Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Service Worker: Redirect loses hash fragment
https://bugs.webkit.org/show_bug.cgi?id=258195 rdar://111208014 Reviewed by Chris Dumez. Make sure to implement the fragment identifier handling defined in https://fetch.spec.whatwg.org/#concept-response-location-url: - If the response has a fragment identifier and the URL computed from the location header does not, add the fragment identifier back. * LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash-worker.js: Added. * LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash.https-expected.txt: Added. * LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash.https.html: Added. * LayoutTests/http/wpt/service-workers/resources/redirect-with-hash.py: Added. (main): * Source/WebCore/platform/network/ResourceRequestBase.cpp: (WebCore::ResourceRequestBase::redirectedRequest const): * Source/WebCore/platform/network/ResourceRequestBase.h: * Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: (WebKit::ServiceWorkerFetchTask::processRedirectResponse): Canonical link: https://commits.webkit.org/265845@main
- Loading branch information
Showing
7 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
addEventListener("fetch", (e) => { | ||
e.respondWith(fetch(e.request)); | ||
}); |
4 changes: 4 additions & 0 deletions
4
LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash.https-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS setup | ||
PASS load iframe with hash | ||
|
29 changes: 29 additions & 0 deletions
29
LayoutTests/http/wpt/service-workers/navigation-redirect-with-hash.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<title>Navigation redirect with hash</title> | ||
<meta name=timeout content=long> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> | ||
<body> | ||
<script> | ||
promise_test(async () => { | ||
const registration = await navigator.serviceWorker.register("navigation-redirect-with-hash-worker.js", { scope : "resources" }); | ||
var activeWorker = registration.active; | ||
if (!activeWorker) { | ||
activeWorker = registration.installing; | ||
await new Promise(resolve => { | ||
activeWorker.addEventListener('statechange', () => { | ||
if (activeWorker.state === "activated") | ||
resolve(registration); | ||
}); | ||
}); | ||
} | ||
}, "setup"); | ||
|
||
promise_test(async () => { | ||
const frame = await with_iframe("/WebKit/service-workers/resources/redirect-with-hash.py#test"); | ||
assert_equals(frame.contentWindow.location.hash, "#test"); | ||
frame.remove(); | ||
}, "load iframe with hash"); | ||
</script> | ||
</body> |
8 changes: 8 additions & 0 deletions
8
LayoutTests/http/wpt/service-workers/resources/redirect-with-hash.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from wptserve.utils import isomorphic_decode | ||
|
||
|
||
def main(request, response): | ||
headers = [] | ||
headers.append((b"Location", b"/redirected")) | ||
|
||
return 302, headers, b"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters