cross-origin-module-sharing-fails.html (1560B)
1 <title>Postmessage of a WebAssembly.Module cross-origin fails with a messageerror</title> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/get-host-info.sub.js"></script> 5 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> 6 <script src="resources/test-incrementer.js"></script> 7 8 <body> 9 <script> 10 async function testPostMessageErrorForOrigin(t, remoteOrigin){ 11 const iframe = document.createElement('iframe'); 12 iframe.src = `${remoteOrigin}${base_path()}resources/incrementer-iframe-failure.html`; 13 const iframeLoaded = new Promise(resolve => iframe.onload = resolve); 14 document.body.appendChild(iframe); 15 t.add_cleanup(() => { 16 iframe.remove(); 17 }); 18 await iframeLoaded; 19 20 const module = await createWasmModule(); 21 const messageErrorReceived = 22 new Promise(resolve => window.onmessage = resolve); 23 iframe.contentWindow.postMessage({message: 'send module', module}, "*"); 24 let reply = await messageErrorReceived; 25 assert_equals('messageerror received', reply.data); 26 } 27 28 promise_test(async t => { 29 const remoteOrigin = get_host_info().OTHER_ORIGIN; 30 await testPostMessageErrorForOrigin(t, remoteOrigin); 31 }, "postMessaging a wasm module to an iframe in a different agent cluster fails"); 32 33 promise_test(async t => { 34 const remoteOrigin = get_host_info().HTTPS_ORIGIN; 35 await testPostMessageErrorForOrigin(t, remoteOrigin); 36 }, "postMessaging a wasm module to a cross-origin iframe in the same agent cluster fails"); 37 </script> 38 </body>