public function ColorSafePreviewTest::testColorPreview in Drupal 9
Same name and namespace in other branches
- 8 core/modules/color/tests/src/Functional/ColorSafePreviewTest.php \Drupal\Tests\color\Functional\ColorSafePreviewTest::testColorPreview()
Ensures color preview.html is sanitized.
File
- core/
modules/ color/ tests/ src/ Functional/ ColorSafePreviewTest.php, line 47
Class
- ColorSafePreviewTest
- Tests sanitizing color preview loaded from theme.
Namespace
Drupal\Tests\color\FunctionalCode
public function testColorPreview() {
// Install the color test theme.
\Drupal::service('theme_installer')
->install([
'color_test_theme',
]);
$this
->drupalLogin($this->bigUser);
// Markup is being printed from an HTML file located in:
// core/modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html
$url = Url::fromRoute('system.theme_settings_theme', [
'theme' => 'color_test_theme',
]);
$this
->drupalGet($url);
$this
->assertSession()
->pageTextContains('TEST COLOR PREVIEW');
$this
->assertSession()
->responseNotContains('<script>alert("security filter test");</script>');
$this
->assertSession()
->responseContains('<h2>TEST COLOR PREVIEW</h2>');
}