Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

  • This test has a WPT meta file that expects 1 subtest issues.
  • This WPT test may be referenced by the following Test IDs:
<!DOCTYPE html>
<html>
<head>
<title>script-url-blocked-and-sends-hash in shared worker</title>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/util.js"></script>
</head>
<body>
<script>
const scriptUrl = new URL("./support/externalScript.js", document.location).toString();
promise_test(async t => {
const expectedHash = await sha256ofURL(scriptUrl);
return new Promise((resolve, reject) => {
const w = new SharedWorker("./support/worker-report-hash.js");
w.port.onmessage = e => {
if (e.data.type === 'violation') {
try {
assert_equals(e.data.blockedURI, scriptUrl);
assert_equals(e.data.urlHash.replace(/=+$/, ''), `url-sha256-${expectedHash}`);
assert_equals(e.data.evalHash, "");
resolve();
} catch (err) {
reject(err);
}
}
};
});
}, "script-specific violation report contains correct urlHash in shared worker");
</script>
</body>
</html>