michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function log(text) { michael@0: dump("WORKER "+text+"\n"); michael@0: } michael@0: michael@0: function send(message) { michael@0: self.postMessage(message); michael@0: } michael@0: michael@0: self.onmessage = function(msg) { michael@0: self.onmessage = function(msg) { michael@0: log("ignored message "+JSON.stringify(msg.data)); michael@0: }; michael@0: let { isDebugBuild, umask } = msg.data; michael@0: try { michael@0: test_name(); michael@0: test_xul(); michael@0: test_debugBuildWorkerThread(isDebugBuild); michael@0: test_umaskWorkerThread(umask); michael@0: } catch (x) { michael@0: log("Catching error: " + x); michael@0: log("Stack: " + x.stack); michael@0: log("Source: " + x.toSource()); michael@0: ok(false, x.toString() + "\n" + x.stack); michael@0: } michael@0: finish(); michael@0: }; michael@0: michael@0: function finish() { michael@0: send({kind: "finish"}); michael@0: } michael@0: michael@0: function ok(condition, description) { michael@0: send({kind: "ok", condition: condition, description:description}); michael@0: } michael@0: function is(a, b, description) { michael@0: send({kind: "is", a: a, b:b, description:description}); michael@0: } michael@0: function isnot(a, b, description) { michael@0: send({kind: "isnot", a: a, b:b, description:description}); michael@0: } michael@0: michael@0: // Test that OS.Constants.Sys.Name is defined michael@0: function test_name() { michael@0: isnot(null, OS.Constants.Sys.Name, "OS.Constants.Sys.Name is defined"); michael@0: } michael@0: michael@0: // Test that OS.Constants.Sys.DEBUG is set properly in ChromeWorker thread michael@0: function test_debugBuildWorkerThread(isDebugBuild) { michael@0: is(isDebugBuild, !!OS.Constants.Sys.DEBUG, "OS.Constants.Sys.DEBUG is set properly on worker thread"); michael@0: } michael@0: michael@0: // Test that OS.Constants.Sys.umask is set properly in ChromeWorker thread michael@0: function test_umaskWorkerThread(umask) { michael@0: is(umask, OS.Constants.Sys.umask, michael@0: "OS.Constants.Sys.umask is set properly on worker thread: " + michael@0: ("0000"+umask.toString(8)).slice(-4)); michael@0: } michael@0: michael@0: // Test that OS.Constants.Path.libxul lets us open libxul michael@0: function test_xul() { michael@0: let lib; michael@0: isnot(null, OS.Constants.Path.libxul, "libxul is defined"); michael@0: try { michael@0: lib = ctypes.open(OS.Constants.Path.libxul); michael@0: lib.declare("DumpJSStack", ctypes.default_abi, ctypes.void_t); michael@0: } catch (x) { michael@0: ok(false, "test_xul: Could not open libxul: " + x); michael@0: } michael@0: if (lib) { michael@0: lib.close(); michael@0: } michael@0: ok(true, "test_xul: opened libxul successfully"); michael@0: }