blob: e5f970d004ff169fad96a3bff0454ac951949b20 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test sending shared WebAssembly.Memory via postMessage to a worker.");
if (typeof WebAssembly !== 'undefined') {
jsTestIsAsync = true;
memory = new WebAssembly.Memory({ initial: 1, maximum: 2, shared: true });
buffer = memory.buffer;
view = new Uint8Array(buffer);
view[0] = 42;
shouldBe(`view[0]`, `42`);
worker = new Worker("./resources/webassembly-memory-shared-worker.js");
worker.onmessage = function(msg) {
message = msg;
shouldBe(`message.data`, `"DONE"`);
shouldBe(`view[0]`, `43`);
shouldBe(`view[1]`, `42`);
shouldBe(`view[2]`, `44`);
shouldBe(`buffer.byteLength`, `65536`);
shouldBe(`memory.buffer.byteLength`, `131072`);
finishJSTest();
};
worker.postMessage(memory);
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>