Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / workers / test / test_fibonacci.html
blobc3e3e985740337a1508fd8766954037ce884dc9f
1 <!--
2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
4 -->
5 <!DOCTYPE HTML>
6 <html>
7 <!--
8 Tests of DOM Worker Threads with Fibonacci
9 -->
10 <head>
11 <title>Test for DOM Worker Threads with Fibonacci</title>
12 <script src="/tests/SimpleTest/SimpleTest.js"></script>
13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
14 </head>
15 <body>
16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450452">DOM Worker Threads Fibonacci</a>
17 <p id="display"></p>
18 <div id="content" style="display: none">
20 </div>
21 <pre id="test">
22 <script class="testbody" type="text/javascript">
24 const seqNum = 5;
26 function recursivefib(n) {
27 return n < 2 ? n : recursivefib(n - 1) + recursivefib(n - 2);
30 var worker = new Worker("fibonacci_worker.js");
32 worker.onmessage = function(event) {
33 is(event.target, worker);
34 is(event.data, recursivefib(seqNum));
35 SimpleTest.finish();
38 worker.onerror = function(event) {
39 is(event.target, worker);
40 ok(false, "Worker had an error: " + event.message);
41 SimpleTest.finish();
44 worker.postMessage(seqNum);
46 SimpleTest.waitForExplicitFinish();
48 </script>
49 </pre>
50 </body>
51 </html>