blob: 746ffa2b395743bafdebf125815ea9f14c4d63de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
</body>
<script>
// This page is reused with a different query parameter indicating which
// handler to register and activate a portal from.
const handler_name = window.location.search.substring(1);
const portal_element = document.createElement('portal');
portal_element.src = 'simple-portal.html';
document.body.appendChild(portal_element);
let page_loaded = false;
let portal_loaded = false;
function notifyReady() {
if (page_loaded && portal_loaded) {
window.opener.postMessage('done', '*');
}
}
portal_element.addEventListener('load', () => {
portal_loaded = true;
notifyReady();
});
window.addEventListener('load', () => {
page_loaded = true;
notifyReady();
});
// This will be used to let the parent page know the handler has run and
// |portal_promise| is now valid.
window.opener.handler_called_promise = new Promise((resolve) => {
window.addEventListener(handler_name, () => {
window.opener.portal_promise = portal_element.activate();
// Let the parent page know it can now look at |portal_promise|.
resolve();
}, {once: true});
});
</script>
</html>
|