browser_cmd_pref2.js 2.7 KB

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