Skip to content

HTML: BroadcastChannel and SharedArrayBuffer success case revamp #17760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->

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

<script>
"use strict";

promise_test(t => {
const channelName = token();
return Promise.all([
createIFrame("resources/broadcastchannel-iframe.html"),
createIFrame("resources/broadcastchannel-iframe.html"),
createIFrame("resources/broadcastchannel-iframe.html")
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=0`),
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=1`),
createIFrame(`resources/broadcastchannel-iframe.html?channel=${channelName}&index=2`)
]).then(() => {
const sab = new SharedArrayBuffer(3);
const view = new Uint8Array(sab);
const channel = new BroadcastChannel("channel name");
const channel = new BroadcastChannel(channelName);

return new Promise(resolve => {
let soFar = 0;
channel.onmessage = t.step_func(({ data: { sab: broadcastSAB, i } }) => {
if (broadcastSAB) {
// We only care about "broadcasts" from the workers.
return;
}

channel.onmessage = t.step_func(({ data: { i } }) => {
assert_in_array(i, [0, 1, 2], "Any message events must come from expected sources");
++soFar;

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

<script>
"use strict";
const channel = new BroadcastChannel("channel name");
const query = new URLSearchParams(location.search);
const channel = new BroadcastChannel(query.get("channel"));
const i = Number(query.get("index"));

channel.onmessage = ({ data: { sab, i }, source }) => {
if (!sab) {
channel.onmessage = e => {
const sab = e.data.sab;
if (sab === undefined) {
// We only care about "broadcasts" from the window
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp