|
1 |
|
2 "use strict"; |
|
3 |
|
4 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
5 Cu.import('resource://gre/modules/Services.jsm'); |
|
6 Cu.import('resource://gre/modules/identity/LogUtils.jsm'); |
|
7 |
|
8 function toggle_debug() { |
|
9 do_test_pending(); |
|
10 |
|
11 function Wrapper() { |
|
12 this.init(); |
|
13 } |
|
14 Wrapper.prototype = { |
|
15 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]), |
|
16 |
|
17 observe: function observe(aSubject, aTopic, aData) { |
|
18 if (aTopic === "nsPref:changed") { |
|
19 // race condition? |
|
20 do_check_eq(Logger._debug, true); |
|
21 do_test_finished(); |
|
22 run_next_test(); |
|
23 } |
|
24 }, |
|
25 |
|
26 init: function() { |
|
27 Services.prefs.addObserver('toolkit.identity.debug', this, false); |
|
28 } |
|
29 }; |
|
30 |
|
31 var wrapper = new Wrapper(); |
|
32 Services.prefs.setBoolPref('toolkit.identity.debug', true); |
|
33 } |
|
34 |
|
35 // test that things don't break |
|
36 |
|
37 function logAlias(...args) { |
|
38 Logger.log.apply(Logger, ["log alias"].concat(args)); |
|
39 } |
|
40 function reportErrorAlias(...args) { |
|
41 Logger.reportError.apply(Logger, ["report error alias"].concat(args)); |
|
42 } |
|
43 |
|
44 function test_log() { |
|
45 Logger.log("log test", "I like pie"); |
|
46 do_test_finished(); |
|
47 run_next_test(); |
|
48 } |
|
49 |
|
50 function test_reportError() { |
|
51 Logger.reportError("log test", "We are out of pies!!!"); |
|
52 do_test_finished(); |
|
53 run_next_test(); |
|
54 } |
|
55 |
|
56 function test_wrappers() { |
|
57 logAlias("I like potatoes"); |
|
58 do_test_finished(); |
|
59 reportErrorAlias("Too much red bull"); |
|
60 } |
|
61 |
|
62 let TESTS = [ |
|
63 // XXX fix me |
|
64 // toggle_debug, |
|
65 test_log, |
|
66 test_reportError, |
|
67 test_wrappers, |
|
68 ]; |
|
69 |
|
70 TESTS.forEach(add_test); |
|
71 |
|
72 function run_test() { |
|
73 run_next_test(); |
|
74 } |