1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/commandline/test/browser_cmd_pref2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 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 settings = require("gcli/settings"); 1.14 + 1.15 +const TEST_URI = "data:text/html;charset=utf-8,gcli-pref2"; 1.16 + 1.17 +function test() { 1.18 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.19 +} 1.20 + 1.21 +function spawnTest() { 1.22 + let options = yield helpers.openTab(TEST_URI); 1.23 + yield helpers.openToolbar(options); 1.24 + 1.25 + let tabSizeOrig = prefBranch.getIntPref("devtools.editor.tabsize"); 1.26 + info("originally: devtools.editor.tabsize = " + tabSizeOrig); 1.27 + 1.28 + yield helpers.audit(options, [ 1.29 + { 1.30 + setup: 'pref show devtools.editor.tabsize', 1.31 + check: { 1.32 + args: { 1.33 + setting: { value: settings.getSetting("devtools.editor.tabsize") } 1.34 + }, 1.35 + }, 1.36 + exec: { 1.37 + output: "devtools.editor.tabsize: " + tabSizeOrig, 1.38 + }, 1.39 + }, 1.40 + { 1.41 + setup: 'pref set devtools.editor.tabsize 20', 1.42 + check: { 1.43 + args: { 1.44 + setting: { value: settings.getSetting("devtools.editor.tabsize") }, 1.45 + value: { value: 20 } 1.46 + }, 1.47 + }, 1.48 + exec: { 1.49 + output: '', 1.50 + }, 1.51 + post: function() { 1.52 + is(prefBranch.getIntPref("devtools.editor.tabsize"), 20, 1.53 + "devtools.editor.tabsize is 20"); 1.54 + } 1.55 + }, 1.56 + { 1.57 + setup: 'pref show devtools.editor.tabsize', 1.58 + check: { 1.59 + args: { 1.60 + setting: { value: settings.getSetting("devtools.editor.tabsize") } 1.61 + }, 1.62 + }, 1.63 + exec: { 1.64 + output: "devtools.editor.tabsize: 20", 1.65 + } 1.66 + }, 1.67 + { 1.68 + setup: 'pref set devtools.editor.tabsize 1', 1.69 + check: { 1.70 + args: { 1.71 + setting: { value: settings.getSetting("devtools.editor.tabsize") }, 1.72 + value: { value: 1 } 1.73 + }, 1.74 + }, 1.75 + exec: { 1.76 + output: '', 1.77 + }, 1.78 + }, 1.79 + { 1.80 + setup: 'pref show devtools.editor.tabsize', 1.81 + check: { 1.82 + args: { 1.83 + setting: { value: settings.getSetting("devtools.editor.tabsize") } 1.84 + }, 1.85 + }, 1.86 + exec: { 1.87 + output: "devtools.editor.tabsize: 1", 1.88 + }, 1.89 + post: function() { 1.90 + is(prefBranch.getIntPref("devtools.editor.tabsize"), 1, 1.91 + "devtools.editor.tabsize is 1"); 1.92 + } 1.93 + }, 1.94 + ]); 1.95 + 1.96 + prefBranch.setIntPref("devtools.editor.tabsize", tabSizeOrig); 1.97 + 1.98 + yield helpers.closeToolbar(options); 1.99 + yield helpers.closeTab(options); 1.100 +}