michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests that the pref commands work michael@0: michael@0: let prefBranch = Cc["@mozilla.org/preferences-service;1"] michael@0: .getService(Ci.nsIPrefService).getBranch(null) michael@0: .QueryInterface(Ci.nsIPrefBranch2); michael@0: michael@0: let supportsString = Cc["@mozilla.org/supports-string;1"] michael@0: .createInstance(Ci.nsISupportsString); michael@0: michael@0: let settings = require("gcli/settings"); michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host", michael@0: Ci.nsISupportsString).data; michael@0: info("originally: devtools.debugger.remote-host = " + remoteHostOrig); michael@0: michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: 'pref show devtools.debugger.remote-host', michael@0: check: { michael@0: args: { michael@0: setting: { value: settings.getSetting("devtools.debugger.remote-host") } michael@0: }, michael@0: }, michael@0: exec: { michael@0: output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"), michael@0: }, michael@0: }, michael@0: { michael@0: setup: 'pref set devtools.debugger.remote-host e.com', michael@0: check: { michael@0: args: { michael@0: setting: { value: settings.getSetting("devtools.debugger.remote-host") }, michael@0: value: { value: "e.com" } michael@0: }, michael@0: }, michael@0: exec: { michael@0: output: '', michael@0: }, michael@0: }, michael@0: { michael@0: setup: 'pref show devtools.debugger.remote-host', michael@0: check: { michael@0: args: { michael@0: setting: { value: settings.getSetting("devtools.debugger.remote-host") } michael@0: }, michael@0: }, michael@0: exec: { michael@0: output: new RegExp("^devtools\.debugger\.remote-host: e.com$"), michael@0: }, michael@0: post: function() { michael@0: var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host", michael@0: Ci.nsISupportsString).data; michael@0: is(ecom, "e.com", "devtools.debugger.remote-host is e.com"); michael@0: } michael@0: }, michael@0: { michael@0: setup: 'pref set devtools.debugger.remote-host moz.foo', michael@0: check: { michael@0: args: { michael@0: setting: { value: settings.getSetting("devtools.debugger.remote-host") }, michael@0: value: { value: "moz.foo" } michael@0: }, michael@0: }, michael@0: exec: { michael@0: output: '', michael@0: }, michael@0: }, michael@0: { michael@0: setup: 'pref show devtools.debugger.remote-host', michael@0: check: { michael@0: args: { michael@0: setting: { value: settings.getSetting("devtools.debugger.remote-host") } michael@0: }, michael@0: }, michael@0: exec: { michael@0: output: new RegExp("^devtools\.debugger\.remote-host: moz.foo$"), michael@0: }, michael@0: post: function() { michael@0: var mozfoo = prefBranch.getComplexValue("devtools.debugger.remote-host", michael@0: Ci.nsISupportsString).data; michael@0: is(mozfoo, "moz.foo", "devtools.debugger.remote-host is moz.foo"); michael@0: } michael@0: }, michael@0: ]); michael@0: michael@0: supportsString.data = remoteHostOrig; michael@0: prefBranch.setComplexValue("devtools.debugger.remote-host", michael@0: Ci.nsISupportsString, supportsString); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }