Skip to content

Add ephemeral support to BroadcastChannel #17220

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

Closed
goodov opened this issue Jul 28, 2021 · 4 comments · Fixed by brave/brave-core#9578
Closed

Add ephemeral support to BroadcastChannel #17220

goodov opened this issue Jul 28, 2021 · 4 comments · Fixed by brave/brave-core#9578

Comments

@goodov
Copy link
Member

goodov commented Jul 28, 2021

BroadcastChannel currently is not blocked and is shared between 1p and 3p frames with the same origin. We can use ephemeral-specific origins to partition it in ephemeral contexts.

@goodov goodov added OS/Android Fixes related to Android browser functionality OS/Desktop labels Jul 28, 2021
@goodov goodov self-assigned this Jul 28, 2021
@goodov goodov changed the title Add ephemeral BroadcastChannel support Add ephemeral support to BroadcastChannel Jul 28, 2021
@goodov goodov added this to the 1.29.x - Nightly milestone Aug 3, 2021
@stephendonner
Copy link

Setting QA/Blocked until we get a test plan; mind doing the honors again, @goodov 🙏

@goodov
Copy link
Member Author

goodov commented Aug 6, 2021

Ephemeral/partitioned BroadcastChannel manual test can be done like this:

  1. Open https://dev-pages.brave.software/storage/frames.html
  2. Open https://dev-pages.brave.software/storage/frames.html in a second tab
  3. Open https://dev-pages.bravesoftware.com/storage/frames.html in a third tab
  4. Register BroadcastChannel via DevTools in main, nested first-party, nested third-party frames in all tabs with this snippet:
    bc = new BroadcastChannel('bc'); bc.onmessage = (msg) => { console.log(((window.self !== window.parent) ? 'received in iframe: ' : 'received in main frame: ') + window.location.href); console.log(msg); }
  5. Send a broadcast message from different frames using this snippet: bc.postMessage('msg')
  6. Expect messages are send and received according to the ephemeral rules:
    • All first-party frames share same BroadcastChannel per origin.
    • All third-party frames share same BroadcastChannel, but this channel is separate for each main frame eTLD+1 origin. For example, b.com nested in a.com will have a virtual channel a.com+b.com, but b.com nested in c.com will have a virtual channel c.com+b.com.
    • Third-party frames cannot receive messages from first-party frames of the same origin. Example: b.com nested in a.com cannot receive messages sent from b.com opened in another tab.

Test cases:

  1. Send from brave.software main frame, expect received in another brave.software tab and nested first-party brave.software frames, but not in third-party brave.software frames.
  2. Send from third-party bravesoftware.com frame inside brave.software, expect received in third-party bravesoftware.com frames inside brave.software.
  3. Send from bravesoftware.com main frame, expect received in nested first-party bravesoftware.com frame, but not in third-party bravesoftware.com frames.

@stephendonner stephendonner added the QA/In-Progress Indicates that QA is currently in progress for that particular issue label Aug 17, 2021
@stephendonner
Copy link

stephendonner commented Aug 19, 2021

Verified PASSED using the testplan #17220 (comment) with modifications by me, reviewed by @goodov, on build

Brave 1.29.61 Chromium: 92.0.4515.131 (Official Build) beta (x86_64)
Revision 6b8d6c56ce21e38a72f7c4becb5abc1fa5134f29-refs/branch-heads/4515@{#1933}
OS macOS Version 12.0 (Build 21A5304g)

PREREQUISITE: follow the testplan steps 1-4, first.

Testcase 1:

  1. in tab 1, send the message using bc.postMessage('message') from top/dev-pages.brave.software frame
  2. confirm one message shows up in the 1st tab: received in iframe
  3. confirm two messages shows up in the 2nd tab: received in mainframe, received in iframe
  4. ensure no messages received in the 3rd tab
steps 1-2 step 3 step 4
Screen Shot 2021-08-19 at 1 21 06 AM Screen Shot 2021-08-19 at 1 21 11 AM Screen Shot 2021-08-19 at 1 23 08 AM

Testcase 2:

  1. from tab 1, send message using bc.postMessage('message') from storage.html/dev-pages.bravesoftware.com frame
  2. confirm message was received in tab 2: received in iframe <...> dev-pages.bravesoftware.com
  3. ensure no messages received in the 3rd tab
steps 1-2 step 2 step 3
Screen Shot 2021-08-19 at 1 25 13 AM Screen Shot 2021-08-19 at 1 25 21 AM Screen Shot 2021-08-25 at 1 24 10 PM

Testcase 3:

  1. from tab 3, send message using bc.postMessage('message') from top/dev-pages.bravesoftware.com frame
  2. confirm one message shows up in the 3rd tab: received in iframe
  3. a) confirm message was not received in tab 1 and b) tab 2
step 1 step 2 step 3a step 3b
Screen Shot 2021-08-19 at 1 27 42 AM Screen Shot 2021-08-19 at 1 26 56 AM Screen Shot 2021-08-19 at 1 27 46 AM Screen Shot 2021-08-19 at 1 27 51 AM

