Skip to content

Commit

Permalink
Fix module script descendant referrer tests (#22038)
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino committed Mar 11, 2020
1 parent ebcb931 commit 324142d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
test(t => {
assert_equals(
referrerSame, location.href,
"Referrer should be sent for the same-origin top-level script.");
"Full referrer should be sent for the same-origin top-level script.");
}, "Importing a same-origin top-level script with the " +
"origin-when-cross-origin policy.");

test(t => {
assert_equals(
referrerRemote, origin,
"Referrer should be sent for the remote-origin top-level script.");
"Referrer should be stripped to the origin when importing " +
"remote-origin top-level script.");
}, "Importing a remote-origin top-level script with the " +
"origin-when-cross-origin policy.");

Expand All @@ -45,31 +46,34 @@
new URL("resources/import-referrer-checker.sub.js", location.href)
assert_equals(
referrerSameSame, scriptURL + "?name=same_same",
"Referrer should be sent for the same-origin descendant script.");
"Full referrer should be sent for same-origin descendant script" +
"imported by same-origin top-level script.");
}, "Importing a same-origin descendant script from a same-origin top-level " +
"script with the origin-when-cross-origin policy.");

test(t => {
assert_equals(
referrerSameRemote, origin,
"Referrer should be sent for the remote-origin descendant script.");
"Referrer should be stripped to the origin for the remote-origin " +
"descendant script imported from same-origin top-level script.");
}, "Importing a remote-origin descendant script from a same-origin top-level " +
"script with the origin-when-cross-origin policy.");

test(t => {
assert_equals(
referrerRemoteRemote, remoteOrigin,
"Referrer should be sent for the remote-origin descendant script.");
const scriptURL = new URL(
"html/semantics/scripting-1/the-script-element/module/resources/" +
"import-referrer-checker.sub.js",
remoteOrigin);
assert_equals(referrerRemoteRemote, scriptURL + "?name=remote_remote",
"Full referrer should be sent for the remote-origin descendant script " +
"imported from a remote-origin top-level script.");
}, "Importing a remote-origin descendant script from a remote-origin " +
"top-level script with the origin-when-cross-origin policy.");

test(t => {
const scriptURL = new URL(
"html/semantics/scripting-1/the-script-element/module/resources/" +
"import-same-origin-referrer-checker-from-remote-origin.sub.js",
remoteOrigin);
assert_equals(referrerRemoteSame, scriptURL + "?name=remote_same",
"Referrer should be sent for the same-origin descendant script.");
assert_equals(referrerRemoteSame, remoteOrigin,
"Referrer should be stripped to the origin for the same-origin " +
"descendant script imported by remote-origin top-level script.");
}, "Importing a same-origin descendant script from a remote-origin " +
"top-level script with the origin-when-cross-origin policy.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,21 @@
"script with the same-origin policy.");

test(t => {
const scriptURL = new URL(
"html/semantics/scripting-1/the-script-element/module/resources/" +
"import-referrer-checker.sub.js", remoteOrigin);
assert_equals(
referrerRemoteRemote, "",
"Referrer should not be sent for the remote-origin descendant script " +
"even if it is imported from the script in the same remote-origin.");
referrerRemoteRemote, scriptURL + "?name=remote_remote",
"Referrer should be sent for the remote-origin descendant script " +
"when it is imported from a top-level script in the same remote-origin.");
}, "Importing a remote-origin descendant script from a remote-origin " +
"top-level script with the same-origin policy.");

test(t => {
const scriptURL = new URL(
"html/semantics/scripting-1/the-script-element/module/resources/" +
"import-same-origin-referrer-checker-from-remote-origin.sub.js",
remoteOrigin);
assert_equals(
referrerRemoteSame, scriptURL + "?name=remote_same",
"Referrer should be sent for the same-origin descendant script " +
"even if it is imported from the script in the remote-origin.");
referrerRemoteSame, "",
"Referrer should not be sent for the same-origin descendant script " +
"when it is imported from a top-level remote-origin script.");
}, "Importing a same-origin descendant script from a remote-origin " +
"top-level script with the same-origin policy.");

Expand Down

0 comments on commit 324142d

Please sign in to comment.