public function ElementsLabelsTest::testTitleEscaping in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Form/ElementsLabelsTest.php \Drupal\Tests\system\Functional\Form\ElementsLabelsTest::testTitleEscaping()
- 9 core/modules/system/tests/src/Functional/Form/ElementsLabelsTest.php \Drupal\Tests\system\Functional\Form\ElementsLabelsTest::testTitleEscaping()
Tests XSS-protection of element labels.
File
- core/
modules/ system/ tests/ src/ Functional/ Form/ ElementsLabelsTest.php, line 100
Class
- ElementsLabelsTest
- Tests form element labels, required markers and associated output.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testTitleEscaping() {
$this
->drupalGet('form_test/form-labels');
foreach (FormTestLabelForm::$typesWithTitle as $type) {
$this
->assertSession()
->responseContains("{$type} alert('XSS') is XSS filtered!");
$this
->assertSession()
->responseNotContains("{$type} <script>alert('XSS')</script> is XSS filtered!");
}
}