Bug 1628625 - Fix uncaught exception in preferences tests. r=mkmelin DONTBUILD
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 14 Apr 2020 13:56:49 +0300
changeset 38820 ddff38db03687e1ae6320732ec0fa3b7542d4aaf
parent 38819 c5eb775788e3e0e6d0254b580e5f04fa15324317
child 38821 4a6f4e4423980eebe6e78951c433a4ae0849725e
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersmkmelin
bugs1628625
Bug 1628625 - Fix uncaught exception in preferences tests. r=mkmelin DONTBUILD And spell quarantine correctly.
mail/base/content/utilityOverlay.js
mail/components/preferences/preferences.js
mail/components/preferences/preferencesTab.js
mail/components/preferences/privacy.inc.xhtml
mail/components/preferences/test/browser/browser_privacy.js
mail/components/preferences/test/browser/browser_security.js
--- a/mail/base/content/utilityOverlay.js
+++ b/mail/base/content/utilityOverlay.js
@@ -309,25 +309,17 @@ function openContentTab(url, where, hand
 function openPreferencesTab(paneID, scrollPaneTo, otherArgs) {
   let url = "about:preferences";
   let params = {
     contentPage: url,
     paneID,
     scrollPaneTo,
     otherArgs,
     onLoad(aEvent, aBrowser) {
-      let prefWindow = aBrowser.contentDocument.getElementById(
-        "MailPreferences"
-      );
-      aBrowser.contentWindow.selectPrefPane(
-        prefWindow,
-        paneID,
-        scrollPaneTo,
-        otherArgs
-      );
+      aBrowser.contentWindow.selectPrefPane(paneID, scrollPaneTo, otherArgs);
     },
   };
   openTab("preferencesTab", params);
 }
 
 /**
  * Open the dictionary list in a new content tab, if possible in an available
  * mail:3pane window, otherwise by opening a new mail:3pane.
--- a/mail/components/preferences/preferences.js
+++ b/mail/components/preferences/preferences.js
@@ -115,22 +115,21 @@ function showPane(paneID) {
 
   document.documentElement.setAttribute("lastSelected", paneID);
   Services.xulStore.persist(document.documentElement, "lastSelected");
 }
 
 /**
  * Selects the specified preferences pane
  *
- * @param prefWindow          the prefwindow element to operate on
  * @param paneID              ID of prefpane to select
  * @param scrollPaneTo        ID of the element to scroll into view
  * @param otherArgs.subdialog ID of button to activate, opening a subdialog
  */
-function selectPrefPane(prefWindow, paneID, scrollPaneTo, otherArgs) {
+function selectPrefPane(paneID, scrollPaneTo, otherArgs) {
   if (paneID) {
     let prefPane = document.getElementById(paneID);
     if (getCurrentPaneID() != paneID) {
       showPane(paneID);
     }
     if (scrollPaneTo) {
       showTab(
         prefPane,
--- a/mail/components/preferences/preferencesTab.js
+++ b/mail/components/preferences/preferencesTab.js
@@ -47,21 +47,17 @@ var preferencesTabType = {
     let tabmail = document.getElementById("tabmail");
     tabmail.registerTabType(this);
   },
 
   shouldSwitchTo(aArgs) {
     if (!gPrefTab) {
       return -1;
     }
-    let prefWindow = gPrefTab.browser.contentDocument.getElementById(
-      "MailPreferences"
-    );
     gPrefTab.browser.contentWindow.selectPrefPane(
-      prefWindow,
       aArgs.paneID,
       aArgs.scrollPaneTo,
       aArgs.otherArgs
     );
     return document.getElementById("tabmail").tabInfo.indexOf(gPrefTab);
   },
 
   closeTab(aTab) {
@@ -117,17 +113,20 @@ var preferencesTabType = {
       function(event) {
         aTab.pageLoading = false;
         aTab.pageLoaded = true;
 
         if ("onLoad" in aArgs) {
           // Let selection of the initial pane complete before selecting another.
           // Otherwise we can end up with two panes selected at once.
           setTimeout(() => {
-            aArgs.onLoad(event, aTab.browser);
+            // By now, the tab could already be closed. Check that it isn't.
+            if (aTab.panel) {
+              aArgs.onLoad(event, aTab.browser);
+            }
           }, 0);
         }
       },
       { once: true }
     );
 
     // Initialize our unit testing variables.
     aTab.pageLoading = true;
--- a/mail/components/preferences/privacy.inc.xhtml
+++ b/mail/components/preferences/privacy.inc.xhtml
@@ -254,17 +254,17 @@
     </html:fieldset>
 
     <!-- Anti Virus -->
     <html:fieldset data-category="panePrivacy">
       <html:legend data-l10n-id="privacy-anti-virus-title"></html:legend>
       <description>&antiVirus.intro;</description>
       <separator class="thin"/>
       <hbox>
-        <checkbox id="enableAntiVirusQuaruntine"
+        <checkbox id="enableAntiVirusQuarantine"
                   label="&antiVirus.label;"
                   accesskey="&antiVirus.accesskey;"
                   preference="mailnews.downloadToTempFile"/>
         <spacer flex="1"/>
       </hbox>
     </html:fieldset>
 
     <html:fieldset data-category="panePrivacy">
--- a/mail/components/preferences/test/browser/browser_privacy.js
+++ b/mail/components/preferences/test/browser/browser_privacy.js
@@ -48,18 +48,18 @@ add_task(async () => {
     }
   );
 
   await testCheckboxes("panePrivacy", "privacySecurityCategory", {
     checkboxID: "enablePhishingDetector",
     pref: "mail.phishing.detection.enabled",
   });
 
-  await testCheckboxes("panePrivacy", "enableAntiVirusQuaruntine", {
-    checkboxID: "enableAntiVirusQuaruntine",
+  await testCheckboxes("panePrivacy", "enableAntiVirusQuarantine", {
+    checkboxID: "enableAntiVirusQuarantine",
     pref: "mailnews.downloadToTempFile",
   });
 });
 
 add_task(async () => {
   Services.prefs.setBoolPref("mail.spam.manualMark", true);
 
   await testRadioButtons("panePrivacy", "privacyJunkCategory", {
--- a/mail/components/preferences/test/browser/browser_security.js
+++ b/mail/components/preferences/test/browser/browser_security.js
@@ -23,17 +23,17 @@ add_task(async () => {
   );
 
   await testCheckboxes("paneSecurity", "phishingTab", {
     checkboxID: "enablePhishingDetector",
     pref: "mail.phishing.detection.enabled",
   });
 
   await testCheckboxes("paneSecurity", "antiVirusTab", {
-    checkboxID: "enableAntiVirusQuaruntine",
+    checkboxID: "enableAntiVirusQuarantine",
     pref: "mailnews.downloadToTempFile",
   });
 });
 
 add_task(async () => {
   Services.prefs.setBoolPref("mail.spam.manualMark", true);
 
   await testRadioButtons("paneSecurity", "junkTab", {