Bug 1435705 - Fix WebExtensions options_ui hidden. draft
authorLuca Greco <lgreco@mozilla.com>
Tue, 13 Feb 2018 20:59:11 +0100
changeset 759005 5982f9933b2c63d5e0f7b24f619071191463bd6b
parent 758396 ea3da643422c58d65335f1778dd6c89c09911585
push id100249
push userluca.greco@alcacoop.it
push dateFri, 23 Feb 2018 15:30:07 +0000
bugs1435705
milestone60.0a1
Bug 1435705 - Fix WebExtensions options_ui hidden. If a user opens the about:addons page and then immediately switches to the addon details, while the discovery panel is still loading, then a ViewChanged event is received once the discovery panel has been completely loaded and the options_ui of the extension was removed (because the ViewChanged event is also sent when the about:addons page navigates between its sub-views). MozReview-Commit-ID: GBF5NHezpNB
toolkit/mozapps/extensions/content/extensions.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -3190,24 +3190,34 @@ var gDetailView = {
           gDetailView.scrollToPreferencesRows();
       });
     };
 
     var rows = document.getElementById("detail-downloads").parentNode;
 
     if (this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_BROWSER) {
       whenViewLoaded(async () => {
-        await this._addon.startupPromise;
+        const addon = this._addon;
+        await addon.startupPromise;
 
         const browserContainer = await this.createOptionsBrowser(rows);
 
         if (browserContainer) {
           // Make sure the browser is unloaded as soon as we change views,
           // rather than waiting for the next detail view to load.
           document.addEventListener("ViewChanged", function() {
+            // Do not remove the addon options container if the view changed
+            // event is not related to a change to the current selected view
+            // or the current selected addon (e.g. it could be related to the
+            // disco pane view that has completed to load, See Bug 1435705 for
+            // a rationale).
+            if (gViewController.currentViewObj === gDetailView &&
+                gDetailView._addon === addon) {
+              return;
+            }
             browserContainer.remove();
           }, {once: true});
         }
 
         finish(browserContainer);
       });
     }