You are here

public function CspFirefoxBugTest::testSetStyleSrc in Content-Security-Policy 8

Test that directives are not copied if more specific directive set.

@covers ::ff1313937

File

tests/src/Unit/CspFirefoxBugTest.php, line 105

Class

CspFirefoxBugTest
Test Csp handling of Firefox bug #1313937.

Namespace

Drupal\Tests\csp\Unit

Code

public function testSetStyleSrc() {
  $policy = new Csp();
  $policy
    ->setDirective('default-src', [
    Csp::POLICY_SELF,
    Csp::POLICY_STRICT_DYNAMIC,
    "'hash-abc'",
  ]);
  $policy
    ->setDirective('style-src', [
    Csp::POLICY_SELF,
  ]);
  $this
    ->assertEquals("default-src 'self' 'strict-dynamic' 'hash-abc'; script-src 'self' 'strict-dynamic' 'hash-abc'; style-src 'self'", $policy
    ->getHeaderValue());
}