Update web-platform-tests to revision 2b7dace05fc1869398ee24f84fda4c0e4c0455ae

This commit is contained in:
WPT Sync Bot 2018-08-31 21:37:12 +00:00 committed by Tom Servo
parent b23125d590
commit 6c901de216
844 changed files with 19802 additions and 3093 deletions

View file

@ -0,0 +1,38 @@
<!doctype html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<title>WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<script>
async_test(t => {
const channel = new BroadcastChannel("anne was here"),
dw = new Worker("resources/broadcastchannel-worker.js"),
sw = new SharedWorker("resources/broadcastchannel-sharedworker.js");
let startCounter = 0,
dwStatus = "unknown",
swStatus = "unknown";
channel.onmessage = t.step_func(({ data }) => {
if(data === "hi") {
startCounter++;
if(startCounter === 2) {
createWasmModule().then(module => {
channel.postMessage(module);
});
} else if(startCounter > 2) {
assert_unreached();
}
} else if(data === "dw-success") {
dwStatus = "success";
} else if(data === "sw-success") {
swStatus = "success";
} else {
assert_unreached();
}
if(dwStatus === "success" && swStatus === "success") {
t.done();
}
});
});
</script>

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>Structured cloning of WebAssembly.Module: BroadcastChannel within the same agent cluster</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
promise_test(t => {
return createWasmModule().then(module => {
let loadedIframes = 0;
return Promise.all([
createIFrame("resources/broadcastchannel-iframe.html"),
createIFrame("resources/broadcastchannel-iframe.html"),
createIFrame("resources/broadcastchannel-iframe.html")
]).then(() => {
const thisIframe = loadedIframes++;
const channel = new BroadcastChannel("channel name");
return new Promise(resolve => {
let soFar = 0;
channel.onmessage = t.step_func(msg => {
if (msg.module) {
// We only care about "broadcasts" from the workers.
return;
}
let {i, result} = msg;
assert_in_array(i, [0, 1, 2], "Any message events must come from expected sources");
assert_equals(result, i + 1, `iframe ${i} must return ${i+1}`);
++soFar;
if (soFar === 3) {
resolve();
}
});
channel.postMessage({ module, i: thisIframe });
});
});
});
});
function createIFrame(src) {
return new Promise((resolve, reject) => {
const iframe = document.createElement("iframe");
iframe.src = src;
iframe.onload = () => resolve(iframe);
iframe.onerror = () => reject(`iframe with URL ${src} failed to load`);
document.body.appendChild(iframe);
});
}
</script>

View file

@ -0,0 +1,66 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>WebAssembly.Modules, when cloned, do not give back the same object</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
async_test(t => {
createWasmModule().then(module => {
window.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 1) {
return;
}
assert_not_equals(data.module, module);
t.done();
}));
window.postMessage({ module, testId: 1 }, "*");
});
}, "postMessaging to this window does not give back the same WebAssembly.Module");
async_test(t => {
createWasmModule().then(module => {
const worker = new Worker("resources/echo-worker.js");
worker.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 2) {
return;
}
assert_not_equals(data.module, module);
t.done();
}));
worker.postMessage({ testId: 2, module });
});
}, "postMessaging to a worker and back does not give back the same WebAssembly.Module");
async_test(t => {
createWasmModule().then(module => {
window.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 3) {
return;
}
assert_not_equals(data.module, module);
t.done();
}));
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
iframe.contentWindow.postMessage({ testId: 3, module }, "*");
});
iframe.src = "resources/echo-iframe.html";
document.body.appendChild(iframe);
});
}, "postMessaging to an iframe and back does not give back the same WebAssembly.Module");
</script>

View file

