PSA: Enabling BroadcastChannel usage in opaque origin contexts

50 views
Skip to first unread message

Andrew Williams

unread,
Mar 18, 2022, 3:32:01 PMMar 18
to blink-dev

Hi blink-dev@,


As implemented in Chrome today, attempting to create a BroadcastChannel instance in an opaque origin context will result in an exception being thrown. We plan to ship a minor change that will allow BroadcastChannel instances to be created and used in these contexts, which will align Chrome with the HTML standard [1] and with Firefox / Safari. We don’t expect any breakage as a result of this change, and there is existing web platform test coverage [2] [3] to ensure that BroadcastChannel works as expected in opaque origin contexts. A CL implementing the change [4] has been reviewed and is ready to land, so we expect this to ship with M102. This effort is tracked by crbug 670024 [5].


Let me know if you have any questions. Thank you!


-Andrew


[1] https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts 

[2] https://github.com/web-platform-tests/wpt/blob/master/webmessaging/broadcastchannel/sandbox.html

[3] https://github.com/web-platform-tests/wpt/blob/master/webmessaging/broadcastchannel/opaque-origin.html

[4] https://chromium-review.googlesource.com/c/chromium/src/+/3520021 

[5] https://bugs.chromium.org/p/chromium/issues/detail?id=670024

Yoav Weiss

unread,
Mar 21, 2022, 3:49:15 AMMar 21
to Andrew Williams, blink-dev
Thanks for the PSA Andrew. Since we're going from throwing an exception to not throwing one, this does seem like a safe change.

Reading through the spec, it indeed doesn't seem like broadcasting from an opaque origin should throw, but at the same time, IIUC, this broadcast will also not reach any other browsing contexts, as an opaque origin would be serializable to "null". Do I understand this correctly? Or would two opaque origins in two different browsing contexts be able to BroadcastMessage each other after this change?

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAEa0%2BkVpMwdP8VCujnidyyE9Fr0m41f%2Bdu3kfd7Msd7zNdhKsw%40mail.gmail.com.

Andrew Williams

unread,
Mar 21, 2022, 11:12:43 AMMar 21
to MROKU, blink-dev
Thanks for taking a look, Yoav.  I believe your understanding aligns with mine - BroadcastChannel instances in an opaque origin context can only exchange messages with other instances tied to that same opaque origin, and there's no way to create the same opaque origin in another browsing context.

Related to this, I added a WPT that tests that BroadcastChannel instances in different opaque origins (in the same document) can't exchange messages [6], and it currently passes in Firefox [7].  In Safari, it currently fails, but I've opened a WebKit bug report [8] for this.

-Andrew


On Mon, Mar 21, 2022 at 4:07 AM MROKU <thes...@gmail.com> wrote:
THX

Jeremy Roman

unread,
Mar 21, 2022, 11:15:57 AMMar 21
to Andrew Williams, MROKU, blink-dev
On Mon, Mar 21, 2022 at 11:12 AM Andrew Williams <awi...@chromium.org> wrote:
Thanks for taking a look, Yoav.  I believe your understanding aligns with mine - BroadcastChannel instances in an opaque origin context can only exchange messages with other instances tied to that same opaque origin, and there's no way to create the same opaque origin in another browsing context.

Opening an about:blank window from the opaque origin window does so, right? I guess this means that unrelated BCs can't be same-origin.

Related to this, I added a WPT that tests that BroadcastChannel instances in different opaque origins (in the same document) can't exchange messages [6], and it currently passes in Firefox [7].  In Safari, it currently fails, but I've opened a WebKit bug report [8] for this.

-Andrew


On Mon, Mar 21, 2022 at 4:07 AM MROKU <thes...@gmail.com> wrote:
THX

piątek, 18 marca 2022 o 20:32:01 UTC+1 awi...@chromium.org napisał(a):

Hi blink-dev@,


As implemented in Chrome today, attempting to create a BroadcastChannel instance in an opaque origin context will result in an exception being thrown. We plan to ship a minor change that will allow BroadcastChannel instances to be created and used in these contexts, which will align Chrome with the HTML standard [1] and with Firefox / Safari. We don’t expect any breakage as a result of this change, and there is existing web platform test coverage [2] [3] to ensure that BroadcastChannel works as expected in opaque origin contexts. A CL implementing the change [4] has been reviewed and is ready to land, so we expect this to ship with M102. This effort is tracked by crbug 670024 [5].


Let me know if you have any questions. Thank you!


-Andrew


[1] https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts 

[2] https://github.com/web-platform-tests/wpt/blob/master/webmessaging/broadcastchannel/sandbox.html

[3] https://github.com/web-platform-tests/wpt/blob/master/webmessaging/broadcastchannel/opaque-origin.html

[4] https://chromium-review.googlesource.com/c/chromium/src/+/3520021 

[5] https://bugs.chromium.org/p/chromium/issues/detail?id=670024

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Marijn Kruisselbrink

unread,
Mar 23, 2022, 6:46:47 PMMar 23
to Jeremy Roman, Andrew Williams, MROKU, blink-dev
Also opening a dedicated worker from an opaque origin window/iframe would result in a worker and frame with the same same-origin opaque origin.

Reply all
Reply to author
Forward
0 new messages