diff --git a/core/modules/system/src/Tests/Bootstrap/GetFilenameTest.php b/core/modules/system/src/Tests/Bootstrap/GetFilenameTest.php
new file mode 100644
index 0000000..25585ad
--- /dev/null
+++ b/core/modules/system/src/Tests/Bootstrap/GetFilenameTest.php
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\system\Tests\Bootstrap\GetFilenameTest.
+ */
+
+namespace Drupal\system\Tests\Bootstrap;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests that drupal_get_filename() works correctly after Drupal bootstrap.
+ *
+ * @group Bootstrap
+ */
+class GetFilenameTest extends WebTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['system_test'];
+
+  /**
+   * Tests that drupal_get_filename() works for profiles.
+   */
+  function testProfileDrupalGetFilename() {
+    // This works because the static cache of drupal_get_filename() has been
+    // initialized with all installation profiles during the install and we are
+    // inside the same request.
+    $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.info.yml');
+
+    // This is a trick to run drupal_get_filename('profile', 'standard') in
+    // other PHP space and have the static cache non-initialized by the
+    // installation process.
+    $this->drupalGet('system-test/drupal-get-filename');
+    $this->assertText('core/profiles/standard/standard.info.yml');
+
+    // Detection of uninstalled modules does not work anymore (in D7 they did).
+    $this->assertFalse($this->container->get('module_handler')->moduleExists('actions'));
+    $this->assertIdentical(drupal_get_filename('module', 'actions'), 'core/modules/actions/actions.info.yml');
+
+    // Detection of uninstalled theme still works. Inconsistency?
+    $this->assertFalse($this->container->get('theme_handler')->themeExists('stark'));
+    $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
+  }
+
+}
diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
index 15ab478..a6cb6d0 100644
--- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
+++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
@@ -318,4 +318,16 @@ public function permissionDependentContent() {
     return $build;
   }
 
+  /**
+   * Tries to get the path for a nod-default profile.
+   *
+   * @return array
+   *   A render array.
+   */
+  public function drupalGetFilename() {
+    return [
+      '#markup' => drupal_get_filename('profile', 'standard'),
+    ];
+  }
+
 }
diff --git a/core/modules/system/tests/modules/system_test/system_test.routing.yml b/core/modules/system/tests/modules/system_test/system_test.routing.yml
index ecb9921..97f78fd 100644
--- a/core/modules/system/tests/modules/system_test/system_test.routing.yml
+++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml
@@ -129,3 +129,10 @@ system_test.permission_dependent_route_access:
     _controller: '\Drupal\system_test\Controller\SystemTestController::mainContentFallback'
   requirements:
     _permission: 'pet llamas'
+
+system_test.drupal_get_filename:
+  path: '/system-test/drupal-get-filename'
+  defaults:
+    _controller: '\Drupal\system_test\Controller\SystemTestController::drupalGetFilename'
+  requirements:
+    _access: 'TRUE'