@ -0,0 +1,9 @@
// META: global=!default,dedicatedworker,sharedworker
// META: script=resources/test-incrementer.js
"use strict";
promise_test(t => {
const worker = new Worker("resources/incrementer-worker.js");
return testSharingViaIncrementerScript(t, worker, "parent worker", worker, "sub-worker");
}, "postMessaging to a dedicated sub-worker allows them to see each others' modifications");

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>WebAssembly.Modules cannot be transferred</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/create-empty-wasm-module.js"></script>
<script>
"use strict";
test(() => {
const module = createEmptyWasmModule();
assert_throws("DataCloneError", () => window.postMessage(module, "*", [module]));
assert_throws("DataCloneError", () => window.postMessage("test", "*", [module]));
}, "Trying to transfer a WebAssembly.Module to this window throws");
test(() => {
const module = createEmptyWasmModule();
const worker = new Worker("resources/echo-worker.js");
assert_throws("DataCloneError", () => worker.postMessage(module, [module]));
assert_throws("DataCloneError", () => worker.postMessage("test", [module]));
}, "Trying to transfer a WebAssembly.Module to a worker throws");
test(() => {
const module = createEmptyWasmModule();
const channel = new MessageChannel();
assert_throws("DataCloneError", () => channel.port1.postMessage(module, [module]));
assert_throws("DataCloneError", () => channel.port1.postMessage("test", [module]));
}, "Trying to transfer a WebAssembly.Module through a MessagePort throws");
</script>

View file

@ -0,0 +1,2 @@
<!DOCTYPE html>
<title>Empty doc</title>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that uses a given WebAssembly.Module sent from a BroadcastChannel</title>
<script>
"use strict";
const channel = new BroadcastChannel("channel name");
channel.onmessage = ({ data: { module, i }, source }) => {
if (!module) {
// We only care about "broadcasts" from the window
return;
}
let instance = new WebAssembly.Instance(module);
let increment = instance.exports["increment"];
let result = increment(i);
channel.postMessage({i, result});
};
</script>

View file

@ -0,0 +1,7 @@
const channel = new BroadcastChannel("anne was here");
channel.onmessageerror = ({ data }) => {
if(data === null) {
channel.postMessage("sw-success");
}
}
channel.postMessage("hi");

View file

@ -0,0 +1,9 @@
const channel = new BroadcastChannel("anne was here");
channel.onmessage = ({ data }) => {
if(data === "hi" || data === "sw-success") {
return;
} else if(data instanceof WebAssembly.Module) {
channel.postMessage("dw-success");
}
}
channel.postMessage("hi");

View file

@ -0,0 +1,4 @@
function createEmptyWasmModule() {
return new WebAssembly.Module(
new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]));
}

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that echos back anything postMessaged to it to its parent</title>
<script>
"use strict";
window.onmessage = ({ data }) => {
parent.postMessage(data, "*");
};
</script>

View file

@ -0,0 +1,5 @@
"use strict";
self.onmessage = ({ data }) => {
self.postMessage(data);
};

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that is sent a WebAssembly Module</title>
<script src="/resources/testharness.js"></script>
<script src="test-incrementer.js"></script>
<script>
"use strict";
document.domain = "{{host}}";
setupDestinationIncrementer(self, parent, "*");
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that is sent a WebAssembly Module</title>
<script src="/resources/testharness.js"></script>
<script src="test-incrementer.js"></script>
<script>
"use strict";
setupDestinationIncrementer(self, parent, "*");
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that is sent a WebAssembly Module</title>
<script src="/resources/testharness.js"></script>
<script src="test-incrementer.js"></script>
<script>
"use strict";
setupDestinationIncrementer(self, opener, "*");
</script>

View file

@ -0,0 +1,8 @@
"use strict";
importScripts("/resources/testharness.js");
importScripts("./test-incrementer.js");
self.onmessage = ({ data }) => {
// data will be a MessagePort
setupDestinationIncrementer(data, data);
};

View file

@ -0,0 +1,5 @@
"use strict";
importScripts("/resources/testharness.js");
importScripts("./test-incrementer.js");
setupDestinationIncrementer(self, self);

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nesting level 1</title>
<iframe src="nested-iframe-2.html"></iframe>

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nesting level 2</title>
<iframe src="nested-iframe-3.html"></iframe>

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nesting level 3</title>
<iframe src="nested-iframe-4-incrementer.html"></iframe>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that is sent a WebAssembly Module, nested 4 levels deep in iframes</title>
<script src="/resources/testharness.js"></script>
<script src="test-incrementer.js"></script>
<script>
"use strict";
setupDestinationIncrementer(self, parent.parent.parent.parent.parent, "*");
</script>

