Update web-platform-tests to revision 7a6f5673ff5d146ca5c09c6a1b42b7706cfee328

This commit is contained in:
WPT Sync Bot 2018-06-28 21:05:13 -04:00
parent e2fca1b228
commit 4787b28da3
261 changed files with 8195 additions and 4689 deletions

View file

@ -2,25 +2,14 @@
# |expected_referrer|.
def main(request, response):
referrer = request.headers.get("referer", "")
referrer_policy = request.GET.first("referrer_policy")
expected_referrer = request.GET.first("expected_referrer", "")
response_headers = [("Content-Type", "text/javascript"),
("Access-Control-Allow-Origin", "*")]
if referrer_policy == "no-referrer" or referrer_policy == "origin":
if referrer == expected_referrer:
return (200, response_headers, "")
return (404, response_headers)
if referrer_policy == "same-origin":
if referrer == expected_referrer:
return (200, response_headers, "")
# The expected referrer doesn't contain query params for simplification,
# so we check the referrer by startswith() here.
if (expected_referrer != "" and
referrer.startswith(expected_referrer + "?")):
return (200, response_headers, "")
return (404, response_headers)
# The expected referrer doesn't contain query params for simplification, so
# we check the referrer by startswith() here.
if (expected_referrer != "" and
referrer.startswith(expected_referrer + "?")):
return (200, response_headers, "")
return (404, response_headers)

View file

@ -29,7 +29,9 @@ function runReferrerTest(settings) {
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}
// Runs a series of tests related to the referrer policy on a worklet.
// Runs a series of tests related to the referrer policy on a worklet. Referrer
// on worklet module loading should always be handled with the default referrer
// policy.
//
// Usage:
// runReferrerTests("paint");
@ -44,7 +46,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'no-referrer',
scriptOrigins: { topLevel: 'same' } });
}, 'Importing a same-origin script from a page that has "no-referrer" ' +
'referrer policy should not send referrer.');
'referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -52,7 +54,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'no-referrer',
scriptOrigins: { topLevel: 'remote' } });
}, 'Importing a remote-origin script from a page that has "no-referrer" ' +
'referrer policy should not send referrer.');
'referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -60,7 +62,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'origin',
scriptOrigins: { topLevel: 'same' } });
}, 'Importing a same-origin script from a page that has "origin" ' +
'referrer policy should send only an origin as referrer.');
'referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -68,7 +70,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'origin',
scriptOrigins: { topLevel: 'remote' } });
}, 'Importing a remote-origin script from a page that has "origin" ' +
'referrer policy should send only an origin as referrer.');
'referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -76,7 +78,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'same-origin',
scriptOrigins: { topLevel: 'same' } });
}, 'Importing a same-origin script from a page that has "same-origin" ' +
'referrer policy should send referrer.');
'referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -84,7 +86,7 @@ function runReferrerTests(workletType) {
referrerPolicy: 'same-origin',
scriptOrigins: { topLevel: 'remote' } });
}, 'Importing a remote-origin script from a page that has "same-origin" ' +
'referrer policy should not send referrer.');
'referrer policy.');
// Tests for descendant script fetch -----------------------------------------
@ -95,7 +97,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'same' } });
}, 'Importing a same-origin script from a same-origin worklet script that ' +
'has "no-referrer" referrer policy should not send referrer.');
'has "no-referrer" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -104,7 +106,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "no-referrer" referrer policy should not send referrer.');
'that has "no-referrer" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -113,7 +115,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'remote',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "no-referrer" referrer policy should not send referrer.');
'that has "no-referrer" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -122,7 +124,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'same' } });
}, 'Importing a same-origin script from a same-origin worklet script that ' +
'has "origin" referrer policy should send referrer.');
'has "origin" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -131,7 +133,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "origin" referrer policy should send referrer.');
'that has "origin" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -140,7 +142,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'remote',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "origin" referrer policy should send referrer.');
'that has "origin" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -149,7 +151,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'same' } });
}, 'Importing a same-origin script from a same-origin worklet script that ' +
'has "same-origin" referrer policy should send referrer.');
'has "same-origin" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -158,7 +160,7 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'same',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a same-origin worklet script ' +
'that has "same-origin" referrer policy should not send referrer.');
'that has "same-origin" referrer policy.');
promise_test(() => {
return runReferrerTest({ workletType: workletType,
@ -167,5 +169,5 @@ function runReferrerTests(workletType) {
scriptOrigins: { topLevel: 'remote',
descendant: 'remote' } });
}, 'Importing a remote-origin script from a remote-origin worklet script ' +
'that has "same-origin" referrer policy should not send referrer.');
'that has "same-origin" referrer policy.');
}

View file

@ -48,47 +48,30 @@ function isDestinationCrossOrigin(fetchType, scriptOrigins) {
assert_unreached('fetchType has an invalid value.');
}
function createExpectedReferrer(
importerURL, fetchType, referrerPolicy, scriptOrigins) {
if (referrerPolicy === 'no-referrer')
return "";
if (referrerPolicy === 'same-origin') {
if (isDestinationCrossOrigin(fetchType, scriptOrigins))
return "";
// Delete query params to make it easier to match with an actual referrer in
// the referrer-checker.py.
const expectedReferrer = new URL(importerURL);
for (var key of expectedReferrer.searchParams.keys())
expectedReferrer.searchParams.delete(key);
return expectedReferrer;
}
if (referrerPolicy === 'origin')
return (new URL(importerURL)).origin + '/';
assert_unreached('referrerPolicy has an invalid value.');
}
window.onmessage = e => {
const workletType = e.data.workletType;
const fetchType = e.data.fetchType;
const referrerPolicy = e.data.referrerPolicy;
const scriptOrigins = e.data.scriptOrigins;
let scriptURL;
let expectedReferrer;
if (fetchType === 'top-level') {
scriptURL = createScriptURLForTopLevel(scriptOrigins.topLevel);
expectedReferrer = createExpectedReferrer(
location.href, fetchType, referrerPolicy, scriptOrigins);
// The referrer of the top-level script should be this file.
// Delete query params to make it easier to match with an actual referrer in
// the referrer-checker.py.
expectedReferrer = new URL(location.href);
for (var key of expectedReferrer.searchParams.keys())
expectedReferrer.searchParams.delete(key);
} else if (fetchType === 'descendant') {
scriptURL = createScriptURLForDecendant(scriptOrigins);
expectedReferrer = createExpectedReferrer(
scriptURL, fetchType, referrerPolicy, scriptOrigins);
// The referrer of the imported script should be the importer script.
expectedReferrer = scriptURL;
} else {
assert_unreached('fetchType should be \'top-level\' or \'descendant\'');
}
const params = new URLSearchParams;
params.append('referrer_policy', referrerPolicy);
params.append('expected_referrer', expectedReferrer);
get_worklet(workletType).addModule(scriptURL + '?' + params)