|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Tests that the pref commands work |
|
5 |
|
6 let prefBranch = Cc["@mozilla.org/preferences-service;1"] |
|
7 .getService(Ci.nsIPrefService).getBranch(null) |
|
8 .QueryInterface(Ci.nsIPrefBranch2); |
|
9 |
|
10 let supportsString = Cc["@mozilla.org/supports-string;1"] |
|
11 .createInstance(Ci.nsISupportsString); |
|
12 |
|
13 let settings = require("gcli/settings"); |
|
14 |
|
15 const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3"; |
|
16 |
|
17 function test() { |
|
18 return Task.spawn(spawnTest).then(finish, helpers.handleError); |
|
19 } |
|
20 |
|
21 function spawnTest() { |
|
22 let options = yield helpers.openTab(TEST_URI); |
|
23 yield helpers.openToolbar(options); |
|
24 |
|
25 let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host", |
|
26 Ci.nsISupportsString).data; |
|
27 info("originally: devtools.debugger.remote-host = " + remoteHostOrig); |
|
28 |
|
29 yield helpers.audit(options, [ |
|
30 { |
|
31 setup: 'pref show devtools.debugger.remote-host', |
|
32 check: { |
|
33 args: { |
|
34 setting: { value: settings.getSetting("devtools.debugger.remote-host") } |
|
35 }, |
|
36 }, |
|
37 exec: { |
|
38 output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"), |
|
39 }, |
|
40 }, |
|
41 { |
|
42 setup: 'pref set devtools.debugger.remote-host e.com', |
|
43 check: { |
|
44 args: { |
|
45 setting: { value: settings.getSetting("devtools.debugger.remote-host") }, |
|
46 value: { value: "e.com" } |
|
47 }, |
|
48 }, |
|
49 exec: { |
|
50 output: '', |
|
51 }, |
|
52 }, |
|
53 { |
|
54 setup: 'pref show devtools.debugger.remote-host', |
|
55 check: { |
|
56 args: { |
|
57 setting: { value: settings.getSetting("devtools.debugger.remote-host") } |
|
58 }, |
|
59 }, |
|
60 exec: { |
|
61 output: new RegExp("^devtools\.debugger\.remote-host: e.com$"), |
|
62 }, |
|
63 post: function() { |
|
64 var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host", |
|
65 Ci.nsISupportsString).data; |
|
66 is(ecom, "e.com", "devtools.debugger.remote-host is e.com"); |
|
67 } |
|
68 }, |
|
69 { |
|
70 setup: 'pref set devtools.debugger.remote-host moz.foo', |
|
71 check: { |
|
72 args: { |
|
73 setting: { value: settings.getSetting("devtools.debugger.remote-host") }, |
|
74 value: { value: "moz.foo" } |
|
75 }, |
|
76 }, |
|
77 exec: { |
|
78 output: '', |
|
79 }, |
|
80 }, |
|
81 { |
|
82 setup: 'pref show devtools.debugger.remote-host', |
|
83 check: { |
|
84 args: { |
|
85 setting: { value: settings.getSetting("devtools.debugger.remote-host") } |
|
86 }, |
|
87 }, |
|
88 exec: { |
|
89 output: new RegExp("^devtools\.debugger\.remote-host: moz.foo$"), |
|
90 }, |
|
91 post: function() { |
|
92 var mozfoo = prefBranch.getComplexValue("devtools.debugger.remote-host", |
|
93 Ci.nsISupportsString).data; |
|
94 is(mozfoo, "moz.foo", "devtools.debugger.remote-host is moz.foo"); |
|
95 } |
|
96 }, |
|
97 ]); |
|
98 |
|
99 supportsString.data = remoteHostOrig; |
|
100 prefBranch.setComplexValue("devtools.debugger.remote-host", |
|
101 Ci.nsISupportsString, supportsString); |
|
102 |
|
103 yield helpers.closeToolbar(options); |
|
104 yield helpers.closeTab(options); |
|
105 } |