mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
90c4cc3118
--HG-- extra : rebase_source : aa831d41e1b04062e208d5c36697da1f5e1c7d07
68 lines
2.2 KiB
HTML
68 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=941830
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>asm.js browser tests</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=941830">asm.js browser tests</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test"></pre>
|
|
|
|
<script>
|
|
var jsFuns = SpecialPowers.Cu.getJSTestingFunctions();
|
|
ok(jsFuns.isAsmJSCompilationAvailable());
|
|
|
|
var asmjsCode = "function f() { 'use asm';";
|
|
for (var i = 0; i < 5000; i++)
|
|
asmjsCode += "function g" + i + "() { return " + i + "}";
|
|
asmjsCode += "return g42 }";
|
|
ok(asmjsCode.length > 100000, "code is long enough to definitely hit the cache");
|
|
|
|
var workerCode = asmjsCode;
|
|
workerCode += "if (f()() !== 42) postMessage('fail'); else postMessage('ok');";
|
|
workerCode = 'var code = "' + workerCode + '"; eval(code); eval(code)';
|
|
var workerBlob = new Blob([workerCode], {type:"application/javascript"});
|
|
|
|
var mainCode = asmjsCode;
|
|
mainCode += "ok(jsFuns.isAsmJSModuleLoadedFromCache(f), 'f is a cache hit')\n";
|
|
mainCode += "var g42 = f();\n";
|
|
mainCode += "ok(jsFuns.isAsmJSFunction(g42), 'g42 is an asm.js function');\n";
|
|
mainCode += "ok(g42() === 42, 'g42 returns the correct result');\n";
|
|
mainCode += "SimpleTest.finish();\n";
|
|
var mainBlob = new Blob([mainCode], {type:"application/javascript"});
|
|
|
|
var w = new Worker(URL.createObjectURL(workerBlob));
|
|
|
|
var received = 0;
|
|
w.onmessage = function(e) {
|
|
switch (received) {
|
|
case 0:
|
|
ok(e.data === "ok", "Received first message");
|
|
received = 1;
|
|
break;
|
|
case 1:
|
|
ok(e.data === "ok", "Received second message");
|
|
received = 2;
|
|
|
|
var script = document.createElement('script');
|
|
script.src = URL.createObjectURL(mainBlob);
|
|
document.body.appendChild(script);
|
|
break;
|
|
default:
|
|
throw "Huh?";
|
|
}
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|