-
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.
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}
- Loading branch information
1 parent
1cf5241
commit f13bccf
Showing
3 changed files
with
51 additions
and
0 deletions.
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
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> |
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> |
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> |