| <!DOCTYPE html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <body> |
| <script> |
| function openPortalAndReceiveMessage(portalSrc) { |
| assert_precondition("HTMLPortalElement" in self); |
| let portal = document.createElement('portal'); |
| portal.src = portalSrc; |
| let received = new Promise((resolve, reject) => { |
| portal.onmessage = resolve; |
| document.body.appendChild(portal); |
| }); |
| return received; |
| } |
| |
| promise_test(() => { |
| return openPortalAndReceiveMessage("resources/portal-host.html"); |
| }, "window.portalHost should be exposed in same-origin portal"); |
| |
| promise_test(() => { |
| return openPortalAndReceiveMessage( |
| "http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/portal-host.html"); |
| }, "window.portalHost should be exposed in cross-origin portal"); |
| |
| promise_test(() => { |
| return openPortalAndReceiveMessage( |
| 'resources/portal-host-cross-origin-navigate.sub.html'); |
| }, "window.portalHost should be exposed in portal after cross-origin navigation"); |
| |
| </script> |
| </body> |