Bug 1299001 - Ensure that the toolbox resets the preferences set when it is closed. r=ochameau
authorLuca Greco <lgreco@mozilla.com>
Tue, 02 Oct 2018 19:09:37 +0000
changeset 495005 5e5d6abb39afe0a23555db526a5bbbf3d59b4cd9
parent 494979 4392b5198fb7773f6148d2caedff82da5f527bfe
child 495006 2de25096cdd54c32488a4d5fdb1fefce6d1fb6db
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1299001, 1222047
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1299001 - Ensure that the toolbox resets the preferences set when it is closed. r=ochameau This patch fixes a regression which has been likely introduced in the refactoring we did in Bug 1222047 on Firefox 63. Differential Revision: https://phabricator.services.mozilla.com/D7523
devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
devtools/client/framework/toolbox.js
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
@@ -40,16 +40,19 @@ function makeWidgetId(id) {
   id = id.toLowerCase();
   return id.replace(/[^a-z0-9_-]/g, "_");
 }
 
 add_task(async function testWebExtensionsToolboxSwitchToPopup() {
   let onReadyForOpenPopup;
   let onPopupCustomMessage;
 
+  is(Services.prefs.getBoolPref("ui.popup.disable_autohide"), false,
+     "disable_autohide shoult be initially false");
+
   Management.on("startup", function listener(event, extension) {
     if (extension.name != ADDON_NAME) {
       return;
     }
 
     Management.off("startup", listener);
 
     function waitForExtensionTestMessage(expectedMessage) {
@@ -201,13 +204,16 @@ add_task(async function testWebExtension
   const args = await onPopupCustomMessage;
   ok(true, "Received console message from the popup page function as expected");
   is(args[0], "popupPageFunctionCalled", "Got the expected console message");
   is(args[1] && args[1].name, ADDON_NAME,
      "Got the expected manifest from WebExtension API");
 
   await onToolboxClose;
 
-  ok(true, "Addon toolbox closed");
+  info("Addon toolbox closed");
+
+  is(Services.prefs.getBoolPref("ui.popup.disable_autohide"), false,
+     "disable_autohide should be reset to false when the toolbox is closed");
 
   await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
   await closeAboutDebugging(tab);
 });
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -2260,26 +2260,34 @@ Toolbox.prototype = {
   },
 
   /**
    * Returns an instance of the preference actor. This is a lazily initialized root
    * actor that persists preferences to the debuggee, instead of just to the DevTools
    * client. See the definition of the preference actor for more information.
    */
   get preferenceFront() {
-    return this.target.client.mainRoot.getFront("preference");
+    const frontPromise = this.target.client.mainRoot.getFront("preference");
+    frontPromise.then(front => {
+      // Set the _preferenceFront property to allow the resetPreferences toolbox method
+      // to cleanup the preference set when the toolbox is closed.
+      this._preferenceFront = front;
+    });
+
+    return frontPromise;
   },
 
   // Is the disable auto-hide of pop-ups feature available in this context?
   get disableAutohideAvailable() {
     return this._target.chrome;
   },
 
   async toggleNoAutohide() {
     const front = await this.preferenceFront;
+
     const toggledValue = !(await this._isDisableAutohideEnabled());
 
     front.setBoolPref(DISABLE_AUTOHIDE_PREF, toggledValue);
 
     if (this.disableAutohideAvailable) {
       this.component.setDisableAutohide(toggledValue);
     }
     this._autohideHasBeenToggled = true;