Commit e0a84eab authored by Asami Doi's avatar Asami Doi Committed by Commit Bot

ServiceWorker: Add WPT to check if clients.claim() for a blob URL worker works

This CL adds a test case to the existing WPT to check if clients.claim()
for a blob URL worker works well. Currently, the test fails when the
PlzDedicatedWorker feature is enabled. It will be fixed in another CL.

Bug: 1017034
Change-Id: I39adf7364f6f60ea50efa28b96b27b7e67bc2b2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531805Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Asami Doi <asamidoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828650}
parent d5f58580
...@@ -15,6 +15,10 @@ promise_test(function(t) { ...@@ -15,6 +15,10 @@ promise_test(function(t) {
return runTest(t, 'resources/claim-nested-worker-fetch-iframe.html'); return runTest(t, 'resources/claim-nested-worker-fetch-iframe.html');
}, 'fetch() in nested Worker should be intercepted after the client is claimed.'); }, 'fetch() in nested Worker should be intercepted after the client is claimed.');
promise_test(function(t) {
return runTest(t, 'resources/claim-blob-url-worker-fetch-iframe.html');
}, 'fetch() in blob URL Worker should be intercepted after the client is claimed.');
function runTest(t, iframe_url) { function runTest(t, iframe_url) {
var resource = 'simple.txt'; var resource = 'simple.txt';
......
<!doctype html>
<script>
const baseLocation = window.location;
const workerScript =
`self.onmessage = async (e) => {
const url = new URL(e.data, '${baseLocation}').href;
const response = await fetch(url);
const text = await response.text();
self.postMessage(text);
};`;
const blob = new Blob([workerScript], { type: 'text/javascript' });
const blobUrl = URL.createObjectURL(blob);
const worker = new Worker(blobUrl);
function fetch_in_worker(url) {
return new Promise((resolve) => {
worker.onmessage = (e) => resolve(e.data);
worker.postMessage(url);
});
}
</script>
This is a testharness.js-based test.
PASS fetch() in Worker should be intercepted after the client is claimed.
PASS fetch() in nested Worker should be intercepted after the client is claimed.
FAIL fetch() in blob URL Worker should be intercepted after the client is claimed. assert_equals: fetch() in the worker should be intercepted. expected "Intercepted!" but got "a simple text file\n"
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment