diff --git a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php
index 09565aefae..3e858fe09d 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php
@@ -137,6 +137,17 @@ public function testLogging() {
     // and so should remain unconverted until that function is removed.
     $result = statistics_get($node_id);
     $this->assertIdentical($result, FALSE);
+
+    // Verify that path to statistics.php is correct.
+    $this->node->save();
+    $this->drupalGet($path);
+    $settings = $this->getDrupalSettings();
+    $this->assertFileExists(DRUPAL_ROOT . $settings['statistics']['url']);
+
+    $this->node->save();
+    $this->drupalGet('index.php/' . $path);
+    $settings = $this->getDrupalSettings();
+    $this->assertFileExists(DRUPAL_ROOT . $settings['statistics']['url']);
   }
 
 }
diff --git a/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
new file mode 100644
index 0000000000..b015e96c90
--- /dev/null
+++ b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Drupal\Tests\statistics\FunctionalJavascript;
+
+use Drupal\Core\Session\AccountInterface;
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\user\Entity\Role;
+
+/**
+ * Tests that statistics works.
+ *
+ * @group system
+ */
+class StatisticsLoggingTest extends JavascriptTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['node', 'block', 'statistics', 'language'];
+
+  /**
+   * Node for tests.
+   *
+   * @var \Drupal\node\Entity\Node
+   */
+  protected $node;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->config('statistics.settings')
+      ->set('count_content_views', 1)
+      ->save();
+
+    Role::load(AccountInterface::ANONYMOUS_ROLE)
+      ->grantPermission('view post access counter')
+      ->save();
+
+    ConfigurableLanguage::create(['id' => 'xx'])->save();
+    $this->config('language.negotiation')->set('url.prefixes.en', 'en')->save();
+
+    $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+    $this->node = $this->drupalCreateNode();
+  }
+
+  /**
+   * Tests that statistics with/without "index.php" prefix.
+   *
+   * @dataProvider providerTestLoggingPage
+   */
+  public function testLoggingPage($path) {
+    $page = $this->getSession()->getPage();
+
+    $this->drupalGet($path);
+    // During the first load there are no statistics yet.
+    $this->assertNotContains('1 view', $page->getContent());
+    // Wait while statistics module send ajax request.
+    $this->assertSession()->assertWaitOnAjaxRequest();
+    // Resaving the node to call the hook_node_links_alter(), which is used to
+    // update information on the page. See statistics_node_links_alter().
+    $this->node->save();
+
+    $this->drupalGet($path);
+    $this->assertContains('1 view', $page->getContent());
+  }
+
+  /**
+   * Data provider for testLoggingPage().
+   */
+  public function providerTestLoggingPage() {
+    return [
+      ['node/1'],
+      ['en/node/1'],
+      ['index.php/node/1'],
+      ['index.php/en/node/1'],
+    ];
+  }
+
+}
