From dedb45f5f20e0ac884ac59634cceb8659cdcff7d Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 19 Jul 2019 14:57:33 +0200 Subject: [PATCH] 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 https://github.com/whatwg/html/pull/4734. --- ...html => broadcastchannel-success.https.html} | 17 +++++++---------- .../broadcastchannel-success.https.html.headers | 2 ++ .../resources/broadcastchannel-iframe.html | 9 ++++++--- .../broadcastchannel-iframe.html.headers | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) rename html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/{broadcastchannel-success.html => broadcastchannel-success.https.html} (75%) create mode 100644 html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html.headers create mode 100644 html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html.headers diff --git a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.html b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html similarity index 75% rename from html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.html rename to html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html index f6d7f26ce83c17..d3e9956368a5ce 100644 --- a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.html +++ b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html @@ -6,6 +6,7 @@ +
@@ -13,23 +14,19 @@ "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; diff --git a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html.headers b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html.headers new file mode 100644 index 00000000000000..63b60e490f47f4 --- /dev/null +++ b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.https.html.headers @@ -0,0 +1,2 @@ +Cross-Origin-Opener-Policy: same-origin +Cross-Origin-Embedder-Policy: require-corp diff --git a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html index 792d6fd2013807..02b9bcbbe8827e 100644 --- a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html +++ b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/broadcastchannel-iframe.html @@ -4,10 +4,13 @@