dom/workers/test/test_longThread.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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 (Bug 437152)
     9 -->
    10 <head>
    11   <title>Test for DOM Worker Threads (Bug 437152)</title>
    12   <script type="text/javascript" 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=437152">DOM Worker Threads Bug 437152</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 numThreads = 5;
    25   var doneThreads = 0;
    27   function onmessage(event) {
    28     switch (event.data) {
    29       case "done":
    30         if (++doneThreads == numThreads) {
    31           ok(true, "All messages received from workers");
    32           SimpleTest.finish();
    33         }
    34         break;
    35       default:
    36         ok(false, "Unexpected message");
    37         SimpleTest.finish();
    38     }
    39   }
    41   function onerror(event) {
    42     ok(false, "Worker had an error");
    43     SimpleTest.finish();
    44   }
    46   for (var i = 0; i < numThreads; i++) {
    47     var worker = new Worker("longThread_worker.js");
    48     worker.onmessage = onmessage;
    49     worker.onerror = onerror;
    50     worker.postMessage("start");
    51   }
    53   SimpleTest.waitForExplicitFinish();
    55 </script>
    56 </pre>
    57 </body>
    58 </html>

mercurial