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
78 lines
2.3 KiB
HTML
78 lines
2.3 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=944821
|
|
-->
|
|
<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=944821">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(), "compilation is available");
|
|
|
|
// generate four slightly different big asm.js modules and compile them async
|
|
// so that we can hit the asm.js cache.
|
|
|
|
var code = "function f() { 'use asm';\n";
|
|
for (var i = 0; i < 5000; i++)
|
|
code += "function g" + i + "() { return " + i + "}\n";
|
|
ok(code.length > 100000, "code is long enough to definitely hit the cache");
|
|
|
|
const N = 4;
|
|
|
|
var codes = [];
|
|
for (var i = 0; i < N; i++) {
|
|
var code2 = code;
|
|
code2 += "return g" + i + ";\n";
|
|
code2 += "}\n";
|
|
code2 += "ok(jsFuns.isAsmJSModule(f), 'f is an asm.js module')\n";
|
|
code2 += "if (assertCacheHit) ok(jsFuns.isAsmJSModuleLoadedFromCache(f), 'cache hit');\n";
|
|
code2 += "var gX = f();\n";
|
|
code2 += "ok(jsFuns.isAsmJSFunction(gX), 'gX is an asm.js function')\n";
|
|
code2 += "ok(gX() === " + i + ", 'gX returns the correct result')\n";
|
|
code2 += "finishedEvalAsync();\n";
|
|
codes.push(code2);
|
|
}
|
|
|
|
function evalAsync(code) {
|
|
var blob = new Blob([code], {type:"application/javascript"});
|
|
var script = document.createElement('script');
|
|
script.src = URL.createObjectURL(blob);
|
|
document.body.appendChild(script);
|
|
}
|
|
|
|
for (var i = 0; i < N; i++)
|
|
evalAsync(codes[i]);
|
|
|
|
var finishedCount = 0;
|
|
var assertCacheHit = false;
|
|
function finishedEvalAsync() {
|
|
finishedCount++;
|
|
|
|
if (finishedCount < 1 || finishedCount > 2*N) {
|
|
throw "Huh?!";
|
|
} else if (finishedCount == N) {
|
|
assertCacheHit = true;
|
|
for (var i = 0; i < N; i++)
|
|
evalAsync(codes[i]);
|
|
} else if (finishedCount == 2*N) {
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|