Bug 1578463 - Mop up ondialogaccept in mail(news). r=aceman,jorgk a=jorgk THUNDERBIRD_70_0b1_BUILD2 THUNDERBIRD_70_0b1_RELEASE
authorIan Neal <iann_cvs@blueyonder.co.uk>
Mon, 09 Sep 2019 09:35:12 +0200
changeset 35752 ab0554e7ca10f0496458892ad0a66b6a3aca43bb
parent 35751 344b5b374a1ddaaa9a5bdf66b37b7c9ace7f0e35
child 35753 d353cae3d8a9e01b41fb5e1adb8bc9bfbcefd3a7
push id2491
push usermozilla@jorgk.com
push dateMon, 09 Sep 2019 17:59:08 +0000
treeherdercomm-beta@ab0554e7ca10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk, jorgk
bugs1578463
Bug 1578463 - Mop up ondialogaccept in mail(news). r=aceman,jorgk a=jorgk
mail/components/addrbook/content/abCard.js
mail/components/addrbook/content/abEditCardDialog.xul
mail/components/addrbook/content/abEditListDialog.xul
mail/components/cloudfile/content/selectDialog.xul
mailnews/addrbook/content/abAddressBookNameDialog.js
mailnews/addrbook/content/abMailListDialog.js
mailnews/extensions/smime/content/am-smime.js
--- a/mail/components/addrbook/content/abCard.js
+++ b/mail/components/addrbook/content/abCard.js
@@ -349,20 +349,21 @@ function OnLoadEditCard() {
 
         // Also disable the mail format popup and allow remote content items.
         document.getElementById("PreferMailFormatPopup").disabled = true;
 
         // And the "prefer display name" checkbox
         document.getElementById("preferDisplayName").disabled = true;
 
         document.documentElement.buttons = "accept";
-        document.documentElement.removeAttribute("ondialogaccept");
+        return;
       }
     }
   }
