toolkit/components/workerloader/tests/worker_handler.js

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 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function worker_handler(worker) {
     5   worker.onerror = function(error) {
     6     error.preventDefault();
     7     ok(false, "error "+error);
     8   }
     9   worker.onmessage = function(msg) {
    10     ok(true, "MAIN: onmessage " + JSON.stringify(msg.data));
    11     switch (msg.data.kind) {
    12     case "is":
    13       SimpleTest.ok(msg.data.outcome, msg.data.description +
    14          "( "+ msg.data.a + " ==? " + msg.data.b + ")" );
    15       return;
    16     case "isnot":
    17       SimpleTest.ok(msg.data.outcome, msg.data.description +
    18       "( "+ msg.data.a + " !=? " + msg.data.b + ")" );
    19          return;
    20     case "ok":
    21       SimpleTest.ok(msg.data.condition, msg.data.description);
    22       return;
    23     case "info":
    24       SimpleTest.info(msg.data.description);
    25       return;
    26     case "finish":
    27       SimpleTest.finish();
    28       return;
    29     default:
    30       SimpleTest.ok(false, "test_osfile.xul: wrong message " + JSON.stringify(msg.data));
    31       return;
    32     }
    33   };
    34 }

mercurial