1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/workerloader/tests/utils_mainthread.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,34 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function worker_handler(worker) { 1.8 + worker.onerror = function(error) { 1.9 + error.preventDefault(); 1.10 + ok(false, "error "+ error.message); 1.11 + }; 1.12 + worker.onmessage = function(msg) { 1.13 +// ok(true, "MAIN: onmessage " + JSON.stringify(msg.data)); 1.14 + switch (msg.data.kind) { 1.15 + case "is": 1.16 + SimpleTest.ok(msg.data.outcome, msg.data.description + 1.17 + "( "+ msg.data.a + " ==? " + msg.data.b + ")" ); 1.18 + return; 1.19 + case "isnot": 1.20 + SimpleTest.ok(msg.data.outcome, msg.data.description + 1.21 + "( "+ msg.data.a + " !=? " + msg.data.b + ")" ); 1.22 + return; 1.23 + case "ok": 1.24 + SimpleTest.ok(msg.data.condition, msg.data.description); 1.25 + return; 1.26 + case "info": 1.27 + SimpleTest.info(msg.data.description); 1.28 + return; 1.29 + case "finish": 1.30 + SimpleTest.finish(); 1.31 + return; 1.32 + default: 1.33 + SimpleTest.ok(false, "test_osfile.xul: wrong message " + JSON.stringify(msg.data)); 1.34 + return; 1.35 + } 1.36 + }; 1.37 +}