7 document
.getElementById('console').appendChild(document
.createTextNode(message
+ "\n"));
12 log("Test calling asm functions across workers with the same heap.");
15 "onmessage = function(e) {",
16 " function Module(stdlib, foreign, heap) {",
18 " var MEM32 = new stdlib.Int32Array(heap);",
19 " function load() { var res = MEM32[255]; MEM32[255] = 123457; return res; }",
20 " return { load: load };",
22 " var buffer = e.data;",
23 " var result = Module(worker, {}, buffer).load();",
24 " var message = result == 123456 ? 'SUCCESS' : 'FAILURE ' + result;",
25 " postMessage(message);",
28 var blobURL
= URL
.createObjectURL(new Blob([string
]));
29 var worker
= new Worker(blobURL
);
30 function Module(stdlib
, foreign
, heap
) {
32 var MEM32
= new stdlib
.Int32Array(heap
);
33 function store() { MEM32
[255] = 123456; }
34 return { store
: store
};
36 var buffer
= new ArrayBuffer(4 * 256);
37 Module(this, {}, buffer
).store();
38 worker
.onmessage = function(event
) {
40 // This buffer may or may not have been neutered, ensure we don't write across threads.
41 for (var i
= 0; i
< 4 * 256; i
++) {
47 if (testRunner
.notifyDone
)
48 testRunner
.notifyDone();
50 worker
.postMessage(buffer
);
53 if (window
.testRunner
) {
54 testRunner
.setAllowUniversalAccessFromFileURLs(false);
55 testRunner
.setAllowFileAccessFromFileURLs(true);
56 testRunner
.dumpAsText();
57 testRunner
.waitUntilDone();
61 <body onload=
"runTest()">
62 <pre id='console'
></pre>