Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=929236
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>asm.js browser tests</title>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=929236">asm.js browser tests</a>
14 <p id="display"></p>
15 <div id="content" style="display: none"></div>
16 <pre id="test"></pre>
18 <script>
19 var jsFuns = SpecialPowers.Cu.getJSTestingFunctions();
20 ok(jsFuns.isAsmJSCompilationAvailable(), "asm.js compilation is available");
22 // generate a big ol asm.js module and compile it async so that we can hit
23 // the asm.js cache.
25 var code = "function f() { 'use asm';\n";
26 for (var i = 0; i < 5000; i++)
27 code += "function g" + i + "() { return " + i + "}\n";
28 code += "return g42 }\n";
29 code += "ok(jsFuns.isAsmJSModule(f), 'f is an asm.js module')\n";
30 code += "var g42 = f();\n";
31 code += "ok(jsFuns.isAsmJSFunction(g42), 'g42 is an asm.js function')\n";
32 code += "ok(g42() === 42, 'g42 returns the correct result')\n";
33 code += "finishedEvalAsync(f);";
34 ok(code.length > 100000, "code is long enough to definitely hit the cache");
36 function evalAsync(code) {
37 var blob = new Blob([code], {type:"application/javascript"});
38 var script = document.createElement('script');
39 script.src = URL.createObjectURL(blob);
40 document.body.appendChild(script);
41 }
43 var state = 0;
44 function finishedEvalAsync(module) {
45 switch (state) {
46 case 0:
47 state++;
48 evalAsync(code);
49 break;
50 case 1:
51 ok(jsFuns.isAsmJSModuleLoadedFromCache(module), 'module loaded from cache');
52 SimpleTest.finish();
53 break;
54 default:
55 throw "huh?";
56 }
57 }
59 SimpleTest.waitForExplicitFinish();
60 evalAsync(code);
61 </script>
63 </body>
64 </html>