diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/asmjscache/test/test_cachingMulti.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/asmjscache/test/test_cachingMulti.html')
-rw-r--r-- | dom/asmjscache/test/test_cachingMulti.html | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/dom/asmjscache/test/test_cachingMulti.html b/dom/asmjscache/test/test_cachingMulti.html new file mode 100644 index 000000000..ca092fda0 --- /dev/null +++ b/dom/asmjscache/test/test_cachingMulti.html @@ -0,0 +1,85 @@ +<!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(); + + var assertCacheHit = false; + + // 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 disabled');\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); + } + + var finishedCount = 0; + 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(); + } + } + + function runTest() { + for (var i = 0; i < N; i++) + evalAsync(codes[i]); + + SimpleTest.waitForExplicitFinish(); + } + + if (!jsFuns.isAsmJSCompilationAvailable()) { + ok(true, "isAsmJSCompilationAvailable is false, skipping this test!"); + } else { + runTest(); + } + </script> + +</body> +</html> + |