Skip to content

Commit 47ec301

Browse files
annevkmoz-wptsync-bot
authored andcommitted
Bug 1564940 [wpt PR 17760] - HTML: BroadcastChannel and SharedArrayBuffer success case revamp, a=testonly
Automatic update from web-platform-tests HTML: BroadcastChannel and SharedArrayBuffer success case revamp The original test could not work. This should be able to work and also adds COOP/COEP headers for future proofing. No browser passes still. For whatwg/html#4734. -- wpt-commits: dedb45f5f20e0ac884ac59634cceb8659cdcff7d wpt-pr: 17760
1 parent 60139b0 commit 47ec301

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,27 @@
66
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
77
<script src="/resources/testharness.js"></script>
88
<script src="/resources/testharnessreport.js"></script>
9+
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
910

1011
<div id="log"></div>
1112

1213
<script>
1314
"use strict";
1415

1516
promise_test(t => {
17+
const channelName = token();
1618
return Promise.all([
17-
createIFrame("resources/broadcastchannel-iframe.html"),
18-
createIFrame("resources/broadcastchannel-iframe.html"),
19-
createIFrame("resources/broadcastchannel-iframe.html")
19+
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=0`),
20+
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=1`),
21+
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=2`)
2022
]).then(() => {
2123
const sab = new SharedArrayBuffer(3);
2224
const view = new Uint8Array(sab);
23-
const channel = new BroadcastChannel("channel name");
25+
const channel = new BroadcastChannel(channelName);
2426

2527
return new Promise(resolve => {
2628
let soFar = 0;
27-
channel.onmessage = t.step_func(({ data: { sab: broadcastSAB, i } }) => {
28-
if (broadcastSAB) {
29-
// We only care about "broadcasts" from the workers.
30-
return;
31-
}
32-
29+
channel.onmessage = t.step_func(({ data: { i } }) => {
3330
assert_in_array(i, [0, 1, 2], "Any message events must come from expected sources");
3431
++soFar;
3532

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Opener-Policy: same-origin
2+
Cross-Origin-Embedder-Policy: require-corp

testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
<script>
66
"use strict";
7-
const channel = new BroadcastChannel("channel name");
7+
const query = new URLSearchParams(location.search);
8+
const channel = new BroadcastChannel(query.get("channel"));
9+
const i = Number(query.get("index"));
810

9-
channel.onmessage = ({ data: { sab, i }, source }) => {
10-
if (!sab) {
11+
channel.onmessage = e => {
12+
const sab = e.data.sab;
13+
if (sab === undefined) {
1114
// We only care about "broadcasts" from the window
1215
return;
1316
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cross-Origin-Embedder-Policy: require-corp

0 commit comments

Comments
 (0)