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
[Safari 16 regression] service worker download does not work in case …
…of preloads https://bugs.webkit.org/show_bug.cgi?id=247885 rdar://problem/102312723 Reviewed by Alex Christensen and Geoffrey Garen. When a fetch is converted to download and is served from a service worker that uses a preload, we should use that preload. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-use-download.https-expected.txt: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-use-download.https.html: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-use-download-and-clone.https-expected.txt: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-use-download-and-clone.https.html: Added. * LayoutTests/http/wpt/service-workers/fetch-service-worker-preload-worker.js: (event.event.request.url.includes): Deleted. * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/ios-wk2/http/wpt/service-workers/fetch-service-worker-preload-use-download-and-clone.https-expected.txt: Added. * LayoutTests/platform/ios-wk2/http/wpt/service-workers/fetch-service-worker-preload-use-download.https-expected.txt: Added. * Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: (WebKit::ServiceWorkerFetchTask::convertToDownload): Canonical link: https://commits.webkit.org/256731@main
- Loading branch information
Showing
9 changed files
with
173 additions
and
2 deletions.
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 @@ | ||
Download started. | ||
Downloading URL with suggested filename "fetch-service-worker-preload-script.py.vcf" | ||
Download size: 7. | ||
Download completed. | ||
|
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,63 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="/common/utils.js"></script> | ||
<script src="resources/routines.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.setShouldLogDownloadCallbacks(true); | ||
testRunner.setShouldLogDownloadSize(true); | ||
testRunner.waitUntilDownloadFinished(); | ||
testRunner.setShouldDownloadUndisplayableMIMETypes(true); | ||
} | ||
|
||
var activeWorker; | ||
var uuid = token(); | ||
var url = "/WebKit/service-workers/resources/fetch-service-worker-preload-script.py?download=yes&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"); | ||
} | ||
|
||
async function doTest() { | ||
if (window.testRunner) { | ||
testRunner.setUseSeparateServiceWorkerProcess(true); | ||
await fetch("").then(() => { }, () => { }); | ||
} | ||
|
||
const 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]); | ||
|
||
await waitUntilActivating(); | ||
triggerActivation(); | ||
await registration.navigationPreload.enable(); | ||
|
||
// Download size should be size of "use-preload". | ||
const promise = withIframe(url + "&promise=getCloneResponseFromNavigationPreload"); | ||
} | ||
doTest(); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Download started. | ||
Downloading URL with suggested filename "fetch-service-worker-preload-script.py.vcf" | ||
Download size: 7. | ||
Download completed. | ||
|
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,63 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="/common/utils.js"></script> | ||
<script src="resources/routines.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.setShouldLogDownloadCallbacks(true); | ||
testRunner.setShouldLogDownloadSize(true); | ||
testRunner.waitUntilDownloadFinished(); | ||
testRunner.setShouldDownloadUndisplayableMIMETypes(true); | ||
} | ||
|
||
var activeWorker; | ||
var uuid = token(); | ||
var url = "/WebKit/service-workers/resources/fetch-service-worker-preload-script.py?download=yes&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"); | ||
} | ||
|
||
async function doTest() { | ||
if (window.testRunner) { | ||
testRunner.setUseSeparateServiceWorkerProcess(true); | ||
await fetch("").then(() => { }, () => { }); | ||
} | ||
|
||
const 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]); | ||
|
||
await waitUntilActivating(); | ||
triggerActivation(); | ||
await registration.navigationPreload.enable(); | ||
|
||
// Download size should be size of "use-preload". | ||
const promise = withIframe(url + "&promise=getResponseFromNavigationPreload"); | ||
} | ||
doTest(); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Download started. | ||
Downloading URL with suggested filename "fetch-service-worker-preload-script.py" | ||
Download size: 7. | ||
Download completed. | ||
|
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 @@ | ||
Download started. | ||
Downloading URL with suggested filename "fetch-service-worker-preload-script.py" | ||
Download size: 7. | ||
Download completed. | ||
|
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