Bug 1551490 - Hide add-on preferences when not allowed in private windows, fix browser_webext_incognito.js. r=rpl, a=jcristau
authorRob Wu <rob@robwu.nl>
Mon, 10 Jun 2019 00:03:36 +0000
changeset 536905 82e6701f5dbbead6f5c610020fce9b3d62b8ab65
parent 536904 3bbbdeca9f13b3c20c6df3419c1726de429fb9e8
child 536906 466fe0fc7db3f5d4d740ff388c15aa7dc9eff14b
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl, jcristau
bugs1551490
milestone68.0
Bug 1551490 - Hide add-on preferences when not allowed in private windows, fix browser_webext_incognito.js. r=rpl, a=jcristau Fix browser_webext_incognito.js to work with both XUL and HTML about:addons. This patch also ensures that (inline) options UI is only shown in HTML about:addons in private windows if add-ons are allowed access to it. browser_webext_incognito.js serves as a unit test for this. Differential Revision: https://phabricator.services.mozilla.com/D34277
toolkit/mozapps/extensions/content/aboutaddons.js
toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -157,16 +157,37 @@ const OPTIONS_TYPE_MAP = {
 };
 
 // Check if an add-on has the provided options type, accounting for the pref
 // to disable inline options.
 function getOptionsType(addon, type) {
   return OPTIONS_TYPE_MAP[addon.optionsType];
 }
 
+// Check whether the options page can be loaded in the current browser window.
+async function isAddonOptionsUIAllowed(addon) {
+  if (addon.type !== "extension" || !getOptionsType(addon)) {
+    // Themes never have options pages.
+    // Some plugins have preference pages, and they can always be shown.
+    // Extensions do not need to be checked if they do not have options pages.
+    return true;
+  }
+  if (!PrivateBrowsingUtils.isContentWindowPrivate(window)) {
+    return true;
+  }
+  if (addon.incognito === "not_allowed") {
+    return false;
+  }
+  // The current page is in a private browsing window, and the add-on does not
+  // have the permission to access private browsing windows. Block access.
+  return allowPrivateBrowsingByDefault ||
+    // Note: This function is async because isAllowedInPrivateBrowsing is async.
+    isAllowedInPrivateBrowsing(addon);
+}
+
 /**
  * This function is set in initialize() by the parent about:addons window. It
  * is a helper for gViewController.loadView().
  *
  * @param {string} type The view type to load.
  * @param {string} param The (optional) param for the view.
  */
 let loadViewFn;
@@ -625,16 +646,21 @@ class AddonOptions extends HTMLElement {
         el.hidden = !updateInstall;
         break;
       case "expand":
         el.hidden = card.expanded;
         break;
       case "preferences":
         el.hidden = getOptionsType(addon) !== "tab" &&
           (getOptionsType(addon) !== "inline" || card.expanded);
+        if (!el.hidden) {
+          isAddonOptionsUIAllowed(addon).then(allowed => {
+            el.hidden = !allowed;
+          });
+        }
         break;
     }
   }
 
   update(card, addon, updateInstall) {
     for (let el of this.querySelectorAll("panel-item")) {
       this.setElementState(el, card, addon, updateInstall);
     }
@@ -1099,16 +1125,21 @@ class AddonDetails extends HTMLElement {
     let getButtonByName =
       name => this.tabGroup.querySelector(`[name="${name}"]`);
     let permsBtn = getButtonByName("permissions");
     permsBtn.hidden = addon.type != "extension";
     let notesBtn = getButtonByName("release-notes");
     notesBtn.hidden = !this.releaseNotesUri;
     let prefsBtn = getButtonByName("preferences");
     prefsBtn.hidden = getOptionsType(addon) !== "inline";
+    if (!prefsBtn.hidden) {
+      isAddonOptionsUIAllowed(addon).then(allowed => {
+        prefsBtn.hidden = !allowed;
+      });
+    }
 
     // Hide the tab group if "details" is the only visible button.
     this.tabGroup.hidden = Array.from(this.tabGroup.children).every(button => {
       return button.name == "details" || button.hidden;
     });
 
     // Show the update check button if necessary. The button might not exist if
     // the add-on doesn't support updates.
@@ -1516,16 +1547,23 @@ class AddonCard extends HTMLElement {
     }
   }
 
   onEnabled(addon) {
     this.reloading = false;
     this.update();
   }
 
+  onInstalled(addon) {
+    // When a temporary addon is reloaded, onInstalled is triggered instead of
+    // onEnabled.
+    this.reloading = false;
+    this.update();
+  }
+
   onUninstalling() {
     // Dispatch a remove event, the DetailView is listening for this to get us
     // back to the list view when the current add-on is removed.
     this.sendEvent("remove");
   }
 
   onUpdateModeChanged() {
     this.update();
@@ -2579,17 +2617,18 @@ class DetailView {
     setCategoryFn(addon.type);
 
     // Go back to the list view when the add-on is removed.
     card.addEventListener("remove", () => loadViewFn("list", addon.type));
 
     card.setAddon(addon);
     card.expand();
     await card.render();
-    if (this.selectedTab === "preferences") {
+    if (this.selectedTab === "preferences" &&
+        (await isAddonOptionsUIAllowed(addon))) {
       card.showPrefs();
     }
 
     this.root.textContent = "";
     this.root.appendChild(card);
   }
 }
 
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
@@ -7,39 +7,154 @@ const {ExtensionPermissions} = ChromeUti
 
 var gManagerWindow;
 
 AddonTestUtils.initMochitest(this);
 
 function get_test_items() {
   var items = {};
 
-  for (let item of gManagerWindow.document.getElementById("addon-list").childNodes) {
-    items[item.mAddon.id] = item;
+  if (gManagerWindow.useHtmlViews) {
+    for (let item of gManagerWindow.getHtmlBrowser().contentDocument.querySelectorAll("addon-card")) {
+      items[item.getAttribute("addon-id")] = item;
+    }
+  } else {
+    for (let item of gManagerWindow.document.getElementById("addon-list").childNodes) {
+      items[item.mAddon.id] = item;
+    }
   }
 
   return items;
 }
 
 function get(aId) {
   return gManagerWindow.document.getElementById(aId);
 }
 
+function getHtmlElem(selector) {
+  return gManagerWindow.getHtmlBrowser().contentDocument.querySelector(selector);
+}
+
+function getPrivateBrowsingBadge(card) {
+  if (gManagerWindow.useHtmlViews) {
+    return card.querySelector(".addon-badge-private-browsing-allowed");
+  }
+  return card.ownerDocument.getAnonymousElementByAttribute(card, "anonid", "privateBrowsing");
+}
+
+function getPreferencesButtonAtListView(card) {
+  if (gManagerWindow.useHtmlViews) {
+    return card.querySelector("panel-item[action='preferences']");
+  }
+  return card._preferencesBtn;
+}
+
+function getPreferencesButtonAtDetailsView() {
+  if (gManagerWindow.useHtmlViews) {
+    return getHtmlElem("panel-item[action='preferences']");
+  }
+  return gManagerWindow.document.getElementById("detail-prefs-btn");
+}
+
+function isInlineOptionsVisible() {
+  if (gManagerWindow.useHtmlViews) {
+    // The following button is used to open the inline options browser.
+    return !getHtmlElem("named-deck-button[name='preferences']").hidden;
+  }
+  return !!gManagerWindow.document.getElementById("addon-options");
+}
+
+function getPrivateBrowsingValue() {
+  if (gManagerWindow.useHtmlViews) {
+    return getHtmlElem("input[type='radio'][name='private-browsing']:checked").value;
+  }
+  return gManagerWindow.document.getElementById("detail-privateBrowsing").value;
+}
+
+async function setPrivateBrowsingValue(value) {
+  if (gManagerWindow.useHtmlViews) {
+    let radio = getHtmlElem(`input[type="radio"][name="private-browsing"][value="${value}"]`);
+    EventUtils.synthesizeMouseAtCenter(radio, { clickCount: 1 }, radio.ownerGlobal);
+    return TestUtils.waitForCondition(() => radio.checked,
+                                      `Waiting for privateBrowsing=${value}`);
+  }
+  let privateBrowsing = gManagerWindow.document.getElementById("detail-privateBrowsing");
+  let radio = privateBrowsing.querySelector(`radio[value="${value}"]`);
+  EventUtils.synthesizeMouseAtCenter(radio, { clickCount: 1 }, gManagerWindow);
+  return TestUtils.waitForCondition(() => privateBrowsing.value == value,
+                                    `Waiting for privateBrowsing=${value}`);
+}
+
+// Check whether the private browsing inputs are visible in the details view.
+function checkIsModifiable(expected) {
+  if (gManagerWindow.useHtmlViews) {
+    if (expected) {
+      is_element_visible(getHtmlElem(".addon-detail-row-private-browsing"), "Private browsing should be visible");
+    } else {
+      is_element_hidden(getHtmlElem(".addon-detail-row-private-browsing"), "Private browsing should be hidden");
+    }
+    return;
+  }
+  if (expected) {
+    is_element_visible(get("detail-privateBrowsing-row"), "Private browsing should be visible");
+    is_element_visible(get("detail-privateBrowsing-row-footer"), "Private browsing footer should be visible");
+  } else {
+    is_element_hidden(get("detail-privateBrowsing-row"), "Private browsing should be hidden");
+    is_element_hidden(get("detail-privateBrowsing-row-footer"), "Private browsing footer should be hidden");
+  }
+}
+
+// Check whether the details view shows that private browsing is forcibly disallowed.
+function checkIsDisallowed(expected) {
+  if (gManagerWindow.useHtmlViews) {
+    // TODO bug 1557792: Show when private browsing is forcibly disallowed.
+    if (expected) {
+      is_element_hidden(getHtmlElem(".addon-detail-row-private-browsing"), "Private browsing cannot both be allowed and disallowed");
+    }
+    return;
+  }
+  if (expected) {
+    is_element_visible(get("detail-privateBrowsing-disallowed"), "Private browsing should be disallowed");
+    is_element_visible(get("detail-privateBrowsing-disallowed-footer"), "Private browsing footer should be disallowed");
+  } else {
+    is_element_hidden(get("detail-privateBrowsing-disallowed"), "Private browsing should not be disallowed");
+    is_element_hidden(get("detail-privateBrowsing-disallowed-footer"), "Private browsing footer should not be disallowed");
+  }
+}
+
+// Check whether the details view shows that private browsing is forcibly allowed.
+function checkIsRequired(expected) {
+  if (gManagerWindow.useHtmlViews) {
+    // TODO bug 1557792: Show when private browsing is forcibly allowed.
+    if (expected) {
+      is_element_hidden(getHtmlElem(".addon-detail-row-private-browsing"), "Private browsing cannot both be mutable and required");
+    }
+    return;
+  }
+  if (expected) {
+    is_element_visible(get("detail-privateBrowsing-required"), "Private required should be visible");
+    is_element_visible(get("detail-privateBrowsing-required-footer"), "Private required footer should be visible");
+  } else {
+    is_element_hidden(get("detail-privateBrowsing-required"), "Private required should be hidden");
+    is_element_hidden(get("detail-privateBrowsing-required-footer"), "Private required footer should be hidden");
+  }
+}
+
 async function hasPrivateAllowed(id) {
   let perms = await ExtensionPermissions.get(id);
   return perms.permissions.length == 1 &&
          perms.permissions[0] == "internal:privateBrowsingAllowed";
 }
 
 add_task(function clearInitialTelemetry() {
   // Clear out any telemetry data that existed before this file is run.
   Services.telemetry.clearEvents();
 });
 
-add_task(async function test_addon() {
+async function test_badge_and_toggle_incognito() {
   await SpecialPowers.pushPrefEnv({set: [["extensions.allowPrivateBrowsingByDefault", false]]});
 
   let addons = new Map([
     ["@test-default", {
       useAddonManager: "temporary",
       manifest: {
         applications: {
           gecko: {id: "@test-default"},
@@ -77,56 +192,49 @@ add_task(async function test_addon() {
   let extensions = [];
   for (let definition of addons.values()) {
     let extension = ExtensionTestUtils.loadExtension(definition);
     extensions.push(extension);
     await extension.startup();
   }
 
   gManagerWindow = await open_manager("addons://list/extension");
-  let doc = gManagerWindow.document;
   let items = get_test_items();
   for (let [id, definition] of addons.entries()) {
     ok(items[id], `${id} listed`);
-    let badge = doc.getAnonymousElementByAttribute(items[id], "anonid", "privateBrowsing");
+    let badge = getPrivateBrowsingBadge(items[id]);
     if (definition.incognitoOverride == "spanning") {
       is_element_visible(badge, `private browsing badge is visible`);
     } else {
       is_element_hidden(badge, `private browsing badge is hidden`);
     }
   }
   await close_manager(gManagerWindow);
 
   for (let [id, definition] of addons.entries()) {
     gManagerWindow = await open_manager("addons://detail/" + encodeURIComponent(id));
     ok(true, `==== ${id} detail opened`);
     if (definition.manifest.incognito == "not_allowed") {
-      is_element_hidden(get("detail-privateBrowsing-row"), "Private browsing should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-row-footer"), "Private browsing footer should be hidden");
+      checkIsModifiable(false);
       ok(!await hasPrivateAllowed(id), "Private browsing permission not set");
-      is_element_visible(get("detail-privateBrowsing-disallowed"), "Private browsing should be hidden");
-      is_element_visible(get("detail-privateBrowsing-disallowed-footer"), "Private browsing footer should be hidden");
+      checkIsDisallowed(true);
     } else {
       // This assumes PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS, we test other options in a later test in this file.
-      is_element_visible(get("detail-privateBrowsing-row"), "Private browsing should be visible");
-      is_element_visible(get("detail-privateBrowsing-row-footer"), "Private browsing footer should be visible");
-      let privateBrowsing = gManagerWindow.document.getElementById("detail-privateBrowsing");
+      checkIsModifiable(true);
       if (definition.incognitoOverride == "spanning") {
-        is(privateBrowsing.value, "1", "Private browsing should be on");
+        is(getPrivateBrowsingValue(), "1", "Private browsing should be on");
         ok(await hasPrivateAllowed(id), "Private browsing permission set");
-        EventUtils.synthesizeMouseAtCenter(privateBrowsing.lastChild, { clickCount: 1 }, gManagerWindow);
-        await TestUtils.waitForCondition(() => privateBrowsing.value == "0");
-        is(privateBrowsing.value, "0", "Private browsing should be off");
+        await setPrivateBrowsingValue("0");
+        is(getPrivateBrowsingValue(), "0", "Private browsing should be off");
         ok(!await hasPrivateAllowed(id), "Private browsing permission removed");
       } else {
-        is(privateBrowsing.value, "0", "Private browsing should be off");
+        is(getPrivateBrowsingValue(), "0", "Private browsing should be off");
         ok(!await hasPrivateAllowed(id), "Private browsing permission not set");
-        EventUtils.synthesizeMouseAtCenter(privateBrowsing.firstChild, { clickCount: 1 }, gManagerWindow);
-        await TestUtils.waitForCondition(() => privateBrowsing.value == "1");
-        is(privateBrowsing.value, "1", "Private browsing should be on");
+        await setPrivateBrowsingValue("1");
+        is(getPrivateBrowsingValue(), "1", "Private browsing should be on");
         ok(await hasPrivateAllowed(id), "Private browsing permission set");
       }
     }
     await close_manager(gManagerWindow);
   }
 
   for (let extension of extensions) {
     await extension.unload();
@@ -140,19 +248,19 @@ add_task(async function test_addon() {
 
   assertTelemetryMatches([
     ["action", "aboutAddons", "on", {...expectedExtras, addonId: "@test-default"}],
     ["action", "aboutAddons", "off", {...expectedExtras, addonId: "@test-override"}],
     ["action", "aboutAddons", "off", {...expectedExtras, addonId: "@test-override-permanent"}],
   ], {filterMethods: ["action"]});
 
   Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
-});
+}
 
-add_task(async function test_addon_preferences_button() {
+async function test_addon_preferences_button() {
   await SpecialPowers.pushPrefEnv({set: [["extensions.allowPrivateBrowsingByDefault", false]]});
 
   let addons = new Map([
     ["test-inline-options@mozilla.com", {
       useAddonManager: "temporary",
       manifest: {
         name: "Extension with inline options",
         applications: {gecko: {id: "test-inline-options@mozilla.com"}},
@@ -181,115 +289,112 @@ add_task(async function test_addon_prefe
   async function runTest(openInPrivateWin) {
     const win = await BrowserTestUtils.openNewBrowserWindow({
       private: openInPrivateWin,
     });
 
     gManagerWindow = await open_manager(
       "addons://list/extension", undefined, undefined, undefined, win);
 
-    const doc = gManagerWindow.document;
     const checkPrefsVisibility = (id, hasInlinePrefs, expectVisible) => {
       if (!hasInlinePrefs) {
-        const detailsPrefBtn = doc.getElementById("detail-prefs-btn");
+        const detailsPrefBtn = getPreferencesButtonAtDetailsView();
         is(!detailsPrefBtn.hidden, expectVisible,
            `The ${id} prefs button in the addon details has the expected visibility`);
       } else {
-        const hasInlineOptionsBrowser = !!doc.getElementById("addon-options");
-        is(hasInlineOptionsBrowser, expectVisible,
+        is(isInlineOptionsVisible(), expectVisible,
            `The ${id} inline prefs in the addon details has the expected visibility`);
       }
     };
 
     const setAddonPrivateBrowsingAccess = async (id, allowPrivateBrowsing) => {
-      const privateBrowsing = doc.getElementById("detail-privateBrowsing");
-
-      is(privateBrowsing.value,
+      let cardUpdatedPromise;
+      if (gManagerWindow.useHtmlViews) {
+        cardUpdatedPromise = BrowserTestUtils.waitForEvent(getHtmlElem("addon-card"), "update");
+      } else {
+        cardUpdatedPromise = BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged");
+      }
+      is(getPrivateBrowsingValue(),
          allowPrivateBrowsing ? "0" : "1",
          `Private browsing should be initially ${allowPrivateBrowsing ? "off" : "on"}`);
 
       // Get the DOM element we want to click on (to allow or disallow the
       // addon on private browsing windows).
-      const controlEl = allowPrivateBrowsing ?
-        privateBrowsing.firstChild : privateBrowsing.lastChild;
-
-      EventUtils.synthesizeMouseAtCenter(controlEl, { clickCount: 1 }, gManagerWindow);
+      await setPrivateBrowsingValue(allowPrivateBrowsing ? "1" : "0");
 
-      // Wait the private browsing access to be reflected in the about:addons
-      // addon details page.
-      await TestUtils.waitForCondition(
-        () => privateBrowsing.value == allowPrivateBrowsing ? "1" : "0",
-        "Waiting privateBrowsing value to be updated");
+      info(`Waiting for details view of ${id} to be reloaded`);
+      await cardUpdatedPromise;
 
-      is(privateBrowsing.value,
+      is(getPrivateBrowsingValue(),
          allowPrivateBrowsing ? "1" : "0",
          `Private browsing should be initially ${allowPrivateBrowsing ? "on" : "off"}`);
 
       is(await hasPrivateAllowed(id), allowPrivateBrowsing,
          `Private browsing permission ${allowPrivateBrowsing ? "added" : "removed"}`);
+      if (gManagerWindow.useHtmlViews) {
+        let badge = getPrivateBrowsingBadge(getHtmlElem("addon-card"));
+        is(!badge.hidden, allowPrivateBrowsing, `Expected private browsing badge at ${id}`);
+      }
     };
 
     const extensions = [];
     for (const definition of addons.values()) {
       const extension = ExtensionTestUtils.loadExtension(definition);
       extensions.push(extension);
       await extension.startup();
     }
 
     const items = get_test_items();
 
-    for (const [id, definition] of addons.entries()) {
+    for (const id of addons.keys()) {
       // Check the preferences button in the addon list page.
-      is(items[id]._preferencesBtn.hidden, openInPrivateWin,
+      is(getPreferencesButtonAtListView(items[id]).hidden, openInPrivateWin,
         `The ${id} prefs button in the addon list has the expected visibility`);
+    }
 
+    for (const [id, definition] of addons.entries()) {
       // Check the preferences button or inline frame in the addon
       // details page.
       info(`Opening addon details for ${id}`);
       const hasInlinePrefs = !definition.manifest.options_ui.open_in_tab;
       const onceViewChanged = BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged");
       gManagerWindow.loadView(`addons://detail/${encodeURIComponent(id)}`);
       await onceViewChanged;
 
       checkPrefsVisibility(id, hasInlinePrefs, !openInPrivateWin);
 
       // While testing in a private window, also check that the preferences
       // are going to be visible when we toggle the PB access for the addon.
       if (openInPrivateWin && definition.manifest.incognito !== "not_allowed") {
-        await Promise.all([
-          BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged"),
-          setAddonPrivateBrowsingAccess(id, true),
-        ]);
+        await setAddonPrivateBrowsingAccess(id, true);
         checkPrefsVisibility(id, hasInlinePrefs, true);
 
-        await Promise.all([
-          BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged"),
-          setAddonPrivateBrowsingAccess(id, false),
-        ]);
+        await setAddonPrivateBrowsingAccess(id, false);
         checkPrefsVisibility(id, hasInlinePrefs, false);
       }
     }
 
     for (const extension of extensions) {
       await extension.unload();
     }
 
     await close_manager(gManagerWindow);
     await BrowserTestUtils.closeWindow(win);
   }
 
   // run tests in private and non-private windows.
   await runTest(true);
   await runTest(false);
-});
+}
 
-add_task(async function test_addon_postinstall_incognito_hidden_checkbox() {
+async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
   await SpecialPowers.pushPrefEnv({set: [
     ["extensions.allowPrivateBrowsingByDefault", false],
     ["extensions.langpacks.signatures.required", false],
+    ["extensions.htmlaboutaddons.enabled", withHtmlViews],
   ]});
 
   const TEST_ADDONS = [
     {
       manifest: {
         name: "Extension incognito default opt-in",
         applications: {gecko: {id: "ext-incognito-default-opt-in@mozilla.com"}},
       },
@@ -368,28 +473,70 @@ add_task(async function test_addon_posti
     } else {
       ok(!canChangePBAccess, `${id} should not have the PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS permission`);
     }
 
     // This tests the visibility of various private detail rows.
     gManagerWindow = await open_manager("addons://detail/" + encodeURIComponent(id));
     info(`addon ${id} detail opened`);
     if (addon.type === "extension") {
-      is(!is_hidden(get("detail-privateBrowsing-row")), canChangePBAccess, "Private permission row visibility is correct");
-      is(!is_hidden(get("detail-privateBrowsing-row-footer")), canChangePBAccess, "Private permission footer visibility is correct");
+      checkIsModifiable(canChangePBAccess);
       let required = addon.incognito === "spanning";
-      is(!is_hidden(get("detail-privateBrowsing-required")), !canChangePBAccess && required, "Private required row visibility is correct");
-      is(!is_hidden(get("detail-privateBrowsing-required-footer")), !canChangePBAccess && required, "Private required footer visibility is correct");
-      is(!is_hidden(get("detail-privateBrowsing-disallowed")), !canChangePBAccess && !required, "Private disallowed row visibility is correct");
-      is(!is_hidden(get("detail-privateBrowsing-disallowed-footer")), !canChangePBAccess && !required, "Private disallowed footer visibility is correct");
+      checkIsRequired(!canChangePBAccess && required);
+      checkIsDisallowed(!canChangePBAccess && !required);
     } else {
-      is_element_hidden(get("detail-privateBrowsing-row"), "Private browsing should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-row-footer"), "Private browsing footer should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-required"), "Private required should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-required-footer"), "Private required footer should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-disallowed"), "Private disallowed should be hidden");
-      is_element_hidden(get("detail-privateBrowsing-disallowed-footer"), "Private disallowed footer should be hidden");
+      checkIsModifiable(false);
+      checkIsRequired(false);
+      checkIsDisallowed(false);
     }
     await close_manager(gManagerWindow);
 
     await addon.uninstall();
   }
+  // No popPrefEnv because of bug 1557397.
+}
+
+
+add_task(async function test_badge_and_toggle_incognito_on_XUL_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", false]],
+  });
+  await test_badge_and_toggle_incognito();
+  // No popPrefEnv because of bug 1557397.
 });
+
+add_task(async function test_badge_and_toggle_incognito_on_HTML_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", true]],
+  });
+  await test_badge_and_toggle_incognito();
+  // No popPrefEnv because of bug 1557397.
+});
+
+add_task(async function test_addon_preferences_button_on_XUL_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["extensions.htmlaboutaddons.enabled", false],
+      ["extensions.htmlaboutaddons.inline-options.enabled", false],
+    ],
+  });
+  await test_addon_preferences_button();
+  // No popPrefEnv because of bug 1557397.
+});
+
+add_task(async function test_addon_preferences_button_on_HTML_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["extensions.htmlaboutaddons.enabled", true],
+      ["extensions.htmlaboutaddons.inline-options.enabled", true],
+    ],
+  });
+  await test_addon_preferences_button();
+  // No popPrefEnv because of bug 1557397.
+});
+
+add_task(async function test_addon_postinstall_incognito_hidden_checkbox_on_XUL_aboutaddons() {
+  await test_addon_postinstall_incognito_hidden_checkbox(false);
+});
+
+add_task(async function test_addon_postinstall_incognito_hidden_checkbox_on_HTML_aboutaddons() {
+  await test_addon_postinstall_incognito_hidden_checkbox(true);
+});