Commit d4ca0e6e authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Add missing worklet referrer tests

This CL adds more web-platform-tests for the `Referer` on worklet
descendant requests. This CL introduces tests where we fetch a
same-origin descendant script from a cross-origin worklet script served
with varying referrer policies.

The tests are similar to those introduced in crrev.com/c/1809205 for
module scripts, and will pass once crrev.com/c/1808663 is merged.

R=ikilpatrick@chromium.org, kouhei@chromium.org

Bug: 786862,1004083
Change-Id: I4425be4264424b52e4ec307513a404541869f2a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813122Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699351}
parent b7ab4f74
......@@ -7,12 +7,15 @@ PASS Importing a same-origin script from a page that has "same-origin" referrer
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer.
FAIL Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
FAIL Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
Harness: the test ran to completion.
......@@ -7,12 +7,15 @@ PASS Importing a same-origin script from a page that has "same-origin" referrer
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer.
FAIL Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
FAIL Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
Harness: the test ran to completion.
......@@ -7,12 +7,15 @@ PASS Importing a same-origin script from a page that has "same-origin" referrer
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer.
FAIL Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
FAIL Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
Harness: the test ran to completion.
......@@ -7,12 +7,15 @@ PASS Importing a same-origin script from a page that has "same-origin" referrer
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
PASS Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer.
PASS Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer.
FAIL Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
FAIL Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "The user aborted a request."
Harness: the test ran to completion.
// Forward GET parameters to the server.
import '{{GET[requestor_origin]}}/worklets/resources/referrer-checker.py?referrer_policy={{GET[referrer_policy]}}&expected_referrer={{GET[expected_referrer]}}';
......@@ -88,6 +88,7 @@ function runReferrerTests(workletType) {
// Tests for descendant script fetch -----------------------------------------
// Referrer policy: no-referrer.
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -106,6 +107,15 @@ function runReferrerTests(workletType) {
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "no-referrer" referrer policy should not send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
referrerPolicy: 'no-referrer',
scriptOrigins: { topLevel: 'remote',
descendant: 'same' } });
}, 'Importing a same-origin script from a remote-origin worklet script ' +
'that has "no-referrer" referrer policy should not send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -115,6 +125,7 @@ function runReferrerTests(workletType) {
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "no-referrer" referrer policy should not send referrer.');
// Referrer policy: origin.
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -133,6 +144,15 @@ function runReferrerTests(workletType) {
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "origin" referrer policy should send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
referrerPolicy: 'origin',
scriptOrigins: { topLevel: 'remote',
descendant: 'same' } });
}, 'Importing a same-origin script from a remote-origin worklet script ' +
'that has "origin" referrer policy should send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -142,6 +162,7 @@ function runReferrerTests(workletType) {
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "origin" referrer policy should send referrer.');
// Referrer policy: same-origin.
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -160,6 +181,15 @@ function runReferrerTests(workletType) {
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "same-origin" referrer policy should not send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
referrerPolicy: 'same-origin',
scriptOrigins: { topLevel: 'remote',
descendant: 'same' } });
}, 'Importing a same-origin script from a remote-origin worklet script ' +
'that has "same-origin" referrer policy should send referrer.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
......@@ -168,4 +198,6 @@ function runReferrerTests(workletType) {
descendant: 'remote' } });
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "same-origin" referrer policy should not send referrer.');
// TODO(domfarolino): Add tests for more referrer policies.
}
......@@ -31,6 +31,14 @@ function createScriptURLForDecendant(scriptOrigins) {
'import-remote-origin-referrer-checker-worklet-script.sub.js',
location.href);
}
if (scriptOrigins.topLevel === 'remote' &&
scriptOrigins.descendant === 'same') {
url = new URL(
get_host_info().HTTPS_REMOTE_ORIGIN +
'/worklets/resources/' +
'import-same-origin-referrer-checker-worklet-script-from-remote-origin.sub.js');
return url;
}
if (scriptOrigins.topLevel === 'remote' &&
scriptOrigins.descendant === 'remote') {
return new URL(
......@@ -88,6 +96,7 @@ window.onmessage = e => {
}
const params = new URLSearchParams;
params.append('requestor_origin', document.location.origin);
params.append('referrer_policy', referrerPolicy);
params.append('expected_referrer', expectedReferrer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment