share-module-cross-origin-fails.sub.html (1171B)
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="./resources/test-incrementer.js"></script> 5 6 <body></body> 7 8 <script> 9 promise_test(async t => { 10 // Create an iframe. It will notify this document when the "messageerror" 11 // event is triggered. 12 const iframe = document.createElement("iframe"); 13 iframe.src = "//{{domains[www1]}}:{{location[port]}}" + 14 "/wasm/serialization/module/resources/incrementer-iframe-failure.html"; 15 16 // Instantiate and wait for the document to be loaded. 17 const iframeLoaded = new Promise(resolve => iframe.onload = resolve); 18 document.body.appendChild(iframe); 19 await iframeLoaded; 20 21 const module = await createWasmModule(); 22 const messageErrorReceived = new Promise(resolve => { 23 window.onmessage = ({data}) => { 24 if (data == 'messageerror received') 25 resolve(); 26 }; 27 }); 28 iframe.contentWindow.postMessage({message: 'send module', module}, "*"); 29 await messageErrorReceived; 30 }, "postMessaging a wasm module to a cross-origin iframe fails"); 31 </script>