Skip to content

Commit

Permalink
Make a SharedWorker blob URL inherits the parent controller.
Browse files Browse the repository at this point in the history
Bug: 324939068

Change-Id: Ie3f43cb510c41930991f3704427b44a79d86d881
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5307317
Commit-Queue: Yoshisato Yanagisawa <[email protected]>
Reviewed-by: Hiroki Nakagawa <[email protected]>
Reviewed-by: Shunya Shishido <[email protected]>
Reviewed-by: Minoru Chikamune <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1263113}
  • Loading branch information
yoshisatoyanagisawa authored and chromium-wpt-export-bot committed Feb 21, 2024
1 parent e7ef6d0 commit 44c02e3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
});
}, 'Same-origin blob URL worker should intercept fetch().');

promise_test(function(t) {
return doAsyncTest(t, {
scheme: 'blob',
child: 'sharedworker',
check: 'fetch',
expect: 'intercept',
});
}, 'Same-origin blob URL sharedworker should intercept fetch().');

promise_test(function(t) {
return doAsyncTest(t, {
scheme: 'data',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@
self.postMessage(text);
}).catch(e => {
self.postMessage(e.message);
});`
});`;

const sharedWorkerFetchText =
`self.onconnect = (e) => {
const port = e.ports[0];
fetch('${fetchURL}', { mode: 'no-cors' }).then(response => {
return response.text();
}).then(text => {
port.postMessage(text);
}).catch(e => {
port.postMessage(e.message);
});
};`;

function getChildText(opts) {
if (opts.child === 'iframe') {
Expand All @@ -69,6 +81,14 @@
throw('unexpected feature to check: ' + opts.check);
}

if (opts.child === 'sharedworker') {
if (opts.check === 'fetch') {
return sharedWorkerFetchText;
}

throw('unexpected feature to check: ' + opts.check);
}

throw('unexpected child type ' + opts.child);
}

Expand Down Expand Up @@ -98,6 +118,16 @@
});
}

function testSharedWorkerChild(url) {
let w = new SharedWorker(url);
return new Promise((resolve, reject) => {
w.port.onmessage = resolve;
w.onerror = evt => {
reject(evt.message);
}
});
}

function testIframeChild(url) {
let frame = document.createElement('iframe');
frame.src = url;
Expand All @@ -115,6 +145,10 @@
return testWorkerChild(url);
}

if (opts.child === 'sharedworker') {
return testSharedWorkerChild(url);
}

if (opts.child === 'iframe') {
return testIframeChild(url);
}
Expand Down

0 comments on commit 44c02e3

Please sign in to comment.