-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Partitioned Popins] Implement
popinContextType()
JS API
This CL implements `window.popinContextType()` that tells whether a page is inside of a Partitioned Popin. Explainer: https://explainers-by-googlers.github.io/partitioned-popins/ I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/ApU_zUmpQ2g/ Low-Coverage-Reason: COVERAGE_UNDERREPORTED Tested through WPTs. Bug: 340606651 Bug: b/362973178 Change-Id: I053512217160d4875e7558be35eda3a3bbace833 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5826165 Reviewed-by: Ari Chivukula <[email protected]> Reviewed-by: Robert Kaplow <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Commit-Queue: Sandor «Alex» Major <[email protected]> Cr-Commit-Position: refs/heads/main@{#1350877}
- Loading branch information
1 parent
ab72b1d
commit a154121
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
partitioned-popins/popinContextType.in-popin.tentative.https.window.js
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,26 @@ | ||
// META: script=/resources/testdriver.js | ||
// META: script=/resources/testdriver-vendor.js | ||
|
||
'use strict'; | ||
|
||
// Spec: https://explainers-by-googlers.github.io/partitioned-popins/ | ||
// Step 1 (window) Set up listener to resolve messages as they come in. | ||
// Step 2 (window) Open popin. | ||
// Step 3 (popin) Call `window.popinContextType()` and send result to opener. | ||
// Step 4 (main-window) Assert and cleanup. | ||
|
||
async_test(t => { | ||
// Step 1 | ||
window.addEventListener("message", t.step_func(e => { | ||
switch (e.data.type) { | ||
case 'popin': | ||
// Step 4 | ||
assert_equals(e.data.message, "partitioned"); | ||
t.done(); | ||
break; | ||
} | ||
})); | ||
|
||
// Step 2 | ||
window.open("/partitioned-popins/resources/popinContextType.html", '_blank', 'popin'); | ||
}, "Verify PopinContextType is 'partitioned' in a Partitioned Popin"); |
12 changes: 12 additions & 0 deletions
12
partitioned-popins/popinContextType.tentative.https.window.js
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,12 @@ | ||
// META: script=/resources/testdriver.js | ||
// META: script=/resources/testdriver-vendor.js | ||
|
||
'use strict'; | ||
|
||
// Spec: https://explainers-by-googlers.github.io/partitioned-popins/ | ||
// Step 1 - Call `window.popinContextType()` and receive null. | ||
|
||
async_test(t => { | ||
assert_equals(window.popinContextType(), null); | ||
t.done(); | ||
}, "Verify PopinContextType is null on top-level page"); |
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,17 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script> | ||
(async function () { | ||
test_driver.set_test_context(window.opener); | ||
|
||
// Step 3 (partitioned-popins/popinContextType.in-popin.tentative.sub.https.window.js) | ||
let message = "popinContextType is not supported"; | ||
try { | ||
message = window.popinContextType(); | ||
} catch (_) { } | ||
window.opener.postMessage({ type: "popin", message: message }, "*"); | ||
window.close(); | ||
})(); | ||
</script> |