blob: cd3e99b9eca131316965262f84b22002e66b62cd (
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
|
<title>Postmessage of a WebAssembly.Module cross-origin fails with a messageerror</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
<script src="resources/test-incrementer.js"></script>
<body>
<script>
async function testPostMessageErrorForOrigin(t, remoteOrigin){
const iframe = document.createElement('iframe');
iframe.src = `${remoteOrigin}${base_path()}resources/incrementer-iframe-failure.html`;
const iframeLoaded = new Promise(resolve => iframe.onload = resolve);
document.body.appendChild(iframe);
t.add_cleanup(() => {
iframe.remove();
});
await iframeLoaded;
const module = await createWasmModule();
const messageErrorReceived =
new Promise(resolve => window.onmessage = resolve);
iframe.contentWindow.postMessage({message: 'send module', module}, "*");
let reply = await messageErrorReceived;
assert_equals('messageerror received', reply.data);
}
promise_test(async t => {
const remoteOrigin = get_host_info().OTHER_ORIGIN;
await testPostMessageErrorForOrigin(t, remoteOrigin);
}, "postMessaging a wasm module to an iframe in a different agent cluster fails");
promise_test(async t => {
const remoteOrigin = get_host_info().HTTPS_ORIGIN;
await testPostMessageErrorForOrigin(t, remoteOrigin);
}, "postMessaging a wasm module to a cross-origin iframe in the same agent cluster fails");
</script>
</body>
|