Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 5 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /content-security-policy/embedded-enforcement/subsumption_algorithm-unsafe_inline.html?1-8 - WPT Dashboard Interop Dashboard
- /content-security-policy/embedded-enforcement/subsumption_algorithm-unsafe_inline.html?9-last - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<title>Embedded Enforcement: Subsumption Algorithm - 'unsafe-inline' keyword.</title>
<meta name="variant" content="?1-8">
<meta name="variant" content="?9-last">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/testharness-helper.sub.js"></script>
<script src="/common/subset-tests.js"></script>
</head>
<body>
<script>
var tests = [
{ "name": "'strict-dynamic' is ineffective for `style-src`.",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is properly subsumed in `style-src`.",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is only ineffective if the effective returned csp has nonces in `style-src`.",
"returned_csp_1": "style-src 'unsafe-inline' 'nonce-yay'",
"returned_csp_2": "style-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is only ineffective if the effective returned csp has hashes in `style-src`.",
"returned_csp_1": "style-src 'unsafe-inline' 'sha256-abc123'",
"returned_csp_2": "style-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "Returned csp does not have to allow 'unsafe-inline' in `style-src` to be subsumed.",
"returned_csp_1": "style-src 'self'",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' does not matter if returned csp is effectively `none`.",
"required_csp": "style-src 'unsafe-inline'",
"returned_csp_1": "style-src ",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is properly subsumed in `script-src`.",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "Returned csp only loads 'unsafe-inline' scripts with 'nonce-abc'.",
"returned_csp_1": "script-src 'nonce-abc'",
"returned_csp_2": "script-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is ineffective when nonces are present.",
"returned_csp_1": "script-src 'unsafe-inline' 'nonce-abc'",
"returned_csp_2": "script-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "'unsafe-inline' is only ineffective if the effective returned csp has hashes in `script-src`.",
"returned_csp_1": "script-src 'unsafe-inline' 'sha256-abc123' 'nonce-abc'",
"returned_csp_2": "script-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_LOAD },
{ "name": "Required csp allows `strict-dynamic`, but retuned csp does.",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_BLOCK },
{ "name": "Required csp does not allow `unsafe-inline`, but retuned csp does.",
"returned_csp_1": "style-src 'unsafe-inline'",
"returned_csp_2": null,
"expected": IframeLoad.EXPECT_BLOCK },
{ "name": "Returned csp allows a nonce.",
"returned_csp_1": "style-src 'unsafe-inline' 'nonce-abc'",
"returned_csp_2": "style-src 'nonce-abc'",
"expected": IframeLoad.EXPECT_BLOCK },
{ "name": "Returned csp allows a hash.",
"returned_csp_1": "style-src 'unsafe-inline' 'sha256-abc123'",
"returned_csp_2": "style-src 'sha256-abc123'",
"expected": IframeLoad.EXPECT_BLOCK },
{ "name": "Effective returned csp allows 'unsafe-inline'",
"returned_csp_2": "style-src 'unsafe-inline'",
"expected": IframeLoad.EXPECT_BLOCK },
{ "name": "Effective returned csp does not allow 'sha512-321cba' hash.",
"expected": IframeLoad.EXPECT_LOAD },
];
tests.forEach(test => {
subsetTest(async_test, t => {
var url = generateUrlWithPolicies(Host.CROSS_ORIGIN, test.returned_csp_1);
if (test.returned_csp_2)
url.searchParams.append("policy2", test.returned_csp_2);
assert_iframe_with_csp(t, url, test.required_csp, test.expected, test.name, null);
}, test.name);
});
</script>
</body>
</html>