-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1535859 [wpt PR 15791] - Portals: Support adoption of the predece…
…ssor., a=testonly Automatic update from web-platform-tests Portals: Support adoption of the predecessor. This CL adds support for an activated portal to adopt its predecessor as a portal. Adopting the predecessor enables developers to quickly transition back and forth between different pages. Bug: 914122 Change-Id: I80381017ddb774da20ae07efcba2f4fee733fc3c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1456869 Commit-Queue: Lucas Gadani <lfg@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/master@{#643463} -- wpt-commits: 86f34ae4673f01d22b3bf328a451632882d421eb wpt-pr: 15791
- Loading branch information
1 parent
0623bcc
commit 3a3391d
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
testing/web-platform/tests/portals/portals-adopt-predecessor.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,14 @@ | ||
<!DOCTYPE html> | ||
<title>Tests that a portal can adopt its predecessor</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
async_test(function(t) { | ||
var bc = new BroadcastChannel("portal-test"); | ||
bc.onmessage = t.step_func_done(function(e) { | ||
assert_equals(e.data, "passed"); | ||
bc.close(); | ||
}); | ||
window.open("resources/portals-adopt-predecessor.html"); | ||
}, "Tests that a portal can adopt its predecessor."); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
testing/web-platform/tests/portals/resources/portals-adopt-predecessor-portal.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,17 @@ | ||
<!doctype html> | ||
<script> | ||
window.onportalactivate = function(e) { | ||
var portal = e.adoptPredecessor(); | ||
document.body.appendChild(portal); | ||
|
||
if (portal instanceof HTMLPortalElement) { | ||
var bc_adopted = new BroadcastChannel("portal-adopted"); | ||
bc_adopted.postMessage("adopted"); | ||
bc_adopted.close(); | ||
} | ||
} | ||
|
||
var bc_loaded = new BroadcastChannel("portal-loaded"); | ||
bc_loaded.postMessage("loaded"); | ||
bc_loaded.close(); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
testing/web-platform/tests/portals/resources/portals-adopt-predecessor.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,20 @@ | ||
<!doctype html> | ||
<body> | ||
<portal src="portals-adopt-predecessor-portal.html"></portal> | ||
</body> | ||
<script> | ||
var bc_loaded = new BroadcastChannel("portal-loaded"); | ||
bc_loaded.onmessage = function(e) { | ||
document.querySelector("portal").activate(); | ||
bc_loaded.close(); | ||
|
||
var bc_adopted = new BroadcastChannel("portal-adopted"); | ||
bc_adopted.onmessage = function(e) { | ||
bc_adopted.close(); | ||
|
||
var bc_test = new BroadcastChannel("portal-test"); | ||
bc_test.postMessage("passed"); | ||
bc_test.close(); | ||
} | ||
} | ||
</script> |