1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<!DOCTYPE html>
<html>
<head>
<title>Referrers with CSS module requests</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script type="module">
// "name" parameter is necessary for bypassing the module map.
import referrerSame from "./resources/referrer-checker.py?name=sameNoReferrerPolicy" with { type: "css"};
import referrerRemote from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/css-module/resources/referrer-checker.py?name=remoteNoReferrerPolicy" with { type: "css"};
const origin = (new URL(location.href)).origin + "/";
const originUrl = location.href;
test(t => {
assert_equals(
referrerSame.rules[0].style.content, '"' + originUrl + '"',
"Referrer URL should be sent for the same-origin top-level script.");
}, "Importing a same-origin top-level script with the default referrer policy.");
test(t => {
assert_equals(
referrerRemote.rules[0].style.content, '"' + origin + '"',
"Referrer origin should be sent for the remote-origin top-level script.");
}, "Importing a remote-origin top-level script with the default referrer policy.");
</script>
<script type="module" referrerpolicy="origin">
import referrerSame from "./resources/referrer-checker.py?name=sameReferrerPolicyOrigin" with { type: "css"};
import referrerRemote from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/css-module/resources/referrer-checker.py?name=remoteReferrerPolicyOrigin" with { type: "css"};
const origin = (new URL(location.href)).origin + "/";
test(t => {
assert_equals(
referrerSame.rules[0].style.content, '"' + origin + '"',
"Referrer origin should be sent for the same-origin top-level script.");
}, "Importing a same-origin top-level script with the origin policy.");
test(t => {
assert_equals(
referrerRemote.rules[0].style.content, '"' + origin + '"',
"Referrer origin should be sent for the remote-origin top-level script.");
}, "Importing a remote-origin top-level script with the origin policy.");
</script>
<script type="module" referrerpolicy="no-referrer">
import referrerSame from "./resources/referrer-checker.py?name=sameReferrerPolicyNoReferrer" with { type: "css"};
import referrerRemote from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/css-module/resources/referrer-checker.py?name=remoteReferrerPolicyNoReferrer" with { type: "css"};
test(t => {
assert_equals(
referrerSame.rules[0].style.content, '""',
"No referrer should be sent for the same-origin top-level script.");
}, "Importing a same-origin top-level script with the no-referrer policy.");
test(t => {
assert_equals(
referrerRemote.rules[0].style.content, '""',
"No referrer should be sent for the remote-origin top-level script.");
}, "Importing a remote-origin top-level script with the no-referrer policy.");
</script>
<script type="module" referrerpolicy="unsafe-url">
import referrerSame from "./resources/referrer-checker.py?name=sameNoReferrerPolicyUnsafeUrl" with { type: "css"};
import referrerRemote from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/css-module/resources/referrer-checker.py?name=remoteNoReferrerPolicyUnsafeUrl" with { type: "css"};
const originUrl = location.href;
test(t => {
assert_equals(
referrerSame.rules[0].style.content, '"' + originUrl + '"',
"Referrer URL should be sent for the same-origin top-level script.");
}, "Importing a same-origin top-level script with the unsafe-url referrer policy.");
test(t => {
assert_equals(
referrerRemote.rules[0].style.content, '"' + originUrl + '"',
"Referrer URL should be sent for the remote-origin top-level script.");
}, "Importing a remote-origin top-level script with the unsafe-url referrer policy.");
</script>
</body>
</html>
|