Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
A stopped service worker fails to pass header and referrer on fetch r…
…equest https://bugs.webkit.org/show_bug.cgi?id=242910 rdar://problem/97616866 Reviewed by Alex Christensen. We can use the preoload if we try to load the same request or a cloned request. We cannot in general reuse the preload if the request is changing a bit. Remove the setting of the navigation preload identifier when creating a new request from another. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-changing-request.https-expected.txt: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-changing-request.https.html: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-worker.js: (async event.event.request.url.includes.event.preloadResponse.async return): * LayoutTests/http/wpt/service-workers/resources/fetch-service-worker-preload-script.py: (main): * Source/WebCore/Modules/fetch/FetchRequest.cpp: (WebCore::FetchRequest::initializeWith): Canonical link: https://commits.webkit.org/257110@main
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
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,5 @@ | ||
|
||
|
||
PASS Setup activating worker | ||
PASS Service worker load uses preload through calling fetch on the fetch event request | ||
|
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,67 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="resources/routines.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
var activeWorker; | ||
var uuid = token(); | ||
var url = "/WebKit/service-workers/resources/fetch-service-worker-preload-script.py?getResponseFromRequestWithCustomHeader=yes&customHeader=1&token=" + uuid; | ||
var frame; | ||
const channel = new MessageChannel(); | ||
|
||
function waitUntilActivating() | ||
{ | ||
return new Promise(resolve => { | ||
channel.port2.onmessage = (event) => { | ||
if (event.data === "activating") | ||
resolve(); | ||
}; | ||
}); | ||
} | ||
|
||
function triggerActivation() | ||
{ | ||
activeWorker.postMessage("activate"); | ||
} | ||
|
||
promise_test(async (test) => { | ||
if (window.testRunner) { | ||
testRunner.setUseSeparateServiceWorkerProcess(true); | ||
await fetch("").then(() => { }, () => { }); | ||
} | ||
|
||
let registration = await navigator.serviceWorker.register("/WebKit/service-workers/fetch-service-worker-preload-worker.js", { scope : url }); | ||
if (!registration.installing) { | ||
registration.unregister(); | ||
registration = await navigator.serviceWorker.register("/WebKit/service-workers/fetch-service-worker-preload-worker.js", { scope : url }); | ||
} | ||
|
||
activeWorker = registration.installing; | ||
activeWorker.postMessage({ port: channel.port1 }, [channel.port1]); | ||
|
||
return waitUntilActivating(); | ||
}, "Setup activating worker"); | ||
|
||
promise_test(async (test) => { | ||
fetch(url + "&value=use-preload", { method: 'POST' }); | ||
|
||
// Load iframe, with activating worker, so only preload will start. | ||
const promise = withIframe(url); | ||
|
||
triggerActivation(); | ||
|
||
const frame = await promise; | ||
assert_equals(frame.contentWindow.value, "my-custom-header"); | ||
|
||
// We should have only one GET fetch to url: the service worker preload | ||
const response = await fetch(url + "&count=True"); | ||
assert_equals(await response.text(), "1"); | ||
}, "Service worker load uses preload through calling fetch on the fetch event request"); | ||
</script> | ||
</body> | ||
</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
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