1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/commandline/test/browser_cmd_pref3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,105 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Tests that the pref commands work 1.8 + 1.9 +let prefBranch = Cc["@mozilla.org/preferences-service;1"] 1.10 + .getService(Ci.nsIPrefService).getBranch(null) 1.11 + .QueryInterface(Ci.nsIPrefBranch2); 1.12 + 1.13 +let supportsString = Cc["@mozilla.org/supports-string;1"] 1.14 + .createInstance(Ci.nsISupportsString); 1.15 + 1.16 +let settings = require("gcli/settings"); 1.17 + 1.18 +const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3"; 1.19 + 1.20 +function test() { 1.21 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.22 +} 1.23 + 1.24 +function spawnTest() { 1.25 + let options = yield helpers.openTab(TEST_URI); 1.26 + yield helpers.openToolbar(options); 1.27 + 1.28 + let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host", 1.29 + Ci.nsISupportsString).data; 1.30 + info("originally: devtools.debugger.remote-host = " + remoteHostOrig); 1.31 + 1.32 + yield helpers.audit(options, [ 1.33 + { 1.34 + setup: 'pref show devtools.debugger.remote-host', 1.35 + check: { 1.36 + args: { 1.37 + setting: { value: settings.getSetting("devtools.debugger.remote-host") } 1.38 + }, 1.39 + }, 1.40 + exec: { 1.41 + output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"), 1.42 + }, 1.43 + }, 1.44 + { 1.45 + setup: 'pref set devtools.debugger.remote-host e.com', 1.46 + check: { 1.47 + args: { 1.48 + setting: { value: settings.getSetting("devtools.debugger.remote-host") }, 1.49 + value: { value: "e.com" } 1.50 + }, 1.51 + }, 1.52 + exec: { 1.53 + output: '', 1.54 + }, 1.55 + }, 1.56 + { 1.57 + setup: 'pref show devtools.debugger.remote-host', 1.58 + check: { 1.59 + args: { 1.60 + setting: { value: settings.getSetting("devtools.debugger.remote-host") } 1.61 + }, 1.62 + }, 1.63 + exec: { 1.64 + output: new RegExp("^devtools\.debugger\.remote-host: e.com$"), 1.65 + }, 1.66 + post: function() { 1.67 + var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host", 1.68 + Ci.nsISupportsString).data; 1.69 + is(ecom, "e.com", "devtools.debugger.remote-host is e.com"); 1.70 + } 1.71 + }, 1.72 + { 1.73 + setup: 'pref set devtools.debugger.remote-host moz.foo', 1.74 + check: { 1.75 + args: { 1.76 + setting: { value: settings.getSetting("devtools.debugger.remote-host") }, 1.77 + value: { value: "moz.foo" } 1.78 + }, 1.79 + }, 1.80 + exec: { 1.81 + output: '', 1.82 + }, 1.83 + }, 1.84 + { 1.85 + setup: 'pref show devtools.debugger.remote-host', 1.86 + check: { 1.87 + args: { 1.88 + setting: { value: settings.getSetting("devtools.debugger.remote-host") } 1.89 + }, 1.90 + }, 1.91 + exec: { 1.92 + output: new RegExp("^devtools\.debugger\.remote-host: moz.foo$"), 1.93 + }, 1.94 + post: function() { 1.95 + var mozfoo = prefBranch.getComplexValue("devtools.debugger.remote-host", 1.96 + Ci.nsISupportsString).data; 1.97 + is(mozfoo, "moz.foo", "devtools.debugger.remote-host is moz.foo"); 1.98 + } 1.99 + }, 1.100 + ]); 1.101 + 1.102 + supportsString.data = remoteHostOrig; 1.103 + prefBranch.setComplexValue("devtools.debugger.remote-host", 1.104 + Ci.nsISupportsString, supportsString); 1.105 + 1.106 + yield helpers.closeToolbar(options); 1.107 + yield helpers.closeTab(options); 1.108 +}