Bug 1565177 - Temporarily remove Thunderbird additions to about:addons, and update a broken test. rs=bustage-fix,jorgk
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 11 Jul 2019 15:03:15 +0200
changeset 36215 cfbd315d507e5f539dd862e324aed51cb9a5b6b2
parent 36214 ba31676a4f3d301d291a08ac9398b02827a149b8
child 36216 2f5aab4c890282d822d0a12d3c7e80f4125358a8
push id394
push userclokep@gmail.com
push dateMon, 21 Oct 2019 20:22:01 +0000
reviewersbustage-fix, jorgk
bugs1565177
Bug 1565177 - Temporarily remove Thunderbird additions to about:addons, and update a broken test. rs=bustage-fix,jorgk
.eslintignore
mail/app/profile/all-thunderbird.js
mail/base/content/specialTabs.js
mail/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -81,8 +81,12 @@ mail/locales/en-US/all-l10n.js
 
 # prefs files
 calendar/lightning/content/lightning.js
 calendar/providers/gdata/defaults/preferences.js
 calendar/timezones/preferences.js
 
 # third party library
 calendar/base/modules/ical.js
+
+# Temporarily disabled: see bug 1565177
+mail/base/content/aboutAddonsExtra.js
+mail/base/content/extensions.xml
--- a/mail/app/profile/all-thunderbird.js
+++ b/mail/app/profile/all-thunderbird.js
@@ -778,11 +778,8 @@ pref("intl.regional_prefs.use_os_locales
 // Multi-lingual preferences
 pref("intl.multilingual.enabled", false);
 
 // We don't support yet language pack download from ATN
 pref("intl.multilingual.downloadEnabled", false);
 
 // Dark in-content pages
 pref("browser.in-content.dark-mode", false);
-
-// Disable new about:addons page for now. See bug 1558860.
-pref("extensions.htmlaboutaddons.enabled", false);
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -277,20 +277,16 @@ var contentTabBaseType = {
   // Code to run if a particular document is loaded in a tab.
   // The array members (functions) are for the respective document URLs
   // as specified in inContentWhitelist.
   inContentOverlays: [
     // about:addons
     function(aDocument, aTab) {
       // Switch off the context menu.
       aTab.browser.removeAttribute("context");
-
-      Services.scriptloader.loadSubScript(
-        "chrome://messenger/content/aboutAddonsExtra.js", aDocument.defaultView
-      );
     },
 
     // Let's not mess with about:blank.
     null,
 
     // Other about:* pages.
     function(aDocument, aTab) {
       // Provide context menu for about:* pages.
--- a/mail/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
+++ b/mail/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
@@ -1,137 +1,138 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
-const addonID = "policytest@mozilla.com";
-const BASE_URL = "http://mochi.test:8888/browser/comm/mail/components/enterprisepolicies/tests/browser";
+const ADDON_ID = "policytest@mozilla.com";
+const BASE_URL =
+  "http://mochi.test:8888/browser/comm/mail/components/enterprisepolicies/tests/browser";
+
+async function isExtensionLocked(win, addonID) {
+  let addonCard = await BrowserTestUtils.waitForCondition(async () => {
+    let doc = win.getHtmlBrowser().contentDocument;
+    await win.htmlBrowserLoaded;
+    return doc.querySelector(`addon-card[addon-id="${addonID}"]`);
+  }, `Get addon-card for "${addonID}"`);
+  let disableBtn = addonCard.querySelector(
+    'panel-item[action="toggle-disabled"]'
+  );
+  let removeBtn = addonCard.querySelector('panel-item[action="remove"]');
+  ok(removeBtn.hidden, "Remove button should be hidden");
+  ok(disableBtn.hidden, "Disable button should be hidden");
+}
 
 add_task(async function test_addon_install() {
   let installPromise = wait_for_addon_install();
   await setupPolicyEngineWithJson({
-    "policies": {
-      "Extensions": {
-        "Install": [
-          `${BASE_URL}/policytest_v0.1.xpi`,
-        ],
-        "Locked": [
-          addonID,
-        ],
+    policies: {
+      Extensions: {
+        Install: [`${BASE_URL}/policytest_v0.1.xpi`],
+        Locked: [ADDON_ID],
       },
     },
   });
   await installPromise;
-  let addon = await AddonManager.getAddonByID(addonID);
+  let addon = await AddonManager.getAddonByID(ADDON_ID);
   isnot(addon, null, "Addon not installed.");
   is(addon.version, "0.1", "Addon version is correct");
 
-  Assert.deepEqual(addon.installTelemetryInfo, {source: "enterprise-policy"},
-                   "Got the expected addon.installTelemetryInfo");
+  Assert.deepEqual(
+    addon.installTelemetryInfo,
+    { source: "enterprise-policy" },
+    "Got the expected addon.installTelemetryInfo"
+  );
 });
 
 add_task(async function test_addon_locked() {
   let tabmail = document.getElementById("tabmail");
   let index = tabmail.tabInfo.length;
   window.openAddonsMgr("addons://list/extension");
   let tab = tabmail.tabInfo[index];
   let browser = tab.browser;
 
-  await BrowserTestUtils.waitForCondition(async function() {
-    return ContentTask.spawn(browser, null, async function() {
-      return content.document.documentURI.startsWith("about:addons") &&
-             content.document.readyState == "complete";
-    });
-  });
-
-  await ContentTask.spawn(browser, {addonID}, async function({addonID}) {
-    let list = content.document.getElementById("addon-list");
-    let flashEntry = list.getElementsByAttribute("value", addonID)[0];
-    let disableBtn = content.document.getAnonymousElementByAttribute(flashEntry, "anonid", "disable-btn");
-    let removeBtn = content.document.getAnonymousElementByAttribute(flashEntry, "anonid", "remove-btn");
-    is(removeBtn.hidden, true, "Remove button should be hidden");
-    is(disableBtn.hidden, true, "Disable button should be hidden");
-  });
+  await isExtensionLocked(browser.contentWindow, ADDON_ID);
 
   tabmail.closeTab(tab);
 });
 
 add_task(async function test_addon_reinstall() {
   // Test that uninstalling and reinstalling the same addon ID works as expected.
   // This can be used to update an addon.
 
   let uninstallPromise = wait_for_addon_uninstall();
   let installPromise = wait_for_addon_install();
   await setupPolicyEngineWithJson({
-    "policies": {
-      "Extensions": {
-        "Uninstall": [
-          addonID,
-        ],
-        "Install": [
-          `${BASE_URL}/policytest_v0.2.xpi`,
-        ],
+    policies: {
+      Extensions: {
+        Uninstall: [ADDON_ID],
+        Install: [`${BASE_URL}/policytest_v0.2.xpi`],
       },
     },
   });
 
   // Older version was uninstalled
   await uninstallPromise;
 
   // New version was installed
   await installPromise;
 
-  let addon = await AddonManager.getAddonByID(addonID);
-  isnot(addon, null, "Addon still exists because the policy was used to update it.");
+  let addon = await AddonManager.getAddonByID(ADDON_ID);
+  isnot(
+    addon,
+    null,
+    "Addon still exists because the policy was used to update it."
+  );
   is(addon.version, "0.2", "New version is correct");
 });
 
-
 add_task(async function test_addon_uninstall() {
   EnterprisePolicyTesting.resetRunOnceState();
 
   let uninstallPromise = wait_for_addon_uninstall();
   await setupPolicyEngineWithJson({
-    "policies": {
-      "Extensions": {
-        "Uninstall": [
-          addonID,
-        ],
+    policies: {
+      Extensions: {
+        Uninstall: [ADDON_ID],
       },
     },
   });
   await uninstallPromise;
-  let addon = await AddonManager.getAddonByID(addonID);
+  let addon = await AddonManager.getAddonByID(ADDON_ID);
   is(addon, null, "Addon should be uninstalled.");
 });
 
 add_task(async function test_addon_download_failure() {
   // Test that if the download fails, the runOnce pref
-  // is cleared so that the dowbnload will happen again
+  // is cleared so that the download will happen again.
 
   let installPromise = wait_for_addon_install();
   await setupPolicyEngineWithJson({
-    "policies": {
-      "Extensions": {
-        "Install": [
-          `${BASE_URL}/policytest_invalid.xpi`,
-        ],
+    policies: {
+      Extensions: {
+        Install: [`${BASE_URL}/policytest_invalid.xpi`],
       },
     },
   });
 
   await installPromise;
-  is(Services.prefs.prefHasUserValue("browser.policies.runOncePerModification.extensionsInstall"), false, "runOnce pref should be unset");
+  is(
+    Services.prefs.prefHasUserValue(
+      "browser.policies.runOncePerModification.extensionsInstall"
+    ),
+    false,
+    "runOnce pref should be unset"
+  );
 });
 
 function wait_for_addon_install() {
   return new Promise(resolve => {
     let listener = {
       onInstallEnded(install, addon) {
-        if (addon.id == addonID) {
+        if (addon.id == ADDON_ID) {
           AddonManager.removeInstallListener(listener);
           resolve();
         }
       },
       onDownloadFailed() {
         AddonManager.removeInstallListener(listener);
         resolve();
       },
@@ -140,19 +141,19 @@ function wait_for_addon_install() {
         resolve();
       },
     };
     AddonManager.addInstallListener(listener);
   });
 }
 
 function wait_for_addon_uninstall() {
- return new Promise(resolve => {
+  return new Promise(resolve => {
     let listener = {};
     listener.onUninstalled = addon => {
-      if (addon.id == addonID) {
+      if (addon.id == ADDON_ID) {
         AddonManager.removeAddonListener(listener);
         resolve();
       }
     };
     AddonManager.addAddonListener(listener);
   });
 }