You are here

function ColorSafePreviewTest::testColorPreview in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/color/src/Tests/ColorSafePreviewTest.php \Drupal\color\Tests\ColorSafePreviewTest::testColorPreview()

Ensures color preview.html is sanitized.

File

core/modules/color/src/Tests/ColorSafePreviewTest.php, line 47
Contains \Drupal\color\Tests\ColorSafePreviewTest.

Class

ColorSafePreviewTest
Tests sanitizing color preview loaded from theme.

Namespace

Drupal\color\Tests

Code

function testColorPreview() {

  // Install the color test theme.
  \Drupal::service('theme_handler')
    ->install([
    'color_test_theme',
  ]);
  $this
    ->drupalLogin($this->bigUser);

  // Markup is being printed from a 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
    ->assertText('TEST COLOR PREVIEW');
  $this
    ->assertNoRaw('<script>alert("security filter test");</script>');
  $this
    ->assertRaw('<h2>TEST COLOR PREVIEW</h2>');
}