Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing worklet referrer tests #19165

Merged
merged 2 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions worklets/animation-worklet-referrer.https.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down
1 change: 1 addition & 0 deletions worklets/audio-worklet-referrer.https.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down
1 change: 1 addition & 0 deletions worklets/layout-worklet-referrer.https.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down
1 change: 1 addition & 0 deletions worklets/paint-worklet-referrer.https.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 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]}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Access-Control-Allow-Origin: *
32 changes: 32 additions & 0 deletions worklets/resources/referrer-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function runReferrerTests(workletType) {

// Tests for descendant script fetch -----------------------------------------

// Referrer policy: no-referrer.
promise_test(() => {
return runReferrerTest({ workletType: workletType,
fetchType: 'descendant',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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.
}
9 changes: 9 additions & 0 deletions worklets/resources/referrer-window.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
'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(
Expand Down Expand Up @@ -88,6 +96,7 @@
}

const params = new URLSearchParams;
params.append('requestor_origin', document.location.origin);
params.append('referrer_policy', referrerPolicy);
params.append('expected_referrer', expectedReferrer);

Expand Down