View file

@ -0,0 +1,34 @@
// Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/.
"use strict";
self.importScripts("/resources/testharness.js");
self.importScripts("./create-empty-wasm-module.js");
let state = "start in worker";
self.onmessage = e => {
if (e.data === "start in window") {
assert_equals(state, "start in worker");
e.source.postMessage(state);
state = "we are expecting a messageerror due to the window sending us a WebAssembly.Module";
} else if (e.data === "we are expecting a messageerror due to the worker sending us a WebAssembly.Module") {
assert_equals(state, "onmessageerror was received in worker");
e.source.postMessage(createEmptyWasmModule());
state = "done in worker";
} else {
e.source.postMessage(`worker onmessage was reached when in state "${state}" and data ${e.data}`);
}
};
self.onmessageerror = e => {
if (state === "we are expecting a messageerror due to the window sending us a WebAssembly.Module") {
assert_equals(e.data, null, "data");
assert_equals(e.origin, self.origin, "origin");
assert_not_equals(e.source, null, "source");
assert_equals(e.ports.length, 0, "ports length");
state = "onmessageerror was received in worker";
e.source.postMessage(state);
} else {
e.source.postMessage(`worker onmessageerror was reached when in state "${state}" and data ${e.data}`);
}
};

View file

@ -0,0 +1,21 @@
importScripts("./test-incrementer.js");
importScripts("./create-empty-wasm-module.js");
let state = "send-sw-failure"
onconnect = initialE => {
let port = initialE.source;
port.postMessage(state)
port.onmessage = e => {
if(state === "" && e.data === "send-window-failure") {
port.postMessage(createEmptyWasmModule())
} else {
port.postMessage("failure")
}
}
port.onmessageerror = e => {
if(state === "send-sw-failure") {
port.postMessage("send-sw-failure-success")
state = ""
}
}
}

View file

@ -0,0 +1,57 @@
// Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/.
//
// This file is simplified from the one there, because it only tests that the
// module can be passed and that functions can be run. The SharedArrayBuffer
// version also tests that the memory is shared between the agents.
"use strict";
function createWasmModule() {
return fetch('incrementer.wasm')
.then(response => {
if (!response.ok)
throw new Error(response.statusText);
return response.arrayBuffer();
})
.then(WebAssembly.compile);
}
function testModule(module) {
let instance = new WebAssembly.Instance(module);
let increment = instance.exports["increment"];
assert_equals(typeof increment, "function", `The type of the increment export should be "function", got ${typeof increment}`);
let result = increment(42);
assert_equals(result, 43, `increment(42) should be 43, got ${result}`);
}
self.testSharingViaIncrementerScript = (t, whereToListen, whereToListenLabel, whereToSend, whereToSendLabel, origin) => {
return createWasmModule().then(module => {
return new Promise(resolve => {
whereToListen.onmessage = t.step_func(({ data }) => {
switch (data.message) {
case "module received": {
testModule(data.module);
resolve();
break;
}
}
});
whereToSend.postMessage({ message: "send module", module }, origin);
});
});
};
self.setupDestinationIncrementer = (whereToListen, whereToSendBackTo, origin) => {
whereToListen.onmessage = ({ data }) => {
switch (data.message) {
case "send module": {
let module = data.module;
testModule(data.module);
whereToSendBackTo.postMessage({ message: "module received", module }, origin);
break;
}
}
};
};

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>WebAssembly.Module cloning via history's methods invoking StructuredSerializeForStorage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/create-empty-wasm-module.js"></script>
<script>
"use strict";
for (const method of ["pushState", "replaceState"]) {
test(() => {
assert_throws("DataCloneError", () => {
history[method](createEmptyWasmModule(), "dummy title");
});
}, `history.${method}(): simple case`);
test(() => {
let getter1Called = false;
let getter2Called = false;
assert_throws("DataCloneError", () => {
history[method]([
{ get x() { getter1Called = true; return 5; } },
createEmptyWasmModule(),
{ get x() { getter2Called = true; return 5; } }
], "dummy title");
});
assert_true(getter1Called, "The getter before the WebAssembly.Module must have been called");
assert_false(getter2Called, "The getter after the WebAssembly.Module must not have been called");
}, `history.${method}(): is interleaved correctly`);
}
</script>

