You are here

protected function NoJavaScriptAnonymousTest::assertNoJavaScriptExceptHtml5Shiv in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php \Drupal\system\Tests\Common\NoJavaScriptAnonymousTest::assertNoJavaScriptExceptHtml5Shiv()

Passes if no JavaScript is found on the page except the HTML5 shiv.

The HTML5 shiv is necessary for e.g. the <article> tag which Drupal 8 uses to work in older browsers like Internet Explorer 8.

1 call to NoJavaScriptAnonymousTest::assertNoJavaScriptExceptHtml5Shiv()
NoJavaScriptAnonymousTest::testNoJavaScript in core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
Tests that anonymous users are not served any JavaScript.

File

core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php, line 58
Contains \Drupal\system\Tests\Common\NoJavaScriptAnonymousTest.

Class

NoJavaScriptAnonymousTest
Tests that anonymous users are not served any JavaScript in the Standard installation profile.

Namespace

Drupal\system\Tests\Common

Code

protected function assertNoJavaScriptExceptHtml5Shiv() {

  // Ensure drupalSettings is not set.
  $settings = $this
    ->getDrupalSettings();
  $this
    ->assertTrue(empty($settings), 'drupalSettings is not set.');

  // Ensure the HTML5 shiv exists.
  $this
    ->assertRaw('html5shiv/html5shiv.min.js', 'HTML5 shiv JavaScript exists.');

  // Ensure no other JavaScript file exists on the page, while ignoring the
  // HTML5 shiv.
  $this
    ->assertNoPattern('/(?<!html5shiv\\.min)\\.js/', "No other JavaScript exists.");
}