identity-not-preserved.html (1899B)
1 <!DOCTYPE html> 2 <!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ --> 3 <meta charset="utf-8"> 4 <title>WebAssembly.Modules, when cloned, do not give back the same object</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="./resources/test-incrementer.js"></script> 8 9 <div id="log"></div> 10 11 <script> 12 "use strict"; 13 14 async_test(t => { 15 createWasmModule().then(module => { 16 window.addEventListener("message", t.step_func(({ data }) => { 17 if (data.testId !== 1) { 18 return; 19 } 20 21 assert_not_equals(data.module, module); 22 23 t.done(); 24 })); 25 26 window.postMessage({ module, testId: 1 }, "*"); 27 }); 28 }, "postMessaging to this window does not give back the same WebAssembly.Module"); 29 30 async_test(t => { 31 createWasmModule().then(module => { 32 const worker = new Worker("resources/echo-worker.js"); 33 34 worker.addEventListener("message", t.step_func(({ data }) => { 35 if (data.testId !== 2) { 36 return; 37 } 38 39 assert_not_equals(data.module, module); 40 t.done(); 41 })); 42 43 worker.postMessage({ testId: 2, module }); 44 }); 45 }, "postMessaging to a worker and back does not give back the same WebAssembly.Module"); 46 47 async_test(t => { 48 createWasmModule().then(module => { 49 window.addEventListener("message", t.step_func(({ data }) => { 50 if (data.testId !== 3) { 51 return; 52 } 53 54 assert_not_equals(data.module, module); 55 t.done(); 56 })); 57 58 const iframe = document.createElement("iframe"); 59 iframe.onload = t.step_func(() => { 60 iframe.contentWindow.postMessage({ testId: 3, module }, "*"); 61 }); 62 iframe.src = "resources/echo-iframe.html"; 63 document.body.appendChild(iframe); 64 }); 65 }, "postMessaging to an iframe and back does not give back the same WebAssembly.Module"); 66 </script>