mirror of
https://github.com/servo/servo.git
synced 2025-09-01 10:38:25 +01:00
Update web-platform-tests to revision a589fd30bc64bb4d40e1d6854e07accca69b8472
This commit is contained in:
parent
81ab255b70
commit
fd4e600639
57 changed files with 1735 additions and 208 deletions
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
let channelIndex = 0;
|
||||
async function openPortalAndReceiveMessage(portalSrc) {
|
||||
let channelName = `portals-host-exposure-${channelIndex++}`
|
||||
let broadcastChannel = new BroadcastChannel(channelName);
|
||||
try {
|
||||
let received = new Promise((resolve, reject) => {
|
||||
broadcastChannel.addEventListener('message', e => {
|
||||
resolve(e.data);
|
||||
}, {once: true})
|
||||
});
|
||||
let portal = document.createElement('portal');
|
||||
portal.src = `${portalSrc}?broadcastchannel=${channelName}`;
|
||||
document.body.appendChild(portal);
|
||||
return await received;
|
||||
} finally {
|
||||
broadcastChannel.close();
|
||||
}
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
let {hasHost} = await openPortalAndReceiveMessage(
|
||||
'resources/portal-host.html');
|
||||
assert_true(hasHost, "window.portalHost should be defined");
|
||||
}, "window.portalHost should be exposed in same-origin portal");
|
||||
|
||||
promise_test(async t => {
|
||||
let {hasHost} = await openPortalAndReceiveMessage(
|
||||
'http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/portal-host-cross-origin.sub.html');
|
||||
assert_true(hasHost, "window.portalHost should be defined");
|
||||
}, "window.portalHost should be exposed in cross-origin portal");
|
||||
|
||||
promise_test(async t => {
|
||||
let {hasHost} = await openPortalAndReceiveMessage(
|
||||
'resources/portal-host-cross-origin-navigate.sub.html');
|
||||
assert_true(hasHost, "window.portalHost should be defined");
|
||||
}, "window.portalHost should be exposed in portal after cross-origin navigation");
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script>
|
||||
function forwardMessage(e) {
|
||||
let broadcastChannel = new BroadcastChannel(new URL(location).searchParams.get('broadcastchannel'));
|
||||
try {
|
||||
broadcastChannel.postMessage(e.data);
|
||||
} finally {
|
||||
broadcastChannel.close();
|
||||
}
|
||||
}
|
||||
window.addEventListener("message", forwardMessage);
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script>
|
||||
let channelName = new URL(location).searchParams.get('broadcastchannel');
|
||||
window.location.href = `http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/portal-host-cross-origin.sub.html?broadcastchannel=${channelName}`;
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script>
|
||||
let message = {
|
||||
hasHost: !!window.portalHost
|
||||
};
|
||||
let forwardingIframe = document.createElement('iframe');
|
||||
let channelName = new URL(location).searchParams.get('broadcastchannel');
|
||||
forwardingIframe.src = `http://{{host}}:{{ports[http][0]}}/portals/resources/portal-forward-with-broadcast.sub.html?broadcastchannel=${channelName}`;
|
||||
forwardingIframe.onload = () => {
|
||||
forwardingIframe.contentWindow.postMessage(message, '*');
|
||||
}
|
||||
document.body.appendChild(forwardingIframe);
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script>
|
||||
let message = {
|
||||
hasHost: !!window.portalHost
|
||||
};
|
||||
let broadcastChannel = new BroadcastChannel(new URL(location).searchParams.get('broadcastchannel'));
|
||||
try {
|
||||
broadcastChannel.postMessage(message);
|
||||
} finally {
|
||||
broadcastChannel.close();
|
||||
}
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue