dom/system/tests/worker_constants.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 log(text) {
michael@0 5 dump("WORKER "+text+"\n");
michael@0 6 }
michael@0 7
michael@0 8 function send(message) {
michael@0 9 self.postMessage(message);
michael@0 10 }
michael@0 11
michael@0 12 self.onmessage = function(msg) {
michael@0 13 self.onmessage = function(msg) {
michael@0 14 log("ignored message "+JSON.stringify(msg.data));
michael@0 15 };
michael@0 16 let { isDebugBuild, umask } = msg.data;
michael@0 17 try {
michael@0 18 test_name();
michael@0 19 test_xul();
michael@0 20 test_debugBuildWorkerThread(isDebugBuild);
michael@0 21 test_umaskWorkerThread(umask);
michael@0 22 } catch (x) {
michael@0 23 log("Catching error: " + x);
michael@0 24 log("Stack: " + x.stack);
michael@0 25 log("Source: " + x.toSource());
michael@0 26 ok(false, x.toString() + "\n" + x.stack);
michael@0 27 }
michael@0 28 finish();
michael@0 29 };
michael@0 30
michael@0 31 function finish() {
michael@0 32 send({kind: "finish"});
michael@0 33 }
michael@0 34
michael@0 35 function ok(condition, description) {
michael@0 36 send({kind: "ok", condition: condition, description:description});
michael@0 37 }
michael@0 38 function is(a, b, description) {
michael@0 39 send({kind: "is", a: a, b:b, description:description});
michael@0 40 }
michael@0 41 function isnot(a, b, description) {
michael@0 42 send({kind: "isnot", a: a, b:b, description:description});
michael@0 43 }
michael@0 44
michael@0 45 // Test that OS.Constants.Sys.Name is defined
michael@0 46 function test_name() {
michael@0 47 isnot(null, OS.Constants.Sys.Name, "OS.Constants.Sys.Name is defined");
michael@0 48 }
michael@0 49
michael@0 50 // Test that OS.Constants.Sys.DEBUG is set properly in ChromeWorker thread
michael@0 51 function test_debugBuildWorkerThread(isDebugBuild) {
michael@0 52 is(isDebugBuild, !!OS.Constants.Sys.DEBUG, "OS.Constants.Sys.DEBUG is set properly on worker thread");
michael@0 53 }
michael@0 54
michael@0 55 // Test that OS.Constants.Sys.umask is set properly in ChromeWorker thread
michael@0 56 function test_umaskWorkerThread(umask) {
michael@0 57 is(umask, OS.Constants.Sys.umask,
michael@0 58 "OS.Constants.Sys.umask is set properly on worker thread: " +
michael@0 59 ("0000"+umask.toString(8)).slice(-4));
michael@0 60 }
michael@0 61
michael@0 62 // Test that OS.Constants.Path.libxul lets us open libxul
michael@0 63 function test_xul() {
michael@0 64 let lib;
michael@0 65 isnot(null, OS.Constants.Path.libxul, "libxul is defined");
michael@0 66 try {
michael@0 67 lib = ctypes.open(OS.Constants.Path.libxul);
michael@0 68 lib.declare("DumpJSStack", ctypes.default_abi, ctypes.void_t);
michael@0 69 } catch (x) {
michael@0 70 ok(false, "test_xul: Could not open libxul: " + x);
michael@0 71 }
michael@0 72 if (lib) {
michael@0 73 lib.close();
michael@0 74 }
michael@0 75 ok(true, "test_xul: opened libxul successfully");
michael@0 76 }

mercurial