public function BrowserWithJavascriptTest::testEscapingAssertions in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php \Drupal\FunctionalJavascriptTests\BrowserWithJavascriptTest::testEscapingAssertions()
- 9 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() {
$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>");
}