toolkit/components/workerloader/tests/utils_mainthread.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.

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

mercurial