Verified PASSED using the testplan #17220 (comment)

Brave 1.29.68 Chromium: 92.0.4515.159 (Official Build) beta (64-bit)
Revision 0185b8a19c88c5dfd3e6c0da6686d799e9bc3b52-refs/branch-heads/4515@{#2052}
OS Linux

PREREQUISITE: follow the testplan steps 1-4, first.

Testcase 1:

  1. in tab 1, send the message using bc.postMessage('message') from top/dev-pages.brave.software frame
  2. confirm one message shows up in the 1st tab: received in iframe
  3. confirm two messages shows up in the 2nd tab: received in mainframe, received in iframe
  4. ensure no messages received in the 3rd tab
step 1 step 2 steps 3-4
Screen Shot 2021-08-25 at 1 20 39 PM Screen Shot 2021-08-25 at 1 20 49 PM Screen Shot 2021-08-25 at 1 21 00 PM

Testcase 2:

  1. from tab 1, send message using bc.postMessage('message') from storage.html/dev-pages.bravesoftware.com frame
  2. confirm message was received in tab 2: received in iframe <...> dev-pages.bravesoftware.com
  3. ensure no messages received in the 3rd tab
step 1 step 2 step 3
Screen Shot 2021-08-25 at 1 23 52 PM Screen Shot 2021-08-25 at 1 23 55 PM Screen Shot 2021-08-25 at 1 24 10 PM

Testcase 3:

  1. from tab 3, send message using bc.postMessage('message') from top/dev-pages.bravesoftware.com frame
  2. confirm one message shows up in the 3rd tab: received in iframe
  3. a) confirm message was not received in tab 1 and b) tab 2
steps 1-2 step 3a step 3b
Screen Shot 2021-08-25 at 1 26 39 PM Screen Shot 2021-08-25 at 1 26 56 PM Screen Shot 2021-08-25 at 1 26 58 PM

Verification passed on

Brave | 1.29.75 Chromium: 93.0.4577.58 (Official Build) (64-bit)
-- | --
Revision | c4410ece044414ea42fa4ba328d08195e818a99c-refs/branch-heads/4577@{#1076}
OS | Windows 10 OS Version 2009 (Build 19043.1165)

Verified the test plan from #17220 (comment)

Testcase 1:

  1. in tab 1, send the message using bc.postMessage('message') from top/dev-pages.brave.software frame
  2. confirm one message shows up in the 1st tab: received in iframe
  3. confirm two messages shows up in the 2nd tab: received in mainframe, received in iframe
  4. ensure no messages received in the 3rd tab
steps 1-2 step 3 step 4
image image image

Testcase 2:

  1. from tab 1, send message using bc.postMessage('message') from storage.html/dev-pages.bravesoftware.com frame
  2. confirm message was received in tab 2: received in iframe <...> dev-pages.bravesoftware.com
  3. ensure no messages received in the 3rd tab
steps 1-2 step 2 step 3
image image image

Testcase 3:

  1. from tab 3, send message using bc.postMessage('message') from top/dev-pages.bravesoftware.com frame
  2. confirm one message shows up in the 3rd tab: received in iframe
  3. a) confirm message was not received in tab 1 and b) tab 2
step 2 step 3a step 3b
image image image

@stephendonner stephendonner added QA Pass-macOS and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Aug 19, 2021
@srirambv
Copy link
Contributor

Verification passed on Oppo Reno 5 with Android 11 running 1.29.68 xs64 Beta build

Scenario 1:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 1 to top main frame
  • Send broadcast message from tab 1
  • Tab 2 receives two broad case message, one from top frame and one from iframe
  • Tab 1 only see's iframe broadcast message
  • Tab 3 doesn't get any broadcast message

image

Scenario 2:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 1 to first nested frame
  • Send broadcast message from tab 1
  • Tab 2 receives one broadcast message
  • Tab 3 doesn't receive any broadcast message

image

Scenario 3:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 3 to top main frame
  • Send a broadcast message from tab 3
  • Only tab 3 gets a single response, other 2 tabs doesn't get any broadcast message

image


Verification passed on Samsung Tab A with Android 11 running 1.29.68 xs64 Beta build

Scenario 1:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 1 to top main frame
  • Send broadcast message from tab 1
  • Tab 2 receives two broad case message, one from top frame and one from iframe
  • Tab 1 only see's iframe broadcast message
  • Tab 3 doesn't get any broadcast message
    image

Scenario 2:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 1 to first nested frame
  • Send broadcast message from tab 1
  • Tab 2 receives one broadcast message
  • Tab 3 doesn't receive any broadcast message
    image

Scenario 3:

  • Set broadcast message on all 3 frames for all 3 tabs
  • Set tab 3 to top main frame
  • Send a broadcast message from tab 3
  • Only tab 3 gets a single response, other 2 tabs doesn't get any broadcast message
    image

@stephendonner stephendonner added QA/In-Progress Indicates that QA is currently in progress for that particular issue QA Pass-Linux and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment