mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
Update web-platform-tests to revision 3cb5a99e5521936fb8819de8aaba806050b84184
This commit is contained in:
parent
1d2c0ba0bc
commit
c700482629
204 changed files with 5112 additions and 1445 deletions
|
@ -0,0 +1,28 @@
|
|||
const SAME_ORIGIN = {origin: get_host_info().HTTP_ORIGIN, name: "SAME_ORIGIN"};
|
||||
const SAME_SITE = {origin: get_host_info().HTTP_REMOTE_ORIGIN, name: "SAME_SITE"};
|
||||
const CROSS_ORIGIN = {origin: get_host_info().HTTP_NOTSAMESITE_ORIGIN, name: "CROSS_ORIGIN"}
|
||||
|
||||
function coop_test(t, host, coop, channelName, hasOpener) {
|
||||
let bc = new BroadcastChannel(channelName);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
let payload = event.data;
|
||||
assert_equals(payload.name, hasOpener ? channelName : "");
|
||||
assert_equals(payload.opener, hasOpener);
|
||||
});
|
||||
|
||||
let w = window.open(`${host.origin}/html/cross-origin-opener/resources/coop_window.py?path=window.sub.html&coop=${escape(coop)}&channel=${channelName}`, channelName);
|
||||
|
||||
// w will be closed by its postback iframe. When out of process,
|
||||
// window.close() does not work.
|
||||
t.add_cleanup(() => w.close());
|
||||
}
|
||||
|
||||
function run_coop_tests(mainTest, testArray) {
|
||||
for (let test of tests) {
|
||||
async_test(t => {
|
||||
coop_test(t, test[0], test[1],
|
||||
`${mainTest}_to_${test[0].name}_${test[1].replace(/ /g,"-")}`,
|
||||
test[2]);
|
||||
}, `${mainTest} document opening popup to ${test[0].origin} with COOP: "${test[1]}"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script src="common.sub.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
let tests = [
|
||||
// popup Origin, popup COOP, expect opener
|
||||
[SAME_ORIGIN, "", true],
|
||||
[SAME_ORIGIN, "jibberish", true],
|
||||
[SAME_ORIGIN, "same-site", false],
|
||||
[SAME_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_ORIGIN, "same-origin", false],
|
||||
[SAME_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[SAME_SITE, "", true],
|
||||
[SAME_SITE, "jibberish", true],
|
||||
[SAME_SITE, "same-site", false],
|
||||
[SAME_SITE, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_SITE, "same-origin", false],
|
||||
[SAME_SITE, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[CROSS_ORIGIN, "", true],
|
||||
[CROSS_ORIGIN, "jibberish", true],
|
||||
[CROSS_ORIGIN, "same-site", false],
|
||||
[CROSS_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[CROSS_ORIGIN, "same-origin", false],
|
||||
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
];
|
||||
|
||||
run_coop_tests("null", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script src="common.sub.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
let tests = [
|
||||
// popup Origin, popup COOP, expect opener
|
||||
[SAME_ORIGIN, "", false],
|
||||
[SAME_ORIGIN, "jibberish", false],
|
||||
[SAME_ORIGIN, "same-site", false],
|
||||
[SAME_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_ORIGIN, "same-origin", true],
|
||||
[SAME_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[SAME_SITE, "", false],
|
||||
[SAME_SITE, "jibberish", false],
|
||||
[SAME_SITE, "same-site", false],
|
||||
[SAME_SITE, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_SITE, "same-origin", false],
|
||||
[SAME_SITE, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[CROSS_ORIGIN, "", false],
|
||||
[CROSS_ORIGIN, "jibberish", false],
|
||||
[CROSS_ORIGIN, "same-site", false],
|
||||
[CROSS_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[CROSS_ORIGIN, "same-origin", false],
|
||||
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
];
|
||||
|
||||
run_coop_tests("same-origin", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
Cross-Origin-Opener-Policy: same-origin
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script src="common.sub.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
let tests = [
|
||||
// popup Origin, popup COOP, expect opener
|
||||
[SAME_ORIGIN, "", true],
|
||||
[SAME_ORIGIN, "jibberish", true],
|
||||
[SAME_ORIGIN, "same-site", false],
|
||||
[SAME_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_ORIGIN, "same-origin", false],
|
||||
[SAME_ORIGIN, "same-origin unsafe-allow-outgoing", true],
|
||||
|
||||
[SAME_SITE, "", true],
|
||||
[SAME_SITE, "jibberish", true],
|
||||
[SAME_SITE, "same-site", false],
|
||||
[SAME_SITE, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_SITE, "same-origin", false],
|
||||
[SAME_SITE, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[CROSS_ORIGIN, "", true],
|
||||
[CROSS_ORIGIN, "jibberish", true],
|
||||
[CROSS_ORIGIN, "same-site", false],
|
||||
[CROSS_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[CROSS_ORIGIN, "same-origin", false],
|
||||
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
];
|
||||
|
||||
run_coop_tests("same-origin_unsafe-allow-outgoing", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
Cross-Origin-Opener-Policy: same-origin unsafe-allow-outgoing
|
|
@ -1,26 +0,0 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
const CHANNEL_NAME = "new_window_same_site";
|
||||
|
||||
async_test(t => {
|
||||
let w = window.open(`${get_host_info().HTTP_REMOTE_ORIGIN}/html/cross-origin-opener/resources/window.sub.html?channel=${CHANNEL_NAME}`, "window_name", "height=200,width=250");
|
||||
|
||||
// w will be closed by its postback iframe. When out of process,
|
||||
// window.close() does not work.
|
||||
t.add_cleanup(() => w.close());
|
||||
|
||||
let bc = new BroadcastChannel(CHANNEL_NAME);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
let payload = event.data;
|
||||
assert_equals(payload.name, "window_name");
|
||||
assert_equals(payload.opener, true);
|
||||
});
|
||||
}, "same-site policy works");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script src="common.sub.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
let tests = [
|
||||
// popup Origin, popup COOP, expect opener
|
||||
[SAME_ORIGIN, "", false],
|
||||
[SAME_ORIGIN, "jibberish", false],
|
||||
[SAME_ORIGIN, "same-site", true],
|
||||
[SAME_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_ORIGIN, "same-origin", false],
|
||||
[SAME_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[SAME_SITE, "", false],
|
||||
[SAME_SITE, "jibberish", false],
|
||||
[SAME_SITE, "same-site", true],
|
||||
[SAME_SITE, "same-site unsafe-allow-outgoing", false],
|
||||
[SAME_SITE, "same-origin", false],
|
||||
[SAME_SITE, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[CROSS_ORIGIN, "", false],
|
||||
[CROSS_ORIGIN, "jibberish", false],
|
||||
[CROSS_ORIGIN, "same-site", false],
|
||||
[CROSS_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[CROSS_ORIGIN, "same-origin", false],
|
||||
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
];
|
||||
|
||||
run_coop_tests("same-site", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script src="common.sub.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
let tests = [
|
||||
// popup Origin, popup COOP, expect opener
|
||||
[SAME_ORIGIN, "", true],
|
||||
[SAME_ORIGIN, "jibberish", true],
|
||||
[SAME_ORIGIN, "same-site", false],
|
||||
[SAME_ORIGIN, "same-site unsafe-allow-outgoing", true],
|
||||
[SAME_ORIGIN, "same-origin", false],
|
||||
[SAME_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[SAME_SITE, "", true],
|
||||
[SAME_SITE, "jibberish", true],
|
||||
[SAME_SITE, "same-site", false],
|
||||
[SAME_SITE, "same-site unsafe-allow-outgoing", true],
|
||||
[SAME_SITE, "same-origin", false],
|
||||
[SAME_SITE, "same-origin unsafe-allow-outgoing", false],
|
||||
|
||||
[CROSS_ORIGIN, "", true],
|
||||
[CROSS_ORIGIN, "jibberish", true],
|
||||
[CROSS_ORIGIN, "same-site", false],
|
||||
[CROSS_ORIGIN, "same-site unsafe-allow-outgoing", false],
|
||||
[CROSS_ORIGIN, "same-origin", false],
|
||||
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
|
||||
];
|
||||
|
||||
run_coop_tests("same-site_unsafe-allow-outgoing", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
Cross-Origin-Opener-Policy: same-site unsafe-allow-outgoing
|
|
@ -0,0 +1,10 @@
|
|||
import urllib
|
||||
import os.path
|
||||
|
||||
def main(request, response):
|
||||
coop = request.GET.first('coop')
|
||||
if coop:
|
||||
response.headers.set('Cross-Origin-Opener-Policy', urllib.unquote(coop))
|
||||
|
||||
path = os.path.join(os.path.dirname(__file__), request.GET.first('path'))
|
||||
response.content = open(path, mode='rb').read()
|
|
@ -2,17 +2,17 @@
|
|||
<meta charset=utf-8>
|
||||
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<div id="status"> </div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.onload = () => {
|
||||
let payload = { name: self.name, opener: !!self.opener };
|
||||
iframe.contentWindow.postMessage(payload, "*");
|
||||
};
|
||||
let channelName = new URL(location).searchParams.get("channel");
|
||||
iframe.src = `${get_host_info().HTTP_ORIGIN}/html/cross-origin-opener/resources/postback.sub.html?channel=${channelName}`;
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.onload = () => {
|
||||
let payload = { name: self.name, opener: !!self.opener };
|
||||
iframe.contentWindow.postMessage(payload, "*");
|
||||
};
|
||||
let channelName = new URL(location).searchParams.get("channel");
|
||||
iframe.src = `${get_host_info().HTTP_ORIGIN}/html/cross-origin-opener/resources/postback.sub.html?channel=${channelName}`;
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue