Update web-platform-tests to revision ea3cae9746c39e8192b91181044144c60d9388e8

This commit is contained in:
WPT Sync Bot 2019-03-12 21:33:06 -04:00
parent 9513544e91
commit b3f94b4330
194 changed files with 22476 additions and 15435 deletions

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<title>Tests passing of data along with portal activation</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function nextMessage(target) {
return new Promise((resolve, reject) => {
target.addEventListener('message', e => resolve(e), {once: true});
});
}
async function openPortalAndActivate(logic, activateOptions) {
const bc = new BroadcastChannel('portal-activate-data');
const w = window.open();
try {
const portal = w.document.createElement('portal');
portal.src = new URL('resources/portal-activate-data-portal.html?logic=' + encodeURIComponent(logic), location.href);
w.document.body.appendChild(portal);
assert_equals((await nextMessage(bc)).data, 'ready');
await portal.activate(activateOptions);
return (await nextMessage(bc)).data;
} finally {
w.close();
bc.close();
}
}
promise_test(async () => {
const {echo} = await openPortalAndActivate(
'return {echo: event.data}',
{data: 'banana'});
assert_equals(echo, 'banana');
}, "A string can be passed through activate data.");
promise_test(async () => {
let {port1, port2} = new MessageChannel();
let replyViaPort = nextMessage(port1);
port1.start();
let ok = await openPortalAndActivate(
'let port2 = event.data; port2.postMessage(42); return true;',
{data: port2, transfer: [port2]});
assert_true(ok);
assert_equals((await replyViaPort).data, 42);
}, "A message port can be passed through activate data.");
if (window.SharedArrayBuffer) {
promise_test(async t => {
await promise_rejects(
t, 'DataCloneError',
openPortalAndActivate('', {data: new SharedArrayBuffer}));
}, "A SharedArrayBuffer cannot be passed through activate data.");
}
promise_test(async t => {
await promise_rejects(
t, new Error,
openPortalAndActivate('', {data: {get a() { throw new Error; }}}));
}, "Uncloneable data has its exception propagated.");
promise_test(async t => {
await promise_rejects(
t, new TypeError,
openPortalAndActivate('', {data: null, transfer: [null]}));
}, "Errors during transfer list processing are propagated.");
</script>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
promise_test(() => {
var portal = document.createElement("portal");
portal.src = "resources/portals-nested-1.html";
document.body.appendChild(portal);
var waitForMessage = new Promise((resolve, reject) => {
var bc = new BroadcastChannel("portals-nested");
bc.onmessage = () => {
bc.close();
resolve();
}
});
return waitForMessage;
}, "nested portals shouldn't crash");
</script>
</body>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<script>
const bc = new BroadcastChannel('portal-activate-data');
let logic = new Function('event', (new URL(location)).searchParams.get('logic'));
onload = () => bc.postMessage('ready');
onportalactivate = event => {
try {
bc.postMessage(logic(event));
} finally {
bc.close();
}
};
</script>

View file

@ -0,0 +1,4 @@
<!DOCTYPE html>
<body>
<portal src="portals-nested-2.html"></portal>
</body>

View file

@ -0,0 +1,6 @@
<!DOCTYPE html>
<script>
var bc = new BroadcastChannel("portals-nested");
bc.postMessage("loaded");
bc.close();
</script>