mirror of
https://github.com/servo/servo.git
synced 2025-10-15 16:00:28 +01:00
24 lines
590 B
HTML
24 lines
590 B
HTML
<!DOCTYPE html>
|
|
<body>
|
|
<script>
|
|
function handleMessage(e) {
|
|
if (e.data == "focus") {
|
|
let button = document.querySelector("button");
|
|
button.onfocus = () => e.source.postMessage({focused: true}, "*");
|
|
button.focus();
|
|
}
|
|
}
|
|
|
|
if (window.portalHost)
|
|
window.portalHost.onmessage = handleMessage;
|
|
|
|
window.onmessage = handleMessage;
|
|
|
|
window.onportalactivate = e => {
|
|
let portal = e.adoptPredecessor();
|
|
document.body.appendChild(portal);
|
|
portal.onmessage = handleMessage;
|
|
}
|
|
</script>
|
|
<button>A</button>
|
|
</body>
|