Bug 1395911 - Ensure Android addon options are not hidden while a webextension is still starting. draft
authorLuca Greco <lgreco@mozilla.com>
Fri, 01 Sep 2017 14:31:26 +0200
changeset 657414 34b99da46eeab57f853c53b7a0c8d05ee79a8fd9
parent 657343 a3585c77e2b1bc5f5fea907e97762f7b47a12033
child 729421 6b1c91293c9979d71c9f3390ce9f19876564c67f
push id77513
push userluca.greco@alcacoop.it
push dateFri, 01 Sep 2017 12:32:10 +0000
bugs1395911
milestone57.0a1
Bug 1395911 - Ensure Android addon options are not hidden while a webextension is still starting. MozReview-Commit-ID: JXxI1dK39jA
mobile/android/chrome/content/aboutAddons.js
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -392,38 +392,38 @@ var Addons = {
     // newly selected extension.
     optionsBox.innerHTML = "";
 
     switch (parseInt(addon.optionsType)) {
       case AddonManager.OPTIONS_TYPE_INLINE_BROWSER:
         // Allow the options to use all the available width space.
         optionsBox.classList.remove("inner");
 
-        this.createWebExtensionOptions(optionsBox, addon);
+        this.createWebExtensionOptions(optionsBox, addon, addonItem);
         break;
       case AddonManager.OPTIONS_TYPE_TAB:
         // Keep the usual layout for any options related the legacy (or system) add-ons
         // when the options are opened in a new tab from a single button in the addon
         // details page.
         optionsBox.classList.add("inner");
 
-        this.createOptionsInTabButton(optionsBox, addon);
+        this.createOptionsInTabButton(optionsBox, addon, addonItem);
         break;
       case AddonManager.OPTIONS_TYPE_INLINE:
         // Keep the usual layout for any options related the legacy (or system) add-ons.
         optionsBox.classList.add("inner");
 
         this.createInlineOptions(optionsBox, optionsURL, aListItem);
         break;
     }
 
     showAddonOptions();
   },
 
-  createOptionsInTabButton: function(destination, addon) {
+  createOptionsInTabButton: function(destination, addon, detailItem) {
     let frame = destination.querySelector("iframe#addon-options");
     let button = destination.querySelector("button#open-addon-options");
 
     if (frame) {
       // Remove any existent options frame (e.g. when the addon updates
       // contains the open_in_tab options for the first time).
 
       frame.remove();
@@ -441,19 +441,23 @@ var Addons = {
         // WebExtensions are loaded asynchronously and the optionsURL
         // may not be available until the addon has been started.
         await addon.startupPromise;
       }
 
       const {optionsURL} = addon;
       openOptionsInTab(optionsURL);
     };
+
+    // Ensure that the Addon Options are visible (the options box will be hidden if the optionsURL
+    // attribute is an empty string, which happens when a WebExtensions is still loading).
+    detailItem.removeAttribute("optionsURL");
   },
 
-  createWebExtensionOptions: async function(destination, addon) {
+  createWebExtensionOptions: async function(destination, addon, detailItem) {
     // WebExtensions are loaded asynchronously and the optionsURL
     // may not be available until the addon has been started.
     await addon.startupPromise;
 
     const {optionsURL, optionsBrowserStyle} = addon;
     let frame = destination.querySelector("iframe#addon-options");
 
     if (!frame) {
@@ -488,16 +492,20 @@ var Addons = {
 
       destination.appendChild(frame);
       originalHeight = frame.getBoundingClientRect().height;
     }
 
     // Loading the URL this way prevents the native back
     // button from applying to the iframe.
     frame.contentWindow.location.replace(optionsURL);
+
+    // Ensure that the Addon Options are visible (the options box will be hidden if the optionsURL
+    // attribute is an empty string, which happens when a WebExtensions is still loading).
+    detailItem.removeAttribute("optionsURL");
   },
 
   createInlineOptions(destination, optionsURL, aListItem) {
     // This function removes and returns the text content of aNode without
     // removing any child elements. Removing the text nodes ensures any XBL
     // bindings apply properly.
     function stripTextNodes(aNode) {
       var text = "";