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

Test for opaque redirect handling #10449

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 13 additions & 0 deletions service-workers/redirects/opaque-redirect.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// META: script=../service-worker/resources/test-helpers.sub.js

promise_test(async t => {
const reg = await service_worker_unregister_and_register(t, "resources/opaque-redirect-serviceworker.js", "resources/");
t.add_cleanup(async () => await reg.unregister());
await wait_for_state(t, reg.installing, 'activated');
const frame = await with_iframe("resources/opaque-redirect.py");
assert_equals(frame.contentDocument.body.textContent, "stage 1 completed\n");
frame.remove();
const frame2 = await with_iframe("resources/x/");
assert_equals(frame2.contentDocument.body.textContent, "YAY!\n");
frame2.remove();
}, "Passing an (opaque) redirect with a relative URL in its Location header to a second navigation with a different base URL");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
YAY!
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let evilGlobalState = null;
onfetch = e => {
if(e.request.url.endsWith("resources/opaque-redirect.py")) {
e.respondWith(new Promise(async resolve => {
evilGlobalState = await fetch(e.request);
resolve(new Response("stage 1 completed\n"));
}));
} else if(e.request.url.endsWith("resources/x/")) {
e.respondWith(evilGlobalState);
}
}
3 changes: 3 additions & 0 deletions service-workers/redirects/resources/opaque-redirect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def main(request, response):
response.status = 302
response.headers.set("Location", "opaque-redirect-result.txt")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NOOO :-(