Update web-platform-tests to revision 14cfa4d648cc1c853b4153268df672d21425f8c1

This commit is contained in:
Josh Matthews 2017-10-30 09:31:22 -04:00
parent 1b73cf3352
commit 75736751d9
1213 changed files with 19434 additions and 12344 deletions

View file

@ -4,11 +4,12 @@
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/worklet-test-utils.js"></script>
<script src="resources/import-tests.js"></script>
</head>
<body>
<script>
runImportTests(window.animationWorklet);
runImportTests("animation");
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/worklet-test-utils.js"></script>
<script src="resources/referrer-tests.js"></script>
</head>
<body>
<script>
runReferrerTests("animation");
</script>
</body>
</html>

View file

@ -4,11 +4,12 @@
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/worklet-test-utils.js"></script>
<script src="resources/import-tests.js"></script>
</head>
<body>
<script>
runImportTests(CSS.paintWorklet);
runImportTests("paint");
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/worklet-test-utils.js"></script>
<script src="resources/referrer-tests.js"></script>
</head>
<body>
<script>
runReferrerTests("paint");
</script>
</body>
</html>

View file

@ -1,8 +1,10 @@
// Runs a series of tests related to importing scripts on a worklet.
//
// Usage:
// runImportTests(workletType);
function runImportTests(worklet) {
// runImportTests("paint");
function runImportTests(worklet_type) {
const worklet = get_worklet(worklet_type);
promise_test(() => {
const kScriptURL = 'resources/empty-worklet-script.js';
return worklet.addModule(kScriptURL).then(undefined_arg => {

View file

@ -0,0 +1,96 @@
function openWindow(url) {
return new Promise(resolve => {
let win = window.open(url, '_blank');
add_completion_callback(() => win.close());
window.onmessage = e => {
assert_equals(e.data, 'LOADED');
resolve(win);
};
});
}
// Runs a series of tests related to the referrer policy on a worklet.
//
// Usage:
// runReferrerTests("paint");
function runReferrerTests(worklet_type) {
const worklet = get_worklet(worklet_type);
promise_test(() => {
const kWindowURL = "resources/referrer-window.html" +
"?pipe=header(Referrer-Policy,no-referrer)";
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'no-referrer',
is_cross_origin: false }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a same-origin script from a page that has "no-referrer" ' +
'referrer policy should not send referrer.');
promise_test(() => {
const kWindowURL = "resources/referrer-window.html" +
"?pipe=header(Referrer-Policy,no-referrer)";
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'no-referrer',
is_cross_origin: true }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a remote-origin script from a page that has "no-referrer" ' +
'referrer policy should not send referrer.');
promise_test(() => {
const kWindowURL = 'resources/referrer-window.html' +
'?pipe=header(Referrer-Policy,origin)';
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'origin',
is_cross_origin: false }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a same-origin script from a page that has "origin" ' +
'referrer policy should send only an origin as referrer.');
promise_test(() => {
const kWindowURL = 'resources/referrer-window.html' +
'?pipe=header(Referrer-Policy,origin)';
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'origin',
is_cross_origin: true }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a remote-origin script from a page that has "origin" ' +
'referrer policy should send only an origin as referrer.');
promise_test(() => {
const kWindowURL = 'resources/referrer-window.html' +
'?pipe=header(Referrer-Policy,same-origin)';
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'same-origin',
is_cross_origin: false }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a same-origin script from a page that has "same-origin" ' +
'referrer policy should send referrer.');
promise_test(() => {
const kWindowURL = 'resources/referrer-window.html' +
'?pipe=header(Referrer-Policy,same-origin)';
return openWindow(kWindowURL).then(win => {
const promise = new Promise(resolve => window.onmessage = resolve);
win.postMessage({ type: worklet_type,
referrer_policy: 'same-origin',
is_cross_origin: true }, '*');
return promise;
}).then(msg_event => assert_equals(msg_event.data, 'RESOLVED'));
}, 'Importing a remote-origin script from a page that has "same-origin" ' +
'referrer policy should not send referrer.');
}

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>Worklet: Referrer</title>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="worklet-test-utils.js"></script>
</head>
<body>
<script>
window.onmessage = e => {
const worklet_type = e.data.type;
const is_cross_origin = e.data.is_cross_origin;
const params = new URLSearchParams;
params.append('referrer_policy', e.data.referrer_policy)
params.append('source_origin', get_host_info().HTTP_ORIGIN);
let script_url = '';
if (is_cross_origin) {
params.append('is_cross_origin', 'true')
script_url = get_host_info().HTTP_REMOTE_ORIGIN + '/worklets/resources/';
}
script_url += 'referrer.py?' + params;
get_worklet(worklet_type).addModule(script_url)
.then(() => window.opener.postMessage('RESOLVED', '*'))
.catch(e => window.opener.postMessage(e.message, '*'));
};
window.opener.postMessage('LOADED', '*');
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
# Returns a valid response when request's |referrer| matches |referrer_policy|.
def main(request, response):
referrer = request.headers.get("referer", None)
referrer_policy = request.GET.first("referrer_policy")
source_origin = request.GET.first("source_origin")
is_cross_origin = request.GET.first("is_cross_origin", False)
response_headers = [("Content-Type", "text/javascript"),
("Access-Control-Allow-Origin", source_origin)];
# When the referrer policy is "no-referrer", the referrer header shouldn't
# be sent.
if referrer_policy == "no-referrer" and not referrer:
return (200, response_headers, "")
# When the referrer policy is "origin", the referrer header should contain
# only the origin. Note that |referrer| contains a trailing slash, while
# |source_origin| doesn't.
if referrer_policy == "origin" and referrer == source_origin + "/":
return (200, response_headers, "")
# When the referrer policy is "same-origin", the referrer header should be
# sent only for a same-origin request.
if referrer_policy == "same-origin":
if is_cross_origin and not referrer:
return (200, response_headers, "")
if not is_cross_origin and referrer:
return (200, response_headers, "")
return (404)

View file

@ -0,0 +1,8 @@
// Returns a reference to a worklet object corresponding to a given type.
function get_worklet(type) {
if (type == 'paint')
return CSS.paintWorklet;
if (type == 'animation')
return window.animationWorklet;
return undefined;
}