View file

@ -0,0 +1,45 @@
// META: script=/IndexedDB/support.js
"use strict";
function createEmptyWasmModule() {
return new WebAssembly.Module(
new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]));
}
async_test(t => {
const openReq = createdb(t);
openReq.onupgradeneeded = e => {
const db = e.target.result;
const store = db.createObjectStore("store", { keyPath: "key" });
assert_throws("DataCloneError", () => {
store.put({ key: 1, property: createEmptyWasmModule() });
});
t.done();
};
}, "WebAssembly.Module cloning via IndexedDB: basic case");
async_test(t => {
const openReq = createdb(t);
openReq.onupgradeneeded = e => {
const db = e.target.result;
const store = db.createObjectStore("store", { keyPath: "key" });
let getter1Called = false;
let getter2Called = false;
assert_throws("DataCloneError", () => {
store.put({ key: 1, property: [
{ get x() { getter1Called = true; return 5; } },
createEmptyWasmModule(),
{ get x() { getter2Called = true; return 5; } }
]});
});
assert_true(getter1Called, "The getter before the WebAssembly.Module must have been called");
assert_false(getter2Called, "The getter after the WebAssembly.Module must not have been called");
t.done();
};
}, "WebAssembly.Module cloning via the IndexedDB: is interleaved correctly");

View file

@ -0,0 +1,28 @@
"use strict";
function createEmptyWasmModule() {
return new WebAssembly.Module(
new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]));
}
test(() => {
assert_throws("DataCloneError", () => {
new Notification("Bob: Hi", { data: createEmptyWasmModule() });
})
}, "WebAssembly.Module cloning via the Notifications API's data member: basic case");
test(() => {
let getter1Called = false;
let getter2Called = false;
assert_throws("DataCloneError", () => {
new Notification("Bob: Hi", { data: [
{ get x() { getter1Called = true; return 5; } },
createEmptyWasmModule(),
{ get x() { getter2Called = true; return 5; } }
]});
});
assert_true(getter1Called, "The getter before the SAB must have been called");
assert_false(getter2Called, "The getter after the SAB must not have been called");
}, "WebAssembly.Module cloning via the Notifications API's data member: is interleaved correctly");

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>Structured cloning of WebAssembly.Module into same-origin-domain windows</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
document.domain = "{{host}}";
promise_test(t => {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
});
iframe.src = "//{{domains[www1]}}:{{location[port]}}/wasm/serialization/resources/incrementer-iframe-domain.sub.html";
document.body.appendChild(iframe);
});
}, "postMessaging to a same-origin-domain (but not same-origin) iframe allows them to instantiate");
</script>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>Structured cloning of WebAssembly.Module using MessageChannel</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
promise_test(t => {
const worker = new Worker("resources/incrementer-worker-with-channel.js");
const channel = new MessageChannel();
worker.postMessage(channel.port2, [channel.port2]);
return testSharingViaIncrementerScript(t, channel.port1, "window", channel.port1, "worker");
}, "postMessaging to a dedicated worker via MessageChannel allows them to instantiate");
</script>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<title>WebAssembly.Module cannot cross agent clusters, service worker edition</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
<script src="./resources/create-empty-wasm-module.js"></script>
<script>
"use strict";
promise_test(t => {
const scope = "resources/blank.html";
return service_worker_unregister_and_register(t, "resources/serviceworker-failure.js", scope).then(reg => {
return wait_for_state(t, reg.installing, "activated");
})
.then(() => {
return with_iframe(scope);
}).then(iframe => {
const sw = iframe.contentWindow.navigator.serviceWorker;
let state = "start in window";
return new Promise(resolve => {
sw.onmessage = t.step_func(e => {
if (e.data === "start in worker") {
assert_equals(state, "start in window");
sw.controller.postMessage(createEmptyWasmModule());
state = "we are expecting confirmation of an onmessageerror in the worker";
} else if (e.data === "onmessageerror was received in worker") {
assert_equals(state, "we are expecting confirmation of an onmessageerror in the worker");
state = "we are expecting a messageerror due to the worker sending us a WebAssembly.Module";
sw.controller.postMessage(state);
} else {
assert_unreached("Got an unexpected message from the service worker: " + e.data);
}
});
sw.onmessageerror = t.step_func(e => {
assert_equals(state, "we are expecting a messageerror due to the worker sending us a WebAssembly.Module");
assert_equals(e.data, null, "data");
assert_equals(e.origin, self.origin, "origin");
assert_equals(e.source, null, "source");
assert_equals(e.ports.length, 0, "ports length");
state = "done in window";
resolve();
});
sw.controller.postMessage(state);
});
});
});
</script>

