-
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: Add a WindowEventHandler to the PortalActivateEvent.
Bug: 914122 Change-Id: Ie1817a21216d86f59a708accea43e1d1ef316d6c Reviewed-on: https://chromium-review.googlesource.com/c/1412794 Commit-Queue: Lucas Gadani <[email protected]> Reviewed-by: Jeremy Roman <[email protected]> Cr-Commit-Position: refs/heads/master@{#623445}
- Loading branch information
1 parent
584bdfa
commit 2ade7dc
Showing
3 changed files
with
45 additions
and
11 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
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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
<!DOCTYPE html> | ||
<title>Tests that the PortalActivateEvent is dispatched when a portal is activated</title> | ||
<script> | ||
window.addEventListener("portalactivate", function(e) { | ||
var bc = new BroadcastChannel("test"); | ||
var test = (new URL(location)).searchParams.get("test"); | ||
|
||
function portalActivate(e) { | ||
var bc = new BroadcastChannel("test-" + test); | ||
bc.postMessage("passed"); | ||
bc.close(); | ||
}); | ||
} | ||
|
||
if (test == "bodyeventhandler") { | ||
document.write('<body onportalactivate="portalActivate()"></body>'); | ||
} else if (test == "eventhandler") { | ||
window.onportalactivate = portalActivate; | ||
} else if (test == "eventlistener") { | ||
window.addEventListener("portalactivate", portalActivate); | ||
} | ||
|
||
var bc = new BroadcastChannel("portal"); | ||
var bc = new BroadcastChannel("portal-" + test); | ||
bc.postMessage("loaded"); | ||
bc.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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
var bc = new BroadcastChannel("portal"); | ||
bc.onmessage = function(e) { | ||
document.querySelector("portal").activate(); | ||
bc.close(); | ||
window.onload = function(e) { | ||
var test = (new URL(location)).searchParams.get("test"); | ||
var portal = document.createElement("portal"); | ||
portal.src = "portal-activate-event-portal.html" + location.search; | ||
document.body.appendChild(portal); | ||
|
||
var bc = new BroadcastChannel("portal-" + test); | ||
bc.onmessage = function(e) { | ||
document.querySelector("portal").activate(); | ||
bc.close(); | ||
} | ||
} | ||
</script> | ||
<body> | ||
<portal src="portal-activate-event-portal.html"></portal> | ||
</body> |