You are here

public function CspFirefoxBugTest::testSetScriptSrc 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 88

Class

CspFirefoxBugTest
Test Csp handling of Firefox bug #1313937.

Namespace

Drupal\Tests\csp\Unit

Code

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