View file

@ -0,0 +1,33 @@
<!doctype html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<title>WebAssembly.Modules cannot cross agent clusters, shared worker edition</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/create-empty-wasm-module.js"></script>
<script>
async_test(t => {
const sw = new SharedWorker("resources/sharedworker-failure.js")
let state = ""
sw.port.onmessage = t.step_func(e => {
if(e.data === "send-sw-failure") {
sw.port.postMessage(createEmptyWasmModule())
} else if(e.data === "send-sw-failure-success") {
state = "send-window-failure"
sw.port.postMessage(state)
} else {
assert_unreached()
}
})
sw.port.onmessageerror = t.step_func(e => {
if(state === "send-window-failure") {
assert_equals(e.data, null, "data")
assert_equals(e.origin, "", "origin")
assert_equals(e.source, null, "source")
assert_equals(e.ports.length, 0, "ports length")
t.done()
} else {
assert_unreached()
}
})
})
</script>

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>Structured cloning of WebAssembly.Module to similar-origin, but not same-origin, windows</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
document.domain = "{{host}}";
promise_test(t => {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
});
iframe.src = "//{{domains[www1]}}:{{location[port]}}/wasm/serialization/resources/incrementer-iframe.html";
document.body.appendChild(iframe);
});
}, "postMessaging to a not same-origin-domain, but similar origin, iframe allows them to instantiate");
</script>

View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
<meta charset="utf-8">
<title>Structured cloning of WebAssembly.Module: simple success cases that don't need dedicated files</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
promise_test(t => {
const worker = new Worker("resources/incrementer-worker.js");
return testSharingViaIncrementerScript(t, worker, "window", worker, "worker", undefined);
}, "postMessaging to a dedicated worker allows them to instantiate");
promise_test(t => {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
});
iframe.src = "resources/incrementer-iframe.html";
document.body.appendChild(iframe);
});
}, "postMessaging to a same-origin iframe allows them to instantiate");
promise_test(t => {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
const level1 = iframe.contentWindow;
const level2 = level1.frames[0];
const level3 = level2.frames[0];
const targetWindow = level3.frames[0];
resolve(testSharingViaIncrementerScript(t, window, "window", targetWindow, "nested iframe", "*"));
});
iframe.src = "resources/nested-iframe-1.html";
document.body.appendChild(iframe);
});
}, "postMessaging to a same-origin deeply-nested iframe allows them to instantiate");
promise_test(t => {
return new Promise(resolve => {
const w = window.open("resources/incrementer-popup.html");
w.onload = t.step_func(() => {
resolve(testSharingViaIncrementerScript(t, window, "window", w, "popup window", "*").then(() => {
w.close();
}));
});
});
}, "postMessaging to a same-origin opened window allows them to instantiate");
</script>