-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BroadcastChannel] Add Partitioning WPT
This CL tests that BroadcastChannel is partitioned in third-party contexts (tentative, pending changes to the spec). For more info, see whatwg/html#5803 Bug: 1239274 Change-Id: I8d495ecb141847276aefd1bcc4a1af0ea1098db2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3424369 Reviewed-by: Ben Kelly <[email protected]> Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Andrew Williams <[email protected]> Cr-Commit-Position: refs/heads/main@{#967421} NOKEYCHECK=True GitOrigin-RevId: e8bbaf8fa8b41dfc7c68fd5f42cf6ea0379a67c9
- Loading branch information
1 parent
3c5a5f1
commit 62a0363
Showing
5 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...s/external/wpt/webmessaging/broadcastchannel/cross-partition.https.tentative-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This is a testharness.js-based test. | ||
FAIL BroadcastChannel messages aren't received from a cross-partition iframe assert_equals: expected "msg from iframe2" but got "msg from iframe1" | ||
Harness: the test ran to completion. | ||
|
72 changes: 72 additions & 0 deletions
72
...web_tests/external/wpt/webmessaging/broadcastchannel/cross-partition.https.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<!-- Pull in executor_path needed by newPopup / newIframe --> | ||
<script src="/html/cross-origin-embedder-policy/credentialless/resources/common.js"></script> | ||
<!-- Pull in newPopup / newIframe --> | ||
<script src="/html/cross-origin-embedder-policy/anonymous-iframe/resources/common.js"></script> | ||
<body> | ||
<script> | ||
|
||
const emit_script = (channel_name, message, done_queue_name) => ` | ||
const bc = new BroadcastChannel("${channel_name}"); | ||
bc.postMessage("${message}"); | ||
send("${done_queue_name}", "done"); | ||
`; | ||
|
||
promise_test(async t => { | ||
const origin = get_host_info().HTTPS_ORIGIN; | ||
const not_same_site_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN; | ||
const response_queue_uuid = token(); | ||
|
||
const popup_init_script = ` | ||
const importScript = ${importScript}; | ||
await importScript("/html/cross-origin-embedder-policy/credentialless" + | ||
"/resources/common.js"); | ||
await importScript("/html/cross-origin-embedder-policy/anonymous-iframe" + | ||
"/resources/common.js"); | ||
await importScript("/common/utils.js"); | ||
send("${response_queue_uuid}", newIframe("${origin}")); | ||
`; | ||
|
||
// Create a same-origin iframe in a cross-site popup. | ||
const not_same_site_popup_uuid = newPopup(t, not_same_site_origin); | ||
send(not_same_site_popup_uuid, popup_init_script); | ||
const iframe_1_uuid = await receive(response_queue_uuid); | ||
|
||
// Create a same-origin iframe in a same-site popup. | ||
const same_origin_popup_uuid = newPopup(t, origin); | ||
send(same_origin_popup_uuid, popup_init_script); | ||
const iframe_2_uuid = await receive(response_queue_uuid); | ||
|
||
const channel_name = token(); | ||
const bc = new BroadcastChannel(channel_name); | ||
bc.onmessage = t.step_func(e => { | ||
assert_equals(e.data, "msg from iframe2"); | ||
t.done(); | ||
}); | ||
|
||
// Instruct the not-same-top-level-site iframe to send a message on the BC | ||
// channel we are listening on. This message should not be received since | ||
// the iframe should be in a different partition. | ||
send(iframe_1_uuid, | ||
emit_script(channel_name, "msg from iframe1", response_queue_uuid)); | ||
assert_equals(await receive(response_queue_uuid), "done"); | ||
|
||
// Now instruct the same-top-level-site iframe to send a BC message. By | ||
// the time we send the script to execute, have it send the BC message, | ||
// and then receive the BC message in our BC instance, it should be | ||
// reasonable to assume that the message from the first iframe would have | ||
// been delivered if it was going to be. | ||
send(iframe_2_uuid, | ||
emit_script(channel_name, "msg from iframe2", response_queue_uuid)); | ||
assert_equals(await receive(response_queue_uuid), "done"); | ||
|
||
}, "BroadcastChannel messages aren't received from a cross-partition iframe"); | ||
|
||
</script> | ||
</body> |
2 changes: 2 additions & 0 deletions
2
...al/third-party-storage-partitioning/external/wpt/webmessaging/broadcastchannel/README.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This suite runs BroadcastChannel tests with ThirdPartyStoragePartitioning | ||
enabled. |
4 changes: 4 additions & 0 deletions
4
...g/external/wpt/webmessaging/broadcastchannel/cross-partition.https.tentative-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This is a testharness.js-based test. | ||
PASS BroadcastChannel messages aren't received from a cross-partition iframe | ||
Harness: the test ran to completion. | ||
|