browser_addons_toggle_debug.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. // Test that individual Debug buttons are disabled when "Addons debugging"
  5. // is disabled.
  6. // Test that the buttons are updated dynamically if the preference changes.
  7. const ADDON_ID = "test-devtools@mozilla.org";
  8. const ADDON_NAME = "test-devtools";
  9. add_task(function* () {
  10. info("Turn off addon debugging.");
  11. yield new Promise(resolve => {
  12. let options = {"set": [
  13. ["devtools.chrome.enabled", false],
  14. ["devtools.debugger.remote-enabled", false],
  15. ]};
  16. SpecialPowers.pushPrefEnv(options, resolve);
  17. });
  18. let { tab, document } = yield openAboutDebugging("addons");
  19. yield waitForInitialAddonList(document);
  20. info("Install a test addon.");
  21. yield installAddon({
  22. document,
  23. path: "addons/unpacked/install.rdf",
  24. name: ADDON_NAME,
  25. });
  26. let addonDebugCheckbox = document.querySelector("#enable-addon-debugging");
  27. ok(!addonDebugCheckbox.checked, "Addons debugging should be disabled.");
  28. info("Check all debug buttons are disabled.");
  29. let debugButtons = [...document.querySelectorAll("#addons .debug-button")];
  30. ok(debugButtons.every(b => b.disabled), "Debug buttons should be disabled");
  31. info("Click on 'Enable addons debugging' checkbox.");
  32. let addonsContainer = document.getElementById("addons");
  33. let onAddonsMutation = waitForMutation(addonsContainer,
  34. { subtree: true, attributes: true });
  35. addonDebugCheckbox.click();
  36. yield onAddonsMutation;
  37. info("Check all debug buttons are enabled.");
  38. ok(addonDebugCheckbox.checked, "Addons debugging should be enabled.");
  39. debugButtons = [...document.querySelectorAll("#addons .debug-button")];
  40. ok(debugButtons.every(b => !b.disabled), "Debug buttons should be enabled");
  41. info("Click again on 'Enable addons debugging' checkbox.");
  42. onAddonsMutation = waitForMutation(addonsContainer,
  43. { subtree: true, attributes: true });
  44. addonDebugCheckbox.click();
  45. yield onAddonsMutation;
  46. info("Check all debug buttons are disabled again.");
  47. debugButtons = [...document.querySelectorAll("#addons .debug-button")];
  48. ok(debugButtons.every(b => b.disabled), "Debug buttons should be disabled");
  49. info("Uninstall addon installed earlier.");
  50. yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
  51. yield closeAboutDebugging(tab);
  52. });