forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helps with whatwg/html#4734 and web-platform-tests#18354.
- Loading branch information
1 parent
5a2b404
commit d7c4bb0
Showing
5 changed files
with
73 additions
and
0 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,50 @@ | ||
// META: script=/common/utils.js | ||
// META: script=/common/get-host-info.sub.js | ||
|
||
function taintedImageBitmap(t) { | ||
return new Promise(resolve => { | ||
const img = new Image(); | ||
img.src = `${get_host_info().HTTPS_REMOTE_ORIGIN}/images/blue.png`; | ||
img.onload = t.step_func(() => { | ||
resolve(createImageBitmap(img)); | ||
}); | ||
img.onerror = t.unreached_func(); | ||
}); | ||
} | ||
|
||
async_test(t => { | ||
const bc = new BroadcastChannel(token()); | ||
const popup = window.open(`resources/coop-coep-popup.html?channel=${bc.name}`); | ||
const popupReady = new Promise(resolve => { | ||
bc.onmessage = t.step_func(resolve); | ||
}); | ||
const imageReady = taintedImageBitmap(t); | ||
Promise.all([popupReady, imageReady]).then(t.step_func(([, bitmap]) => { | ||
bc.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data, "Got failure as expected."); | ||
}); | ||
bc.postMessage(bitmap); | ||
})); | ||
}, "BroadcastChannel'ing a tainted ImageBitmap to a COOP+COEP popup"); | ||
|
||
[ | ||
{ | ||
"type": "serialize/deserialize", | ||
"message": (port, bitmap) => port.postMessage(bitmap) | ||
}, | ||
{ | ||
"type": "transfer", | ||
"message": (port, bitmap) => port.postMessage(bitmap, [bitmap]) | ||
} | ||
].forEach(({ type, message }) => { | ||
async_test(t => { | ||
const sw = new SharedWorker("resources/coop-coep-worker.js"); | ||
const imageReady = taintedImageBitmap(t); | ||
imageReady.then(t.step_func(bitmap => { | ||
sw.port.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data, "Got failure as expected."); | ||
}); | ||
message(sw.port, bitmap); | ||
})); | ||
}, `Messaging a tainted ImageBitMap via ${type} to a COEP shared worker`); | ||
}); |
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,11 @@ | ||
<script> | ||
const channel = new URLSearchParams(location.search).get("channel"); | ||
const bc = new BroadcastChannel(channel); | ||
bc.onmessageerror = e => { | ||
bc.postMessage("Got failure as expected."); | ||
} | ||
bc.onmessage = e => { | ||
bc.postMessage("Got message, expected failure."); | ||
} | ||
bc.postMessage("Initialize"); | ||
</script> |
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,2 @@ | ||
Cross-Origin-Opener-Policy: same-origin | ||
Cross-Origin-Embedder-Policy: require-corp |
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,9 @@ | ||
onconnect = e => { | ||
const port = e.source; | ||
port.onmessageerror = e => { | ||
port.postMessage("Got failure as expected."); | ||
} | ||
port.onmessage = e => { | ||
port.postMessage("Got message, expected failure."); | ||
} | ||
} |
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 @@ | ||
Cross-Origin-Embedder-Policy: require-corp |