function BrowserWithJavascriptTest::testEscapingAssertions
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php \Drupal\FunctionalJavascriptTests\BrowserWithJavascriptTest::testEscapingAssertions()
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php \Drupal\FunctionalJavascriptTests\BrowserWithJavascriptTest::testEscapingAssertions()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php \Drupal\FunctionalJavascriptTests\BrowserWithJavascriptTest::testEscapingAssertions()
Tests assertEscaped() and assertUnescaped().
See also
\Drupal\Tests\WebAssert::assertNoEscaped()
\Drupal\Tests\WebAssert::assertEscaped()
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ BrowserWithJavascriptTest.php, line 87
Class
- BrowserWithJavascriptTest
- Tests if we can execute JavaScript in the browser.
Namespace
Drupal\FunctionalJavascriptTestsCode
public function testEscapingAssertions() : void {
$assert = $this->assertSession();
$this->drupalGet('test-escaped-characters');
$assert->assertNoEscaped('<div class="escaped">');
$assert->responseContains('<div class="escaped">');
$assert->assertEscaped('Escaped: <"\'&>');
$this->drupalGet('test-escaped-script');
$assert->assertNoEscaped('<div class="escaped">');
$assert->responseContains('<div class="escaped">');
$assert->assertEscaped("<script>alert('XSS');alert(\"XSS\");</script>");
$this->drupalGetWithAlert('test-unescaped-script');
$assert->assertNoEscaped('<div class="unescaped">');
$assert->responseContains('<div class="unescaped">');
$assert->responseContains("<script>alert('Marked safe');alert(\"Marked safe\");</script>");
$assert->assertNoEscaped("<script>alert('Marked safe');alert(\"Marked safe\");</script>");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.