зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523986 - P2 wpt test with multi-origins redirect and cache r=valentin,annevk
Use `COOP` to force the process switch in redirect with different origins. Also tests cache each reqeusts. Differential Revision: https://phabricator.services.mozilla.com/D48294 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
71e03366fa
Коммит
e5c641de07
|
@ -0,0 +1,72 @@
|
|||
<!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="resources/common.js"></script>
|
||||
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
|
||||
|
||||
<div id=log></div>
|
||||
<script>
|
||||
|
||||
function url_test_cache(t, url, channelName, hasOpener) {
|
||||
const bc = new BroadcastChannel(channelName);
|
||||
bc.onmessage = t.step_func(event => {
|
||||
const payload = event.data;
|
||||
assert_equals(payload.name, hasOpener ? channelName : "");
|
||||
assert_equals(payload.opener, hasOpener);
|
||||
bc.close()
|
||||
|
||||
// test the same url for cache
|
||||
url_test(t, url, channelName, hasOpener);
|
||||
});
|
||||
|
||||
const w = window.open(url, channelName);
|
||||
|
||||
// w will be closed by its postback iframe. When out of process,
|
||||
// window.close() does not work.
|
||||
t.add_cleanup(() => w.close());
|
||||
}
|
||||
|
||||
// Redirect from hostA to hostB with same coop and coep.
|
||||
// Cache the hostA page if redirectCache is true.
|
||||
// Cache the hostB page if destCache is true.
|
||||
function coop_redirect_cache_test(t, hostA, hostB, coop, coep, redirectCache, destCache, channelName, hasOpener) {
|
||||
let redirectUrl = `${hostA.origin}/html/cross-origin-opener-policy/resources/coop-coep.py`;
|
||||
let redirectCacheString = redirectCache ? "&cache=1" : "";
|
||||
let destCacheString = destCache ? "&cache=1" : "";
|
||||
let destUrl = `${hostB.origin}/html/cross-origin-opener-policy/resources/coop-coep.py?coop=${coop}&coep=${coep}${destCacheString}&channel=${channelName}`;
|
||||
let url = `${redirectUrl}?coop=${coop}&coep=${coep}${redirectCacheString}&redirect=${encodeURIComponent(destUrl)}`;
|
||||
|
||||
url_test_cache(t, url, channelName, hasOpener);
|
||||
}
|
||||
|
||||
function run_redirect_cache_tests(documentCOOPValueTitle, testArray) {
|
||||
for (const test of tests) {
|
||||
async_test(t => {
|
||||
coop_redirect_cache_test(t, test[0], test[1], "same-origin", "require-corp", test[2], test[3], test[4], test[5]);
|
||||
}, `${documentCOOPValueTitle} document opening popup redirect from ${test[0].origin} to ${test[1].origin} with redirectCache ${test[2]} and destCache ${test[3]}`);
|
||||
}
|
||||
}
|
||||
|
||||
let tests = [
|
||||
// popup Origin, final Origin, isCacheRedirect, isCacheDestination, channelName, hasOpener
|
||||
// Origin A->A->B
|
||||
[SAME_ORIGIN, CROSS_ORIGIN, true, false, token(), false],
|
||||
[SAME_ORIGIN, CROSS_ORIGIN, false, true, token(), false],
|
||||
[SAME_ORIGIN, CROSS_ORIGIN, true, true, token(), false],
|
||||
|
||||
// Origin A->B->B
|
||||
[CROSS_ORIGIN, SAME_ORIGIN, true, false, token(), false],
|
||||
[CROSS_ORIGIN, SAME_ORIGIN, false, true, token(), false],
|
||||
[CROSS_ORIGIN, SAME_ORIGIN, true, true, token(), false],
|
||||
|
||||
// Origin A->B->C
|
||||
[SAME_SITE, CROSS_ORIGIN, true, false, token(), false],
|
||||
[SAME_SITE, CROSS_ORIGIN, false, true, token(), false],
|
||||
[SAME_SITE, CROSS_ORIGIN, true, true, token(), false],
|
||||
];
|
||||
|
||||
run_redirect_cache_tests("same-origin", tests);
|
||||
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
Cross-Origin-Opener-Policy: same-origin
|
|
@ -6,6 +6,8 @@ def main(request, response):
|
|||
response.headers.set("Cross-Origin-Opener-Policy", coop)
|
||||
if coep != "":
|
||||
response.headers.set("Cross-Origin-Embedder-Policy", coep)
|
||||
if 'cache' in request.GET:
|
||||
response.headers.set('Cache-Control', 'max-age=3600')
|
||||
|
||||
if redirect != None:
|
||||
response.status = 302
|
||||
|
|
Загрузка…
Ссылка в новой задаче