+  document.addEventListener("dialogaccept", EditCardOKButton);
 }
 
 /* Registers functions that are called when loading the card
  * values into the contact editor dialog.  This is useful if
  * extensions have added extra fields to the nsIAbCard, and
  * need to display them in the contact editor.
  */
 function RegisterLoadListener(aFunc) {
--- a/mail/components/addrbook/content/abEditCardDialog.xul
+++ b/mail/components/addrbook/content/abEditCardDialog.xul
@@ -17,15 +17,14 @@
 
   <stringbundleset id="stringbundleset">
     <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
   </stringbundleset>
 
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
   <script src="chrome://messenger/content/addressbook/abCard.js"/>
   <script><![CDATA[
-    document.addEventListener("dialogaccept", EditCardOKButton);
     document.addEventListener("dialogcancel", EditCardCancelButton);
   ]]></script>
 
 #include abCard.inc.xul
 
 </dialog>
--- a/mail/components/addrbook/content/abEditListDialog.xul
+++ b/mail/components/addrbook/content/abEditListDialog.xul
@@ -17,19 +17,16 @@
   <stringbundleset id="stringbundleset">
     <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
   </stringbundleset>
 
   <!-- move needed functions into a single js file -->
   <script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
   <script src="chrome://messenger/content/addressbook/abMailListDialog.js"/>
-  <script><![CDATA[
-    document.addEventListener("dialogaccept", EditListOKButton);
-  ]]></script>
 
   <vbox id="editlist">
     <hbox id="ListNameContainer" align="center">
       <spacer flex="1"/>
       <label control="ListName" value="&ListName.label;" accesskey="&ListName.accesskey;" class="CardEditLabel"/>
       <hbox class="CardEditWidth">
         <textbox id="ListName" flex="1"/>
       </hbox>
--- a/mail/components/cloudfile/content/selectDialog.xul
+++ b/mail/components/cloudfile/content/selectDialog.xul
@@ -4,18 +4,17 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, you can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/content/cloudfile/selectDialog.css" type="text/css"?>
 <!DOCTYPE dialog SYSTEM "chrome://global/locale/commonDialog.dtd">
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      onload="cloudfileDialogOnLoad()"
-      ondialogaccept="return dialogOK();">
+      onload="cloudfileDialogOnLoad();">
 
   <script type="application/javascript" src="chrome://messenger/content/cloudfile/selectDialog.js" />
   <script type="application/javascript" src="chrome://global/content/selectDialog.js" />
   <keyset id="dialogKeys"/>
   <vbox style="width: 24em;margin: 5px;">
     <label id="info.txt"/>
     <vbox>
       <richlistbox id="list" class="theme-listbox" style="height: 8em;"/>
--- a/mailnews/addrbook/content/abAddressBookNameDialog.js
+++ b/mailnews/addrbook/content/abAddressBookNameDialog.js
@@ -14,18 +14,16 @@ var gOkButton;
 var gNameInput;
 var gDirectory = null;
 
 var kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
 var kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab";
 var kAllDirectoryRoot = "moz-abdirectory://";
 var kPABDirectory = 2; // defined in nsDirPrefs.h
 
-document.addEventListener("dialogaccept", abNameOKButton);
-
 function abNameOnLoad() {
   // Get the document elements.
   gOkButton = document.documentElement.getButton("accept");
   gNameInput = document.getElementById("name");
 
   // look in arguments[0] for parameters to see if we have a directory or not
   if (
     "arguments" in window &&
@@ -54,18 +52,18 @@ function abNameOnLoad() {
     (gDirectory.URI == kCollectedAddressbookURI ||
       gDirectory.URI == kPersonalAddressbookURI ||
       gDirectory.URI == kAllDirectoryRoot + "?")
   ) {
     // Address book name is not editable, therefore disable the field and
     // only have an ok button that doesn't do anything.
     gNameInput.readOnly = true;
     document.documentElement.buttons = "accept";
-    document.documentElement.removeAttribute("ondialogaccept");
   } else {
+    document.addEventListener("dialogaccept", abNameOKButton);
     gNameInput.focus();
     abNameDoOkEnabling();
   }
 }
 
 function abNameOKButton(event) {
   var newName = gNameInput.value.trim();
 
--- a/mailnews/addrbook/content/abMailListDialog.js
+++ b/mailnews/addrbook/content/abMailListDialog.js
@@ -280,23 +280,24 @@ function OnLoadEditList() {
   if (gEditList.readOnly) {
     const kMailListFields = ["ListName", "ListNickName", "ListDescription"];
 
     for (let i = 0; i < kMailListFields.length; ++i) {
       document.getElementById(kMailListFields[i]).readOnly = true;
     }
 
     document.documentElement.buttons = "accept";
-    document.documentElement.removeAttribute("ondialogaccept");
 
     // Getting a sane read-only implementation for the addressing widget would
     // basically need a separate dialog. Given I'm not sure about the future of
     // the mailing list dialog in its current state, let's just disable it
     // completely.
     document.getElementById("addressingWidget").disabled = true;
+  } else {
+    document.addEventListener("dialogaccept", EditListOKButton);
   }
 
   if (AppConstants.MOZ_APP_NAME == "seamonkey") {
     document.addEventListener("keypress", awDocumentKeyPress, true);
   }
 
   // workaround for bug 118337 - for mailing lists that have more rows than fits inside
   // the display, the value of the textbox inside the new row isn't inherited into the input -
--- a/mailnews/extensions/smime/content/am-smime.js
+++ b/mailnews/extensions/smime/content/am-smime.js
@@ -24,18 +24,16 @@ var gNeverEncrypt = null;
 var gBundle = null;
 var gBrandBundle;
 var gSmimePrefbranch;
 var gEncryptionChoicesLocked;
 var gSigningChoicesLocked;
 var kEncryptionCertPref = "identity.encryption_cert_name";
 var kSigningCertPref = "identity.signing_cert_name";
 
-document.addEventListener("dialogaccept", smimeOnAcceptEditor);
-
 function onInit() {
   smimeInitializeFields();
 }
 
 function smimeInitializeFields() {
   // initialize all of our elements based on the current identity values....
   gEncryptionCertName = document.getElementById(kEncryptionCertPref);
   gHiddenEncryptionPolicy = document.getElementById(
@@ -518,14 +516,10 @@ function openDeviceManager() {
       "",
       "centerscreen,resizable=yes,dialog=no"
     );
   }
 }
 
 function smimeOnLoadEditor() {
   smimeInitializeFields();
-
-  document.documentElement.setAttribute(
-    "ondialogaccept",
-    "return smimeOnAcceptEditor();"
-  );
+  document.addEventListener("dialogaccept", smimeOnAcceptEditor);
 }