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