function NoJavaScriptAnonymousTest::testNoJavaScript

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Common/NoJavaScriptAnonymousTest.php \Drupal\Tests\system\Functional\Common\NoJavaScriptAnonymousTest::testNoJavaScript()

Tests that anonymous users are not served any JavaScript.

File

core/modules/system/tests/src/Functional/Common/NoJavaScriptAnonymousTest.php, line 28

Class

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

Namespace

Drupal\Tests\system\Functional\Common

Code

public function testNoJavaScript() {
    // Create a node that is listed on the frontpage.
    $this->drupalCreateNode([
        'promote' => NodeInterface::PROMOTED,
    ]);
    $user = $this->drupalCreateUser();
    // Test frontpage.
    $this->drupalGet('');
    $this->assertNoJavaScriptExceptHtml5Shiv();
    // Test node page.
    $this->drupalGet('node/1');
    $this->assertNoJavaScriptExceptHtml5Shiv();
    // Test user profile page.
    $this->drupalGet('user/' . $user->id());
    $this->assertNoJavaScriptExceptHtml5Shiv();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.