browser_cmd_pref3.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. var supportsString = Cc["@mozilla.org/supports-string;1"]
  8. .createInstance(Ci.nsISupportsString);
  9. const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3";
  10. function test() {
  11. return Task.spawn(spawnTest).then(finish, helpers.handleError);
  12. }
  13. function* spawnTest() {
  14. let options = yield helpers.openTab(TEST_URI);
  15. yield helpers.openToolbar(options);
  16. let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host",
  17. Ci.nsISupportsString).data;
  18. info("originally: devtools.debugger.remote-host = " + remoteHostOrig);
  19. yield helpers.audit(options, [
  20. {
  21. setup: "pref show devtools.debugger.remote-host",
  22. check: {
  23. args: {
  24. setting: {
  25. value: options.requisition.system.settings.get("devtools.debugger.remote-host")
  26. }
  27. },
  28. },
  29. exec: {
  30. output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"),
  31. },
  32. },
  33. {
  34. setup: "pref set devtools.debugger.remote-host e.com",
  35. check: {
  36. args: {
  37. setting: {
  38. value: options.requisition.system.settings.get("devtools.debugger.remote-host")
  39. },
  40. value: { value: "e.com" }
  41. },
  42. },
  43. exec: {
  44. output: "",
  45. },
  46. },
  47. {
  48. setup: "pref show devtools.debugger.remote-host",
  49. check: {
  50. args: {
  51. setting: {
  52. value: options.requisition.system.settings.get("devtools.debugger.remote-host")
  53. }
  54. },
  55. },
  56. exec: {
  57. output: new RegExp("^devtools\.debugger\.remote-host: e.com$"),
  58. },
  59. post: function () {
  60. var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host",
  61. Ci.nsISupportsString).data;
  62. is(ecom, "e.com", "devtools.debugger.remote-host is e.com");
  63. }
  64. },
  65. {
  66. setup: "pref set devtools.debugger.remote-host moz.foo",
  67. check: {
  68. args: {
  69. setting: {
  70. value: options.requisition.system.settings.get("devtools.debugger.remote-host")
  71. },
  72. value: { value: "moz.foo" }
  73. },
  74. },
  75. exec: {
  76. output: "",
  77. },
  78. },
  79. {
  80. setup: "pref show devtools.debugger.remote-host",
  81. check: {
  82. args: {
  83. setting: {
  84. value: options.requisition.system.settings.get("devtools.debugger.remote-host")
  85. }
  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. supportsString.data = remoteHostOrig;
  99. prefBranch.setComplexValue("devtools.debugger.remote-host",
  100. Ci.nsISupportsString, supportsString);
  101. yield helpers.closeToolbar(options);
  102. yield helpers.closeTab(options);
  103. }