broadcastchannel-iframe.html (537B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>A test page that uses a given WebAssembly.Module sent from a BroadcastChannel</title> 4 5 <script> 6 "use strict"; 7 const channel = new BroadcastChannel("channel name"); 8 9 channel.onmessage = ({ data: { module, i }, source }) => { 10 if (!module) { 11 // We only care about "broadcasts" from the window 12 return; 13 } 14 15 let instance = new WebAssembly.Instance(module); 16 let increment = instance.exports["increment"]; 17 let result = increment(i); 18 channel.postMessage({i, result}); 19 }; 20 </script>