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