protected function BlockXssTest::doMenuTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/block/tests/src/Functional/BlockXssTest.php \Drupal\Tests\block\Functional\BlockXssTest::doMenuTest()
- 9 core/modules/block/tests/src/Functional/BlockXssTest.php \Drupal\Tests\block\Functional\BlockXssTest::doMenuTest()
Tests XSS coming from Menu block labels.
File
- core/
modules/ block/ tests/ src/ Functional/ BlockXssTest.php, line 151
Class
- BlockXssTest
- Tests that the block module properly escapes block descriptions.
Namespace
Drupal\Tests\block\FunctionalCode
protected function doMenuTest() {
Menu::create([
'id' => $this
->randomMachineName(),
'label' => '<script>alert("menu");</script>',
])
->save();
$this
->drupalGet(Url::fromRoute('block.admin_display'));
$this
->clickLink('Place block');
$this
->assertSession()
->assertEscaped('<script>alert("menu");</script>');
$this
->assertSession()
->responseNotContains('<script>alert("menu");</script>');
}