Bug 1529231, Remove all occurences of ondialogaccept and ondialogcancel, r=Gijs
authorJonas Allmann <jallmann@mozilla.com>
Tue, 26 Mar 2019 18:34:02 +0000
changeset 466165 8691a4583cae7e73381a844c3d616354671184a9
parent 466164 269654f1eeb2b6e099af2e5e3e48d07bc1488268
child 466166 d25cc097d600ac2423c9b3f13aba671f201376d1
push id35762
push usercsabou@mozilla.com
push dateWed, 27 Mar 2019 04:44:00 +0000
treeherdermozilla-central@bc572aee49b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1529231
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529231, Remove all occurences of ondialogaccept and ondialogcancel, r=Gijs Removed all occurences of ondialogaccept. Removed all occurences of ondialogcancel. Replaced all removed attributes with event handlers. Differential Revision: https://phabricator.services.mozilla.com/D21227
browser/base/content/safeMode.js
browser/base/content/safeMode.xul
browser/base/content/sanitize.xul
browser/base/content/sanitizeDialog.js
browser/components/places/content/bookmarkProperties.js
browser/components/places/content/bookmarkProperties.xul
browser/components/preferences/applicationManager.js
browser/components/preferences/applicationManager.xul
browser/components/preferences/in-content/tests/subdialog.xul
browser/components/preferences/in-content/tests/subdialog2.xul
browser/components/preferences/selectBookmark.js
browser/components/preferences/selectBookmark.xul
browser/components/preferences/siteDataRemoveSelected.js
browser/components/preferences/siteDataRemoveSelected.xul
browser/components/shell/content/setDesktopBackground.js
browser/components/shell/content/setDesktopBackground.xul
devtools/client/webide/content/newapp.js
devtools/client/webide/content/newapp.xul
dom/xul/test/398289-resource.xul
security/manager/pki/resources/content/changepassword.js
security/manager/pki/resources/content/changepassword.xul
security/manager/pki/resources/content/choosetoken.js
security/manager/pki/resources/content/choosetoken.xul
security/manager/pki/resources/content/clientauthask.js
security/manager/pki/resources/content/clientauthask.xul
security/manager/pki/resources/content/deletecert.js
security/manager/pki/resources/content/deletecert.xul
security/manager/pki/resources/content/downloadcert.js
security/manager/pki/resources/content/downloadcert.xul
security/manager/pki/resources/content/editcacert.js
security/manager/pki/resources/content/editcacert.xul
security/manager/pki/resources/content/load_device.js
security/manager/pki/resources/content/load_device.xul
security/manager/pki/resources/content/resetpassword.js
security/manager/pki/resources/content/resetpassword.xul
security/manager/pki/resources/content/setp12password.js
security/manager/pki/resources/content/setp12password.xul
toolkit/components/apppicker/content/appPicker.js
toolkit/components/apppicker/content/appPicker.xul
toolkit/components/printing/content/printPageSetup.js
toolkit/components/printing/content/printPageSetup.xul
toolkit/components/printing/content/printProgress.js
toolkit/components/printing/content/printProgress.xul
toolkit/components/prompts/content/commonDialog.js
toolkit/components/prompts/content/commonDialog.xul
toolkit/components/prompts/content/selectDialog.js
toolkit/components/prompts/content/selectDialog.xul
toolkit/content/resetProfile.js
toolkit/content/resetProfile.xul
toolkit/mozapps/downloads/HelperAppDlg.jsm
toolkit/mozapps/downloads/content/unknownContentType.xul
toolkit/mozapps/extensions/content/blocklist.js
toolkit/mozapps/extensions/content/blocklist.xul
toolkit/mozapps/handling/content/dialog.js
toolkit/mozapps/handling/content/dialog.xul
toolkit/mozapps/preferences/changemp.js
toolkit/mozapps/preferences/changemp.xul
toolkit/mozapps/preferences/removemp.js
toolkit/mozapps/preferences/removemp.xul
toolkit/profile/content/profileDowngrade.js
toolkit/profile/content/profileDowngrade.xul
toolkit/profile/content/profileSelection.js
toolkit/profile/content/profileSelection.xul
--- a/browser/base/content/safeMode.js
+++ b/browser/base/content/safeMode.js
@@ -30,26 +30,26 @@ function showResetDialog() {
   window.openDialog("chrome://global/content/resetProfile.xul", null,
                     "chrome,modal,centerscreen,titlebar,dialog=yes", retVals);
   if (!retVals.reset)
     return;
   resetProfile();
   restartApp();
 }
 
-function onDefaultButton() {
+function onDefaultButton(event) {
   if (defaultToReset) {
+    // Prevent starting into safe mode while restarting.
+    event.preventDefault();
     // Restart to reset the profile.
     resetProfile();
     restartApp();
-    // Return false to prevent starting into safe mode while restarting.
-    return false;
   }
+  // Dialog will be closed by default Event handler.
   // Continue in safe mode. No restart needed.
-  return true;
 }
 
 function onCancel() {
   appStartup.quit(appStartup.eForceQuit);
 }
 
 function onExtra1() {
   if (defaultToReset) {
@@ -70,10 +70,12 @@ function onLoad() {
       // Hide the reset button is it's not supported.
       document.documentElement.getButton("extra1").hidden = true;
     }
   } else if (!ResetProfile.resetSupported()) {
     // Hide the reset button and text if it's not supported.
     document.documentElement.getButton("extra1").hidden = true;
     document.getElementById("resetProfileInstead").hidden = true;
   }
+  document.addEventListener("dialogaccept", onDefaultButton);
+  document.addEventListener("dialogcancel", onCancel);
   document.addEventListener("dialogextra1", onExtra1);
 }
--- a/browser/base/content/safeMode.xul
+++ b/browser/base/content/safeMode.xul
@@ -10,18 +10,16 @@
 <dialog id="safeModeDialog"
             xmlns:html="http://www.w3.org/1999/xhtml"
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
             data-l10n-id="safe-mode-window"
             data-l10n-attrs="title,style"
             buttons="accept,extra1"
             buttonidaccept="start-safe-mode"
             buttonidextra1="refresh-profile"
-            ondialogaccept="return onDefaultButton()"
-            ondialogcancel="onCancel();"
             onload="onLoad()">
 
   <linkset>
     <html:link rel="localization" href="branding/brand.ftl"/>
     <html:link rel="localization" href="browser/safeMode.ftl"/>
   </linkset>
 
   <script type="application/javascript" src="chrome://browser/content/safeMode.js"/>
--- a/browser/base/content/sanitize.xul
+++ b/browser/base/content/sanitize.xul
@@ -17,18 +17,17 @@
 <dialog id="SanitizeDialog" type="child"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         buttons="accept,cancel"
         persist="lastSelected screenX screenY"
         role="dialog"
         data-l10n-id="dialog-title"
         data-l10n-attrs="style"
-        onload="gSanitizePromptDialog.init();"
-        ondialogaccept="return gSanitizePromptDialog.sanitize();">
+        onload="gSanitizePromptDialog.init();">
 
   <linkset>
     <html:link rel="localization" href="browser/sanitize.ftl"/>
   </linkset>
 
   <script type="application/javascript"
           src="chrome://global/content/preferencesBindings.js"/>
   <script type="application/javascript"
--- a/browser/base/content/sanitizeDialog.js
+++ b/browser/base/content/sanitizeDialog.js
@@ -33,16 +33,18 @@ var gSanitizePromptDialog = {
 
   init() {
     // This is used by selectByTimespan() to determine if the window has loaded.
     this._inited = true;
 
     let OKButton = document.documentElement.getButton("accept");
     document.l10n.setAttributes(OKButton, "sanitize-button-ok");
 
+    document.addEventListener("dialogaccept", function(e) { gSanitizePromptDialog.sanitize(e); });
+
     if (this.selectedTimespan === Sanitizer.TIMESPAN_EVERYTHING) {
       this.prepareWarning();
       this.warningBox.hidden = false;
       document.l10n.setAttributes(document.documentElement, "dialog-title-everything");
       let warningDesc = document.getElementById("sanitizeEverythingWarning");
       // Ensure we've translated and sized the warning.
       document.mozSubdialogReady =
         document.l10n.translateFragment(warningDesc).then(() => {
@@ -86,17 +88,17 @@ var gSanitizePromptDialog = {
     // If clearing a specific time range
     if (!warningBox.hidden) {
       window.resizeBy(0, -warningBox.getBoundingClientRect().height);
       warningBox.hidden = true;
     }
     document.l10n.setAttributes(document.documentElement, "dialog-title");
   },
 
-  sanitize() {
+  sanitize(event) {
     // Update pref values before handing off to the sanitizer (bug 453440)
     this.updatePrefs();
 
     // As the sanitize is async, we disable the buttons, update the label on
     // the 'accept' button to indicate things are happening and return false -
     // once the async operation completes (either with or without errors)
     // we close the window.
     let docElt = document.documentElement;
@@ -110,20 +112,19 @@ var gSanitizePromptDialog = {
       let options = {
         ignoreTimespan: !range,
         range,
       };
       Sanitizer.sanitize(null, options)
         .catch(Cu.reportError)
         .then(() => window.close())
         .catch(Cu.reportError);
-      return false;
+      event.preventDefault();
     } catch (er) {
       Cu.reportError("Exception during sanitize: " + er);
-      return true; // We *do* want to close immediately on error.
     }
   },
 
   /**
    * If the panel that displays a warning when the duration is "Everything" is
    * not set up, sets it up.  Otherwise does nothing.
    */
   prepareWarning() {
--- a/browser/components/places/content/bookmarkProperties.js
+++ b/browser/components/places/content/bookmarkProperties.js
@@ -217,16 +217,22 @@ var BookmarkPropertiesPanel = {
   /**
    * This method should be called by the onload of the Bookmark Properties
    * dialog to initialize the state of the panel.
    */
   async onDialogLoad() {
     await this._determineItemInfo();
 
     document.title = this._getDialogTitle();
+    document.addEventListener("dialogaccept", function() {
+      BookmarkPropertiesPanel.onDialogAccept();
+    });
+    document.addEventListener("dialogcancel", function() {
+      BookmarkPropertiesPanel.onDialogCancel();
+    });
 
     // Disable the buttons until we have all the information required.
     let acceptButton = document.documentElement.getButton("accept");
     acceptButton.disabled = true;
 
     // Allow initialization to complete in a truely async manner so that we're
     // not blocking the main thread.
     this._initDialog().catch(ex => {
--- a/browser/components/places/content/bookmarkProperties.xul
+++ b/browser/components/places/content/bookmarkProperties.xul
@@ -12,18 +12,16 @@
 <!DOCTYPE dialog [
   <!ENTITY % editBookmarkOverlayDTD SYSTEM "chrome://browser/locale/places/editBookmarkOverlay.dtd">
   %editBookmarkOverlayDTD;
 ]>
 
 <dialog id="bookmarkproperties"
         buttons="accept, cancel"
         buttoniconaccept="save"
-        ondialogaccept="BookmarkPropertiesPanel.onDialogAccept();"
-        ondialogcancel="BookmarkPropertiesPanel.onDialogCancel();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="BookmarkPropertiesPanel.onDialogLoad();"
         onunload="BookmarkPropertiesPanel.onDialogUnload();"
         style="min-width: 30em;"
         persist="screenX screenY width">
 
   <stringbundleset id="stringbundleset">
     <stringbundle id="stringBundle"
--- a/browser/components/preferences/applicationManager.js
+++ b/browser/components/preferences/applicationManager.js
@@ -11,16 +11,18 @@ var gAppManagerDialog = {
     document.mozSubdialogReady = this.init();
   },
 
   async init() {
     this.handlerInfo = window.arguments[0];
     Services.scriptloader.loadSubScript("chrome://browser/content/preferences/in-content/main.js",
       window);
 
+    document.addEventListener("dialogaccept", function() { gAppManagerDialog.onOK(); });
+
     const appDescElem = document.getElementById("appDescription");
     if (this.handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) {
       document.l10n.setAttributes(appDescElem, "app-manager-handle-file", {
         type: this.handlerInfo.typeDescription,
       });
     } else {
       document.l10n.setAttributes(appDescElem, "app-manager-handle-protocol", {
         type: this.handlerInfo.typeDescription,
@@ -54,29 +56,22 @@ var gAppManagerDialog = {
     // result will impact the size of the subdialog.
     await document.l10n.translateElements([
       appDescElem,
       document.getElementById("appType"),
     ]);
   },
 
   onOK: function appManager_onOK() {
-    if (!this._removed.length) {
-      // return early to avoid calling the |store| method.
-      return;
-    }
+    if (this._removed.length) {
+      for (var i = 0; i < this._removed.length; ++i)
+        this.handlerInfo.removePossibleApplicationHandler(this._removed[i]);
 
-    for (var i = 0; i < this._removed.length; ++i)
-      this.handlerInfo.removePossibleApplicationHandler(this._removed[i]);
-
-    this.handlerInfo.store();
-  },
-
-  onCancel: function appManager_onCancel() {
-    // do nothing
+      this.handlerInfo.store();
+    }
   },
 
   remove: function appManager_remove() {
     var list = document.getElementById("appList");
     this._removed.push(list.selectedItem.app);
     var index = list.selectedIndex;
     var element = list.selectedItem;
     list.removeItemFromSelection(element);
--- a/browser/components/preferences/applicationManager.xul
+++ b/browser/components/preferences/applicationManager.xul
@@ -6,18 +6,16 @@
 <?xml-stylesheet href="chrome://global/skin/"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/applications.css"?>
 
 <dialog id="appManager"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         buttons="accept,cancel"
         onload="gAppManagerDialog.onLoad();"
-        ondialogaccept="gAppManagerDialog.onOK();"
-        ondialogcancel="gAppManagerDialog.onCancel();"
         data-l10n-id="app-manager-window"
         data-l10n-attrs="title, style"
         persist="screenX screenY">
 
   <linkset>
     <html:link rel="localization" href="browser/preferences/applicationManager.ftl"/>
   </linkset>
 
--- a/browser/components/preferences/in-content/tests/subdialog.xul
+++ b/browser/components/preferences/in-content/tests/subdialog.xul
@@ -3,19 +3,19 @@
 <!-- Any copyright is dedicated to the Public Domain.
    - http://creativecommons.org/publicdomain/zero/1.0/ -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog id="subDialog"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Sample sub-dialog" style="width: 32em; height: 5em;"
-        onload="document.getElementById('textbox').focus();"
-        ondialogaccept="acceptSubdialog();">
+        onload="document.getElementById('textbox').focus();">
   <script>
+    document.addEventListener("dialogaccept", acceptSubdialog);
     function acceptSubdialog() {
       window.arguments[0].acceptCount++;
     }
   </script>
 
   <description id="desc">A sample sub-dialog for testing</description>
 
   <textbox id="textbox" value="Default text" />
--- a/browser/components/preferences/in-content/tests/subdialog2.xul
+++ b/browser/components/preferences/in-content/tests/subdialog2.xul
@@ -3,19 +3,19 @@
 <!-- Any copyright is dedicated to the Public Domain.
    - http://creativecommons.org/publicdomain/zero/1.0/ -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog id="subDialog"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Sample sub-dialog #2" style="width: 32em; height: 5em;"
-        onload="document.getElementById('textbox').focus();"
-        ondialogaccept="acceptSubdialog();">
+        onload="document.getElementById('textbox').focus();">
   <script>
+    document.addEventListener("dialogaccept", acceptSubdialog);
     function acceptSubdialog() {
       window.arguments[0].acceptCount++;
     }
   </script>
 
   <description id="desc">A sample sub-dialog for testing</description>
 
   <textbox id="textbox" value="Default text" />
--- a/browser/components/preferences/selectBookmark.js
+++ b/browser/components/preferences/selectBookmark.js
@@ -32,16 +32,17 @@ XPCOMUtils.defineLazyScriptGetter(this, 
  */
 var SelectBookmarkDialog = {
   init: function SBD_init() {
     document.getElementById("bookmarks").place =
       "place:type=" + Ci.nsINavHistoryQueryOptions.RESULTS_AS_ROOTS_QUERY;
 
     // Initial update of the OK button.
     this.selectionChanged();
+    document.addEventListener("dialogaccept", function() { SelectBookmarkDialog.accept(); });
   },
 
   /**
    * Update the disabled state of the OK button as the user changes the
    * selection within the view.
    */
   selectionChanged: function SBD_selectionChanged() {
     var accept = document.documentElement.getButton("accept");
--- a/browser/components/preferences/selectBookmark.xul
+++ b/browser/components/preferences/selectBookmark.xul
@@ -10,18 +10,17 @@
 <?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css"?>
 
 <dialog id="selectBookmarkDialog"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         data-l10n-id="select-bookmark-window"
         data-l10n-attrs="title, style"
         persist="screenX screenY width height" screenX="24" screenY="24"
-        onload="SelectBookmarkDialog.init();"
-        ondialogaccept="SelectBookmarkDialog.accept();">
+        onload="SelectBookmarkDialog.init();">
 
   <linkset>
     <html:link rel="localization" href="browser/preferences/selectBookmark.ftl"/>
   </linkset>
 
   <script type="application/javascript"
           src="chrome://browser/content/preferences/selectBookmark.js"/>
   <script type="application/javascript"
--- a/browser/components/preferences/siteDataRemoveSelected.js
+++ b/browser/components/preferences/siteDataRemoveSelected.js
@@ -15,16 +15,18 @@ let gSiteDataRemoveSelected = {
     for (let host of hosts) {
       let listItem = document.createXULElement("richlistitem");
       let label = document.createXULElement("label");
       label.setAttribute("value", host);
       listItem.appendChild(label);
       fragment.appendChild(listItem);
     }
     list.appendChild(fragment);
+    document.addEventListener("dialogaccept", function() { gSiteDataRemoveSelected.ondialogaccept(); });
+    document.addEventListener("dialogcancel", function() { gSiteDataRemoveSelected.ondialogcancel(); });
   },
 
   ondialogaccept() {
     window.arguments[0].allowed = true;
   },
 
   ondialogcancel() {
     window.arguments[0].allowed = false;
--- a/browser/components/preferences/siteDataRemoveSelected.xul
+++ b/browser/components/preferences/siteDataRemoveSelected.xul
@@ -9,18 +9,16 @@
 <?xml-stylesheet href="chrome://browser/skin/preferences/in-content/siteDataSettings.css" type="text/css"?>
 
 <dialog id="SiteDataRemoveSelectedDialog"
         windowtype="Browser:SiteDataRemoveSelected"
         width="500"
         data-l10n-id="site-data-removing-dialog"
         data-l10n-attrs="title, buttonlabelaccept"
         onload="gSiteDataRemoveSelected.init();"
-        ondialogaccept="gSiteDataRemoveSelected.ondialogaccept(); return true;"
-        ondialogcancel="gSiteDataRemoveSelected.ondialogcancel(); return true;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml">
 
   <linkset>
     <html:link rel="localization" href="browser/preferences/siteDataSettings.ftl"/>
   </linkset>
 
   <hbox>
--- a/browser/components/shell/content/setDesktopBackground.js
+++ b/browser/components/shell/content/setDesktopBackground.js
@@ -34,17 +34,17 @@ var gSetBackground = {
       // Hide fill + fit options if < Win7 since they don't work.
       var version = Services.sysinfo.getProperty("version");
       var isWindows7OrHigher = (parseFloat(version) >= 6.1);
       if (!isWindows7OrHigher) {
         document.getElementById("fillPosition").hidden = true;
         document.getElementById("fitPosition").hidden = true;
       }
     }
-
+    document.addEventListener("dialogaccept", function() { gSetBackground.setDesktopBackground(); });
     // make sure that the correct dimensions will be used
     setTimeout(function(self) {
       self.init(window.arguments[0], window.arguments[1]);
     }, 0, this);
   },
 
   init(aImage, aImageName) {
     this._image = aImage;
--- a/browser/components/shell/content/setDesktopBackground.xul
+++ b/browser/components/shell/content/setDesktopBackground.xul
@@ -21,17 +21,16 @@
         windowtype="Shell:SetDesktopBackground"
 #ifndef XP_MACOSX
         buttons="accept,cancel"
 #else
         buttons="accept"
 #endif
         buttonlabelaccept="&setDesktopBackground.title;"
         onload="gSetBackground.load();"
-        ondialogaccept="gSetBackground.setDesktopBackground();"
         title="&setDesktopBackground.title;"
         style="width: 30em;">
 
 #ifdef XP_MACOSX
 #include ../../../base/content/macWindow.inc.xul
 #endif
 
     <stringbundle id="backgroundBundle"
--- a/devtools/client/webide/content/newapp.js
+++ b/devtools/client/webide/content/newapp.js
@@ -17,16 +17,17 @@ ChromeUtils.defineModuleGetter(this, "Do
 const TEMPLATES_URL = "devtools.webide.templatesURL";
 
 var gTemplateList = null;
 
 window.addEventListener("load", function() {
   const projectNameNode = document.querySelector("#project-name");
   projectNameNode.addEventListener("input", canValidate, true);
   getTemplatesJSON();
+  document.addEventListener("dialogaccept", doOK);
 }, {capture: true, once: true});
 
 function getTemplatesJSON() {
   getJSON(TEMPLATES_URL).then(list => {
     if (!Array.isArray(list)) {
       throw new Error("JSON response not an array");
     }
     if (list.length == 0) {
@@ -75,33 +76,36 @@ function canValidate() {
   const dialogNode = document.querySelector("dialog");
   if (projectNameNode.value.length > 0) {
     dialogNode.removeAttribute("buttondisabledaccept");
   } else {
     dialogNode.setAttribute("buttondisabledaccept", "true");
   }
 }
 
-function doOK() {
+function doOK(event) {
   const projectName = document.querySelector("#project-name").value;
 
   if (!projectName) {
     console.error("No project name");
-    return false;
+    event.preventDefault();
+    return;
   }
 
   if (!gTemplateList) {
     console.error("No template index");
-    return false;
+    event.preventDefault();
+    return;
   }
 
   const templatelistNode = document.querySelector("#templatelist");
   if (templatelistNode.selectedIndex < 0) {
     console.error("No template selected");
-    return false;
+    event.preventDefault();
+    return;
   }
 
   /* Chrome mochitest support */
   const promise = new Promise((resolve, reject) => {
     const testOptions = window.arguments[0].testOptions;
     if (testOptions) {
       resolve(testOptions.folder);
     } else {
@@ -159,10 +163,10 @@ function doOK() {
           } else {
             bail("Manifest not found");
           }
         }, bail);
       }, bail);
     }, bail);
   }, bail);
 
-  return false;
+  event.preventDefault();
 }
--- a/devtools/client/webide/content/newapp.xul
+++ b/devtools/client/webide/content/newapp.xul
@@ -10,17 +10,16 @@
 ]>
 
 <?xml-stylesheet href="chrome://global/skin/global.css"?>
 <?xml-stylesheet href="chrome://webide/skin/newapp.css"?>
 
 <dialog id="webide:newapp" title="&newAppWindowTitle;"
   width="600" height="400"
   buttons="accept,cancel"
-  ondialogaccept="return doOK();"
   buttondisabledaccept="true"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript" src="newapp.js"></script>
   <label class="header-name" value="&newAppHeader;"/>
 
   <richlistbox id="templatelist" flex="1">
     <description>&newAppLoadingTemplate;</description>
--- a/dom/xul/test/398289-resource.xul
+++ b/dom/xul/test/398289-resource.xul
@@ -1,17 +1,20 @@
 <?xml version="1.0"?>
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         buttonlabelaccept="OK"
-        ondialogaccept="alert('OK');"
-        buttonlabelcancel="Cancel"
-        ondialogcancel="alert('Cancel');">
+        buttonlabelcancel="Cancel">
+
+  <script>
+    document.addEventListener("dialogaccept", function() { alert('OK') });
+    document.addEventListener("dialogcancel", function() { alert('Cancel') });
+  </script>
 
   <tabbox id="test" flex="1" persist="selectedIndex">
 
     <tabs>
       <tab label="One"/>
       <tab label="Two"/>
     </tabs>
 
--- a/security/manager/pki/resources/content/changepassword.js
+++ b/security/manager/pki/resources/content/changepassword.js
@@ -16,16 +16,17 @@ var token;
 var pw1;
 
 function doPrompt(msg) {
   Services.prompt.alert(window, null, msg);
 }
 
 function onLoad() {
   document.documentElement.getButton("accept").disabled = true;
+  document.addEventListener("dialogaccept", setPassword);
 
   pw1 = document.getElementById("pw1");
   params = window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
   token = params.objects.GetElementAt(0).QueryInterface(Ci.nsIPK11Token);
 
   document.getElementById("tokenName").setAttribute("value", token.name);
 
   process();
@@ -59,17 +60,17 @@ function process() {
   }
 
   // Return value 0 means "canceled"
   params.SetInt(1, 0);
 
   checkPasswords();
 }
 
-function setPassword() {
+function setPassword(event) {
   var oldpwbox = document.getElementById("oldpw");
   var initpw = oldpwbox.getAttribute("inited");
   var bundle = document.getElementById("pippki_bundle");
 
   var success = false;
 
   if (initpw == "false" || initpw == "empty") {
     try {
@@ -125,17 +126,19 @@ function setPassword() {
   }
 
   if (success && params) {
     // Return value 1 means "successfully executed ok"
     params.SetInt(1, 1);
   }
 
   // Terminate dialog
-  return success;
+  if (!success) {
+    event.preventDefault();
+  }
 }
 
 function setPasswordStrength() {
   // We weigh the quality of the password by checking the number of:
   //  - Characters
   //  - Numbers
   //  - Non-alphanumeric chars
   //  - Upper and lower case characters
--- a/security/manager/pki/resources/content/changepassword.xul
+++ b/security/manager/pki/resources/content/changepassword.xul
@@ -6,17 +6,16 @@
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://pippki/locale/pippki.dtd">
 
 <dialog id="set_password" title="&setPassword.title;"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:html="http://www.w3.org/1999/xhtml"
   buttons="accept,cancel"
-  ondialogaccept="return setPassword();"
   onload="onLoad();">
 
 <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
 <script type="application/javascript"
         src="chrome://pippki/content/changepassword.js"/>
 
 <hbox align="center">
--- a/security/manager/pki/resources/content/choosetoken.js
+++ b/security/manager/pki/resources/content/choosetoken.js
@@ -19,23 +19,23 @@ function onLoad() {
     let token = dialogParams.GetString(i);
     menuItemNode.setAttribute("value", token);
     menuItemNode.setAttribute("label", token);
     selectElement.firstChild.appendChild(menuItemNode);
     if (i == 0) {
       selectElement.selectedItem = menuItemNode;
     }
   }
+  document.addEventListener("dialogaccept", doOK);
+  document.addEventListener("dialogcancel", doCancel);
 }
 
 function doOK() {
   let tokenList = document.getElementById("tokens");
   // Signal that the user accepted.
   dialogParams.SetInt(0, 1);
   // Signal the name of the token the user chose.
   dialogParams.SetString(0, tokenList.value);
-  return true;
 }
 
 function doCancel() {
   dialogParams.SetInt(0, 0); // Signal that the user cancelled.
-  return true;
 }
--- a/security/manager/pki/resources/content/choosetoken.xul
+++ b/security/manager/pki/resources/content/choosetoken.xul
@@ -10,18 +10,16 @@
 %pippkiDTD;
 ]>
 
 
 <dialog id="ssl_warning" title="&chooseToken.title;"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"      
   style="width: 40em;"
   buttons="accept,cancel"
-  ondialogaccept="return doOK();"
-  ondialogcancel="return doCancel();"
   onload="onLoad();">
 
 <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
 <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 <script type="application/javascript" src="chrome://pippki/content/choosetoken.js"/>
 
 <description>&chooseToken.message1;</description>
--- a/security/manager/pki/resources/content/clientauthask.js
+++ b/security/manager/pki/resources/content/clientauthask.js
@@ -90,16 +90,18 @@ function onLoad() {
     menuItemNode.setAttribute("label", nickAndSerial); // This is displayed.
     selectElement.firstChild.appendChild(menuItemNode);
     if (i == 0) {
       selectElement.selectedItem = menuItemNode;
     }
   }
 
   setDetails();
+  document.addEventListener("dialogaccept", doOK);
+  document.addEventListener("dialogcancel", doCancel);
 
   Services.obs.notifyObservers(document.getElementById("certAuthAsk"),
                                "cert-dialog-loaded");
 }
 
 /**
  * Populates the details section with information concerning the selected cert.
  */
@@ -138,17 +140,15 @@ function onCertSelected() {
 }
 
 function doOK() {
   let retVals = window.arguments[5].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("certChosen", true);
   let index = parseInt(document.getElementById("nicknames").value);
   retVals.setPropertyAsUint32("selectedIndex", index);
   retVals.setPropertyAsBool("rememberSelection", rememberBox.checked);
-  return true;
 }
 
 function doCancel() {
   let retVals = window.arguments[5].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("certChosen", false);
   retVals.setPropertyAsBool("rememberSelection", rememberBox.checked);
-  return true;
 }
--- a/security/manager/pki/resources/content/clientauthask.xul
+++ b/security/manager/pki/resources/content/clientauthask.xul
@@ -10,18 +10,16 @@
 %pippkiDTD;
 ]>
 
 
 <dialog id="certAuthAsk" title="&clientAuthAsk.title;"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:html="http://www.w3.org/1999/xhtml"
   buttons="accept,cancel"
-  ondialogaccept="return doOK();"
-  ondialogcancel="return doCancel();"
   onload="onLoad();">
 
 <stringbundleset id="stringbundleset">
   <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 </stringbundleset>
 
 <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 <script type="application/javascript" src="chrome://pippki/content/clientauthask.js"/>
--- a/security/manager/pki/resources/content/deletecert.js
+++ b/security/manager/pki/resources/content/deletecert.js
@@ -79,39 +79,36 @@ function onLoad() {
     default:
       return;
   }
 
   document.l10n.setAttributes(document.documentElement, prefixForType + "title");
   document.l10n.setAttributes(confirm, prefixForType + "confirm");
   document.l10n.setAttributes(impact, prefixForType + "impact");
 
+  document.addEventListener("dialogaccept", onDialogAccept);
+  document.addEventListener("dialogcancel", onDialogCancel);
+
   let box = document.getElementById("certlist");
   let certTreeItems = window.arguments[1];
   for (let certTreeItem of certTreeItems) {
     let listItem = document.createXULElement("richlistitem");
     let label = getLabelForCertTreeItem(certTreeItem);
     listItem.appendChild(label);
     box.appendChild(listItem);
   }
 }
 
 /**
  * ondialogaccept() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogAccept() {
   let retVals = window.arguments[2];
   retVals.deleteConfirmed = true;
-  return true;
 }
 
 /**
  * ondialogcancel() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogCancel() {
   let retVals = window.arguments[2];
   retVals.deleteConfirmed = false;
-  return true;
 }
--- a/security/manager/pki/resources/content/deletecert.xul
+++ b/security/manager/pki/resources/content/deletecert.xul
@@ -8,19 +8,17 @@
 <!DOCTYPE dialog>
 
 <dialog id="deleteCertificate"
   data-l10n-id="certmgr-delete-cert"
   data-l10n-attrs="style"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:html="http://www.w3.org/1999/xhtml"
   onload="onLoad();"
-  buttons="accept,cancel"
-  ondialogaccept="return onDialogAccept();"
-  ondialogcancel="return onDialogCancel();">
+  buttons="accept,cancel">
 
   <linkset>
     <html:link rel="localization" href="security/certificates/certManager.ftl"/>
   </linkset>
 
   <script type="application/javascript" src="pippki.js" />
   <script type="application/javascript" src="chrome://pippki/content/deletecert.js"/>
 
--- a/security/manager/pki/resources/content/downloadcert.js
+++ b/security/manager/pki/resources/content/downloadcert.js
@@ -36,16 +36,19 @@
 var gCert;
 
 /**
  * onload() handler.
  */
 function onLoad() {
   gCert = window.arguments[0].QueryInterface(Ci.nsIX509Cert);
 
+  document.addEventListener("dialogaccept", onDialogAccept);
+  document.addEventListener("dialogcancel", onDialogCancel);
+
   let bundle = document.getElementById("pippki_bundle");
   let caName = gCert.commonName;
   if (caName.length == 0) {
     caName = bundle.getString("unnamedCA");
   }
 
   setText("trustHeader", bundle.getFormattedString("newCAMessage1", [caName]));
 }
@@ -54,32 +57,26 @@ function onLoad() {
  * Handler for the "View Cert" button.
  */
 function viewCert() {
   viewCertHelper(window, gCert);
 }
 
 /**
  * ondialogaccept() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogAccept() {
   let checkSSL = document.getElementById("trustSSL");
   let checkEmail = document.getElementById("trustEmail");
 
   let retVals = window.arguments[1].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("importConfirmed", true);
   retVals.setPropertyAsBool("trustForSSL", checkSSL.checked);
   retVals.setPropertyAsBool("trustForEmail", checkEmail.checked);
-  return true;
 }
 
 /**
  * ondialogcancel() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogCancel() {
   let retVals = window.arguments[1].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("importConfirmed", false);
-  return true;
 }
--- a/security/manager/pki/resources/content/downloadcert.xul
+++ b/security/manager/pki/resources/content/downloadcert.xul
@@ -7,18 +7,16 @@
 
 <!DOCTYPE dialog SYSTEM "chrome://pippki/locale/pippki.dtd">
 
 <dialog id="download_cert"
         title="&downloadCert.title;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         style="width: 46em;"
         buttons="accept,cancel"
-        ondialogaccept="return onDialogAccept();"
-        ondialogcancel="return onDialogCancel();"
         onload="onLoad();">
 
 <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
 <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 <script type="application/javascript" src="chrome://pippki/content/downloadcert.js"/>
 
 
--- a/security/manager/pki/resources/content/editcacert.js
+++ b/security/manager/pki/resources/content/editcacert.js
@@ -13,34 +13,33 @@ var gCertDB = Cc["@mozilla.org/security/
 var gCert;
 
 /**
  * onload() handler.
  */
 function onLoad() {
   gCert = window.arguments[0];
 
+  document.addEventListener("dialogaccept", onDialogAccept);
+
   let certMsg = document.getElementById("certmsg");
   document.l10n.setAttributes(certMsg, "edit-trust-ca", { certName: gCert.commonName});
 
   let sslCheckbox = document.getElementById("trustSSL");
   sslCheckbox.checked = gCertDB.isCertTrusted(gCert, Ci.nsIX509Cert.CA_CERT,
                                               Ci.nsIX509CertDB.TRUSTED_SSL);
 
   let emailCheckbox = document.getElementById("trustEmail");
   emailCheckbox.checked = gCertDB.isCertTrusted(gCert, Ci.nsIX509Cert.CA_CERT,
                                                 Ci.nsIX509CertDB.TRUSTED_EMAIL);
 }
 
 /**
  * ondialogaccept() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogAccept() {
   let sslCheckbox = document.getElementById("trustSSL");
   let emailCheckbox = document.getElementById("trustEmail");
   let trustSSL = sslCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_SSL : 0;
   let trustEmail = emailCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_EMAIL : 0;
 
   gCertDB.setCertTrust(gCert, Ci.nsIX509Cert.CA_CERT, trustSSL | trustEmail);
-  return true;
 }
--- a/security/manager/pki/resources/content/editcacert.xul
+++ b/security/manager/pki/resources/content/editcacert.xul
@@ -8,17 +8,16 @@
 <!DOCTYPE dialog>
 
 <dialog id="editCaCert"
         data-l10n-id="certmgr-edit-ca-cert"
         data-l10n-attrs="style"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         buttons="accept,cancel"
-        ondialogaccept="return onDialogAccept();"
         onload="onLoad();">
 
   <linkset>
     <html:link rel="localization" href="security/certificates/certManager.ftl"/>
   </linkset>
 
   <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
   <script type="application/javascript"
--- a/security/manager/pki/resources/content/load_device.js
+++ b/security/manager/pki/resources/content/load_device.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 /* import-globals-from pippki.js */
 "use strict";
 
+document.addEventListener("dialogaccept", onDialogAccept);
+
 /**
  * @file Implements the functionality of load_device.xul: a dialog that allows
  *       a PKCS #11 module to be loaded into Firefox.
  */
 
 async function onBrowseBtnPress() {
   let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
   let [loadPK11ModuleFilePickerTitle] = await document.l10n.formatValues([{id: "load-pk11-module-file-picker-title"}]);
@@ -22,33 +24,31 @@ async function onBrowseBtnPress() {
     // This notification gets sent solely for test purposes. It should not be
     // used by production code.
     Services.obs.notifyObservers(window, "LoadPKCS11Module:FilePickHandled");
   });
 }
 
 /**
  * ondialogaccept() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
+ * @param {Object} event
+ *        The event causing this handler function to be called.
  */
-function onDialogAccept() {
+function onDialogAccept(event) {
   let nameBox = document.getElementById("device_name");
   let pathBox = document.getElementById("device_path");
   let pkcs11ModuleDB = Cc["@mozilla.org/security/pkcs11moduledb;1"]
                          .getService(Ci.nsIPKCS11ModuleDB);
 
   try {
     pkcs11ModuleDB.addModule(nameBox.value, pathBox.value, 0, 0);
   } catch (e) {
     addModuleFailure("add-module-failure");
-    return false;
+    event.preventDefault();
   }
-
-  return true;
 }
 
 async function addModuleFailure(l10nID) {
   let [AddModuleFailure] = await document.l10n.formatValues([{id: l10nID}]);
   alertPromptService(null, AddModuleFailure);
 }
 
 function validateModuleName() {
--- a/security/manager/pki/resources/content/load_device.xul
+++ b/security/manager/pki/resources/content/load_device.xul
@@ -6,18 +6,17 @@
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <!DOCTYPE dialog>
 
 <dialog id="loaddevice"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         data-l10n-id="load-device"
-        buttons="accept,cancel"
-        ondialogaccept="return onDialogAccept();">
+        buttons="accept,cancel">
 
   <linkset>
     <html:link rel="localization" href="security/certificates/deviceManager.ftl"/>
   </linkset>
 
   <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
   <script type="application/javascript"
           src="chrome://pippki/content/load_device.js"/>
--- a/security/manager/pki/resources/content/resetpassword.js
+++ b/security/manager/pki/resources/content/resetpassword.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 /* import-globals-from pippki.js */
 "use strict";
 
+document.addEventListener("dialogaccept", resetPassword);
+
 function resetPassword() {
   var pk11db = Cc["@mozilla.org/security/pk11tokendb;1"]
                  .getService(Ci.nsIPK11TokenDB);
   var token = pk11db.getInternalKeyToken();
   token.reset();
 
   try {
     Services.logins.removeAllLogins();
@@ -18,11 +20,9 @@ function resetPassword() {
   var bundle = document.getElementById("pippki_bundle");
   var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService();
   promptService = promptService.QueryInterface(Ci.nsIPromptService);
   if (promptService && bundle) {
     promptService.alert(window,
                         bundle.getString("resetPasswordConfirmationTitle"),
                         bundle.getString("resetPasswordConfirmationMessage"));
   }
-
-  return true;
 }
--- a/security/manager/pki/resources/content/resetpassword.xul
+++ b/security/manager/pki/resources/content/resetpassword.xul
@@ -7,17 +7,16 @@
 
 <!DOCTYPE dialog SYSTEM "chrome://pippki/locale/pippki.dtd">
 
 <dialog id="reset_password" title="&resetPassword.title;"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   buttons="accept,cancel"
   buttonlabelaccept="&resetPasswordButtonLabel;"
   defaultButton="cancel"
-  ondialogaccept="return resetPassword();"
   style="width: 40em;">
 
   <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
   <script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
   <script type="application/javascript" src="chrome://pippki/content/resetpassword.js"/>
 
   <hbox flex="1">
--- a/security/manager/pki/resources/content/setp12password.js
+++ b/security/manager/pki/resources/content/setp12password.js
@@ -23,41 +23,37 @@
  */
 
 /**
  * onload() handler.
  */
 function onLoad() {
   // Ensure the first password textbox has focus.
   document.getElementById("pw1").focus();
+  document.addEventListener("dialogaccept", onDialogAccept);
+  document.addEventListener("dialogcancel", onDialogCancel);
 }
 
 /**
  * ondialogaccept() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogAccept() {
   let password = document.getElementById("pw1").value;
 
   let retVals = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("confirmedPassword", true);
   retVals.setPropertyAsAString("password", password);
-  return true;
 }
 
 /**
  * ondialogcancel() handler.
- *
- * @returns {Boolean} true to make the dialog close, false otherwise.
  */
 function onDialogCancel() {
   let retVals = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2);
   retVals.setPropertyAsBool("confirmedPassword", false);
-  return true;
 }
 
 /**
  * Calculates the strength of the given password, suitable for use in updating
  * a progress bar that represents said strength.
  *
  * The strength of the password is calculated by checking the number of:
  *   - Characters
--- a/security/manager/pki/resources/content/setp12password.xul
+++ b/security/manager/pki/resources/content/setp12password.xul
@@ -8,18 +8,16 @@
 <!DOCTYPE dialog SYSTEM "chrome://pippki/locale/pippki.dtd">
 
 <dialog id="setp12password"
         title="&pkcs12.setpassword.title;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         style="width: 48em;"
         buttons="accept,cancel"
-        ondialogaccept="return onDialogAccept();"
-        ondialogcancel="return onDialogCancel();"
         onload="onLoad();">
 
   <script type="application/javascript"
           src="chrome://pippki/content/setp12password.js"/>
 
   <description>&pkcs12.setpassword.message;</description>
   <separator />
   <vbox>
--- a/toolkit/components/apppicker/content/appPicker.js
+++ b/toolkit/components/apppicker/content/appPicker.js
@@ -13,16 +13,18 @@ AppPicker.prototype =
     _incomingParams: null,
 
     /**
     * Init the dialog and populate the application list
     */
     appPickerLoad: function appPickerLoad() {
         const nsILocalHandlerApp = Ci.nsILocalHandlerApp;
 
+        document.addEventListener("dialogaccept", function() { g_dialog.appPickerOK(); });
+        document.addEventListener("dialogcancel", function() { g_dialog.appPickerCancel(); });
         document.addEventListener("dialogextra2", function() { g_dialog.appPickerBrowse(); });
 
         this._incomingParams = window.arguments[0];
         this._incomingParams.handlerApp = null;
 
         document.title = this._incomingParams.title;
 
         // Header creation - at the very least, we must have
@@ -149,33 +151,30 @@ AppPicker.prototype =
 
       this._incomingParams.handlerApp = selItem.handlerApp;
       window.close();
 
       return true;
     },
 
     appPickerOK: function appPickerOK() {
-      if (this._incomingParams.handlerApp) return true;
+      if (this._incomingParams.handlerApp) return;
 
       var list = document.getElementById("app-picker-listbox");
       var selItem = list.selectedItem;
 
       if (!selItem) {
         this._incomingParams.handlerApp = null;
-        return true;
+        return;
       }
       this._incomingParams.handlerApp = selItem.handlerApp;
-
-      return true;
     },
 
     appPickerCancel: function appPickerCancel() {
       this._incomingParams.handlerApp = null;
-      return true;
     },
 
     /**
     * User browse for an app.
     */
     appPickerBrowse: function appPickerBrowse() {
       var nsIFilePicker = Ci.nsIFilePicker;
       var fp = Cc["@mozilla.org/filepicker;1"].
@@ -201,14 +200,13 @@ AppPicker.prototype =
                 Cc["@mozilla.org/uriloader/local-handler-app;1"].
                 createInstance(Ci.nsILocalHandlerApp);
               localHandlerApp.executable = fp.file;
 
               this._incomingParams.handlerApp = localHandlerApp;
               window.close();
           }
       });
-      return true;
     },
 };
 
 // Global object
 var g_dialog = new AppPicker();
--- a/toolkit/components/apppicker/content/appPicker.xul
+++ b/toolkit/components/apppicker/content/appPicker.xul
@@ -10,18 +10,16 @@
   <!DOCTYPE dialog SYSTEM "chrome://global/locale/appPicker.dtd" >
 
   <dialog id="app-picker"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     onload="g_dialog.appPickerLoad();"
     buttons="accept,cancel,extra2"
     buttonlabelextra2="&BrowseButton.label;"
     defaultButton="cancel"
-    ondialogaccept="return g_dialog.appPickerOK();"
-    ondialogcancel="return g_dialog.appPickerCancel();"
     aria-describedby="content-description suggested-filename"
     persist="screenX screenY">
 
     <script type="application/javascript" src="chrome://global/content/appPicker.js"/>
 
     <hbox id="file-info" align="center">
       <image id="content-icon" src=""/>
       <vbox flex="1">
--- a/toolkit/components/printing/content/printPageSetup.js
+++ b/toolkit/components/printing/content/printPageSetup.js
@@ -48,16 +48,18 @@ function initDialog() {
   gDialog.fLeftOption     = document.getElementById("fLeftOption");
   gDialog.fCenterOption   = document.getElementById("fCenterOption");
   gDialog.fRightOption    = document.getElementById("fRightOption");
 
   gDialog.scalingLabel    = document.getElementById("scalingInput");
   gDialog.scalingInput    = document.getElementById("scalingInput");
 
   gDialog.enabled         = false;
+
+  document.addEventListener("dialogaccept", onAccept);
 }
 
 // ---------------------------------------------------
 function isListOfPrinterFeaturesAvailable() {
   return Services.prefs.getBoolPref("print.tmp.printerfeatures." +
     gPrintSettings.printerName + ".has_special_printerfeatures", false);
 }
 
@@ -419,18 +421,16 @@ function onAccept() {
               gPrintSettingsInterface.kInitSaveInColor |
               gPrintSettingsInterface.kInitSaveReversed |
               gPrintSettingsInterface.kInitSaveOrientation |
               gPrintSettingsInterface.kInitSaveOddEvenPages |
               gPrintSettingsInterface.kInitSaveShrinkToFit |
               gPrintSettingsInterface.kInitSaveScaling;
 
   gPrintService.savePrintSettingsToPrefs(gPrintSettings, true, flags);
-
-  return true;
 }
 
 // ---------------------------------------------------
 function onCancel() {
   // set return value to "cancel"
   if (paramBlock) {
     paramBlock.SetInt(0, 0);
   } else {
--- a/toolkit/components/printing/content/printPageSetup.xul
+++ b/toolkit/components/printing/content/printPageSetup.xul
@@ -6,17 +6,16 @@
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://global/skin/printPageSetup.css" type="text/css"?>
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:html="http://www.w3.org/1999/xhtml"
   id="printPageSetupDialog"
   onload="onLoad();"
-  ondialogaccept="return onAccept();"
   oncancel="return onCancel();"
   data-l10n-id="print-setup"
   persist="screenX screenY"
   screenX="24" screenY="24">
 
   <linkset>
     <html:link rel="localization" href="toolkit/printing/printDialogs.ftl"/>
   </linkset>
@@ -216,9 +215,8 @@
               </row>
             </rows>
           </grid>
         </groupbox>
       </vbox>
     </tabpanels>
   </tabbox>
 </dialog>
-
--- a/toolkit/components/printing/content/printProgress.js
+++ b/toolkit/components/printing/content/printProgress.js
@@ -177,37 +177,35 @@ function onLoad() {
 
     document.l10n.setAttributes(dialog.tempLabel, "print-preparing");
 
     dialog.title.value = docTitle;
 
     // Fill dialog.
     loadDialog();
 
+    document.addEventListener("dialogcancel", onCancel);
     // set our web progress listener on the helper app launcher
     printProgress.registerListener(progressListener);
     // We need to delay the set title else dom will overwrite it
     window.setTimeout(doneIniting, 500);
 }
 
 function onUnload() {
   if (printProgress) {
    try {
      printProgress.unregisterListener(progressListener);
      printProgress = null;
    } catch ( exception ) {}
   }
 }
 
-// If the user presses cancel, tell the app launcher and close the dialog...
+// If the user presses cancel, tell the app launcher and close the dialog.
 function onCancel() {
   // Cancel app launcher.
    try {
      printProgress.processCanceledByUser = true;
-   } catch ( exception ) { return true; }
-
-  // don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
-  return false;
+   } catch ( exception ) {}
 }
 
 function doneIniting() {
   printProgress.doneIniting();
 }
--- a/toolkit/components/printing/content/printProgress.xul
+++ b/toolkit/components/printing/content/printProgress.xul
@@ -6,17 +6,16 @@
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         buttons="cancel"
         data-l10n-id="print-window"
         style="width: 36em;"
-        ondialogcancel="onCancel()"
         onload="onLoad()"
         onunload="onUnload()">
 
   <linkset>
     <html:link rel="localization" href="toolkit/printing/printDialogs.ftl"/>
   </linkset>
 
   <script type="application/javascript" src="chrome://global/content/printProgress.js"/>
--- a/toolkit/components/prompts/content/commonDialog.js
+++ b/toolkit/components/prompts/content/commonDialog.js
@@ -36,20 +36,22 @@ function commonDialogOnLoad() {
         button0: dialog.getButton("accept"),
         focusTarget: window,
     };
 
     // limit the dialog to the screen width
     document.getElementById("filler").maxWidth = screen.availWidth;
 
     Dialog = new CommonDialog(args, ui);
+    document.addEventListener("dialogaccept", function() { Dialog.onButton0(); });
+    document.addEventListener("dialogcancel", function() { Dialog.onButton1(); });
+    document.addEventListener("dialogextra1", function() { Dialog.onButton2(); window.close(); });
+    document.addEventListener("dialogextra2", function() { Dialog.onButton3(); window.close(); });
     Dialog.onLoad(dialog);
 
-    document.addEventListener("dialogextra1", function() { Dialog.onButton2(); window.close(); });
-    document.addEventListener("dialogextra2", function() { Dialog.onButton3(); window.close(); });
     // resize the window to the content
     window.sizeToContent();
     window.getAttention();
 }
 
 function commonDialogOnUnload() {
     // Convert args back into property bag
     for (let propName in args)
--- a/toolkit/components/prompts/content/commonDialog.xul
+++ b/toolkit/components/prompts/content/commonDialog.xul
@@ -9,18 +9,16 @@
 <?xml-stylesheet href="chrome://global/skin/commonDialog.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://global/locale/commonDialog.dtd">
 
 <dialog id="commonDialog"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         aria-describedby="infoBody"
         onunload="commonDialogOnUnload();"
-        ondialogaccept="Dialog.onButton0(); return true;"
-        ondialogcancel="Dialog.onButton1(); return true;"
         buttonpack="center">
 
   <script type="application/javascript" src="chrome://global/content/commonDialog.js"/>
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript">
     document.addEventListener("DOMContentLoaded", function() {
       commonDialogOnLoad();
     });
--- a/toolkit/components/prompts/content/selectDialog.js
+++ b/toolkit/components/prompts/content/selectDialog.js
@@ -33,16 +33,17 @@ function dialogOnLoad() {
         if (str == "")
             str = "<>";
         listBox.appendItem(str);
         listBox.getItemAtIndex(i).addEventListener("dblclick", dialogDoubleClick);
     }
     listBox.selectedIndex = 0;
     listBox.focus();
 
+    document.addEventListener("dialogaccept", dialogOK);
     // resize the window to the content
     window.sizeToContent();
 
     // Move to the right location
     moveToAlertPosition();
     centerWindowOnScreen();
 
     // play sound
@@ -51,15 +52,14 @@ function dialogOnLoad() {
         createInstance(Ci.nsISound).
         playEventSound(Ci.nsISound.EVENT_SELECT_DIALOG_OPEN);
     } catch (e) { }
 }
 
 function dialogOK() {
     gArgs.setProperty("selected", listBox.selectedIndex);
     gArgs.setProperty("ok", true);
-    return true;
 }
 
 function dialogDoubleClick() {
     dialogOK();
     window.close();
 }
--- a/toolkit/components/prompts/content/selectDialog.xul
+++ b/toolkit/components/prompts/content/selectDialog.xul
@@ -3,18 +3,17 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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"?>
 <!DOCTYPE dialog SYSTEM "chrome://global/locale/commonDialog.dtd">
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      onload="dialogOnLoad()"
-      ondialogaccept="return dialogOK();">
+      onload="dialogOnLoad()">
 
   <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;"/>
     </vbox>
--- a/toolkit/content/resetProfile.js
+++ b/toolkit/content/resetProfile.js
@@ -1,10 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 "use strict";
 
+document.addEventListener("dialogaccept", onResetProfileAccepted);
+
 function onResetProfileAccepted() {
   let retVals = window.arguments[0];
   retVals.reset = true;
 }
--- a/toolkit/content/resetProfile.xul
+++ b/toolkit/content/resetProfile.xul
@@ -9,18 +9,16 @@
 
 <dialog id="resetProfileDialog"
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
             xmlns:html="http://www.w3.org/1999/xhtml"
             data-l10n-id="refresh-profile-dialog"
             buttons="accept,cancel"
             defaultButton="cancel"
             buttonidaccept="refresh-profile-dialog-button"
-            ondialogaccept="return onResetProfileAccepted();"
-            ondialogcancel="window.close();"
             onload="">
 	<!-- The empty onload event handler is a hack to get the accept button text applied by Fluent. -->
 
   <linkset>
     <html:link rel="localization" href="branding/brand.ftl"/>
     <html:link rel="localization" href="toolkit/global/resetProfile.ftl"/>
   </linkset>
 
--- a/toolkit/mozapps/downloads/HelperAppDlg.jsm
+++ b/toolkit/mozapps/downloads/HelperAppDlg.jsm
@@ -407,16 +407,19 @@ nsUnknownContentTypeDialog.prototype = {
 
   // ---------- implementation methods ----------
 
   // initDialog:  Fill various dialog fields with initial content.
   initDialog() {
     // Put file name in window title.
     var suggestedFileName = this.mLauncher.suggestedFileName;
 
+    this.mDialog.document.addEventListener("dialogaccept", this);
+    this.mDialog.document.addEventListener("dialogcancel", this);
+
     // Some URIs do not implement nsIURL, so we can't just QI.
     var url = this.mLauncher.source;
     if (url instanceof Ci.nsINestedURI)
       url = url.innermostURI;
 
     var fname = "";
     var iconPath = "goat";
     this.mSourcePath = url.prePath;
@@ -838,17 +841,17 @@ nsUnknownContentTypeDialog.prototype = {
   // handler service.
   updateHelperAppPref() {
     var handlerInfo = this.mLauncher.MIMEInfo;
     var hs = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService);
     hs.store(handlerInfo);
   },
 
   // onOK:
-  onOK() {
+  onOK(aEvent) {
     // Verify typed app path, if necessary.
     if (this.useOtherHandler) {
       var helperApp = this.helperAppChoice();
       if (!helperApp || !helperApp.executable ||
           !helperApp.executable.exists()) {
         // Show alert and try again.
         var bundle = this.dialogElement("strings");
         var msg = bundle.getFormattedString("badApp", [this.dialogElement("otherHandler").getAttribute("path")]);
@@ -857,17 +860,17 @@ nsUnknownContentTypeDialog.prototype = {
         // Disable the OK button.
         this.mDialog.document.documentElement.getButton("accept").disabled = true;
         this.dialogElement("mode").focus();
 
         // Clear chosen application.
         this.chosenApp = null;
 
         // Leave dialog up.
-        return false;
+        aEvent.preventDefault();
       }
     }
 
     // Remove our web progress listener (a progress dialog will be
     // taking over).
     this.mLauncher.setWebProgressListener(null);
 
     // saveToDisk and launchWithApplication can return errors in
@@ -910,40 +913,49 @@ nsUnknownContentTypeDialog.prototype = {
       // Update user pref for this mime type (if necessary). We do not
       // store anything in the mime type preferences for the ambiguous
       // type application/octet-stream. We do NOT do this for
       // application/x-msdownload since we want users to be able to
       // autodownload these to disk.
       if (needUpdate && this.mLauncher.MIMEInfo.MIMEType != "application/octet-stream")
         this.updateHelperAppPref();
     } catch (e) { }
-
-    // Unhook dialog from this object.
-    this.mDialog.dialog = null;
-
-    // Close up dialog by returning true.
-    return true;
+    this.onUnload();
   },
 
   // onCancel:
   onCancel() {
     // Remove our web progress listener.
     this.mLauncher.setWebProgressListener(null);
 
     // Cancel app launcher.
     try {
       this.mLauncher.cancel(Cr.NS_BINDING_ABORTED);
     } catch (exception) {
     }
+    this.onUnload();
+  },
+
+  onUnload() {
+    this.mDialog.document.removeEventListener("dialogaccept", this);
+    this.mDialog.document.removeEventListener("dialogcancel", this);
 
     // Unhook dialog from this object.
     this.mDialog.dialog = null;
+  },
 
-    // Close up dialog by returning true.
-    return true;
+  handleEvent(aEvent) {
+    switch (aEvent.type) {
+      case "dialogaccept":
+        this.onOK(aEvent);
+        break;
+      case "dialogcancel":
+        this.onCancel();
+        break;
+    }
   },
 
   // dialogElement:  Convenience.
   dialogElement(id) {
     return this.mDialog.document.getElementById(id);
   },
 
   // Retrieve the pretty description from the file
--- a/toolkit/mozapps/downloads/content/unknownContentType.xul
+++ b/toolkit/mozapps/downloads/content/unknownContentType.xul
@@ -21,19 +21,17 @@
         onload="dialog.initDialog();" onunload="if (dialog) dialog.onCancel();"
 #ifdef XP_WIN
         style="width: 36em;"
 #else
         style="width: 34em;"
 #endif
         screenX="" screenY=""
         persist="screenX screenY"
-        aria-describedby="intro location whichIs type from source unknownPrompt"
-        ondialogaccept="return dialog.onOK()"
-        ondialogcancel="return dialog.onCancel()">
+        aria-describedby="intro location whichIs type from source unknownPrompt">
 
 
   <stringbundle id="strings" src="chrome://mozapps/locale/downloads/unknownContentType.properties"/>
 
   <vbox flex="1" id="container">  
     <description id="intro">&intro2.label;</description>
     <separator class="thin"/>
     <hbox align="start" class="small-indent">
--- a/toolkit/mozapps/extensions/content/blocklist.js
+++ b/toolkit/mozapps/extensions/content/blocklist.js
@@ -13,16 +13,19 @@ const {Services} = ChromeUtils.import("r
 
 var gArgs;
 
 function init() {
   var hasHardBlocks = false;
   var hasSoftBlocks = false;
   gArgs = window.arguments[0].wrappedJSObject;
 
+  document.addEventListener("dialogaccept", function() { finish(true); });
+  document.addEventListener("dialogcancel", function() { finish(false); });
+
   // NOTE: We use strings from the "updates.properties" bundleset to change the
   // text on the "Cancel" button to "Restart Later". (bug 523784)
   let bundle = Services.strings.
               createBundle("chrome://mozapps/locale/update/updates.properties");
   let cancelButton = document.documentElement.getButton("cancel");
   cancelButton.setAttribute("label", bundle.GetStringFromName("restartLaterButton"));
   cancelButton.setAttribute("accesskey",
                             bundle.GetStringFromName("restartLaterButton.accesskey"));
@@ -90,10 +93,9 @@ function init() {
 function finish(shouldRestartNow) {
   gArgs.restart = shouldRestartNow;
   var list = gArgs.list;
   var items = document.getElementById("addonList").childNodes;
   for (let i = 0; i < list.length; i++) {
     if (!list[i].blocked)
       list[i].disable = items[i].querySelector(".disableCheckbox").checked;
   }
-  return true;
 }
--- a/toolkit/mozapps/extensions/content/blocklist.xul
+++ b/toolkit/mozapps/extensions/content/blocklist.xul
@@ -11,18 +11,17 @@
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/blocklist.dtd">
 %extensionsDTD;
 ]>
 
 <dialog windowtype="Addons:Blocklist" title="&blocklist.title;" align="stretch"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="init();" ondialogaccept="return finish(true)"
-                         ondialogcancel="return finish(false)"
+        onload="init();"
         buttons="accept,cancel" style="&blocklist.style;"
         buttonlabelaccept="&blocklist.accept.label;"
         buttonaccesskeyaccept="&blocklist.accept.accesskey;">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript" src="chrome://mozapps/content/extensions/blocklist.js"/>
 
   <hbox align="stretch" flex="1">
--- a/toolkit/mozapps/handling/content/dialog.js
+++ b/toolkit/mozapps/handling/content/dialog.js
@@ -126,16 +126,17 @@ var dialog = {
     checkbox.text.textContent    = window.arguments[6];
 
     // Hide stuff that needs to be hidden
     if (!checkbox.desc.label)
       checkbox.desc.hidden = true;
 
     // UI is ready, lets populate our list
     this.populateList();
+    document.addEventListener("dialogaccept", () => { this.onAccept(); });
 
     this._delayHelper = new EnableDelayHelper({
       disableDialog: () => {
         this._buttonDisabled = true;
         this.updateOKButton();
       },
       enableDialog: () => {
         this._buttonDisabled = false;
@@ -302,18 +303,16 @@ var dialog = {
     }
     this._handlerInfo.alwaysAskBeforeHandling = !checkbox.checked;
 
     var hs = Cc["@mozilla.org/uriloader/handler-service;1"].
              getService(Ci.nsIHandlerService);
     hs.store(this._handlerInfo);
 
     this._handlerInfo.launchWithURI(this._URI, this._windowCtxt);
-
-    return true;
   },
 
  /**
   * Determines if the OK button should be disabled or not
   */
   updateOKButton: function updateOKButton() {
     this._okButton.disabled = this._itemChoose.selected ||
                               this._buttonDisabled;
--- a/toolkit/mozapps/handling/content/dialog.xul
+++ b/toolkit/mozapps/handling/content/dialog.xul
@@ -4,17 +4,16 @@
 <?xml-stylesheet href="chrome://mozapps/skin/handling/handling.css"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
 <!DOCTYPE dialog SYSTEM "chrome://mozapps/locale/handling/handling.dtd">
 
 <dialog id="handling"
-        ondialogaccept="return dialog.onAccept();"
         onload="dialog.initialize();"
         style="min-width: &window.emWidth;; min-height: &window.emHeight;;"
         persist="width height screenX screenY"
         aria-describedby="description-text"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mozapps/content/handling/dialog.js" type="application/javascript"/>
 
--- a/toolkit/mozapps/preferences/changemp.js
+++ b/toolkit/mozapps/preferences/changemp.js
@@ -17,16 +17,17 @@ const nsIPK11Token = Ci.nsIPK11Token;
 
 var params;
 var pw1;
 
 function init() {
   pw1 = document.getElementById("pw1");
 
   process();
+  document.addEventListener("dialogaccept", setPassword);
 }
 
 
 function process() {
   // If the token is unitialized, don't use the old password box.
   // Otherwise, do.
 
   let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
@@ -75,18 +76,16 @@ async function createAlert(titleL10nId, 
 
 function setPassword() {
   var pk11db = Cc[nsPK11TokenDB].getService(nsIPK11TokenDB);
   var token = pk11db.getInternalKeyToken();
 
   var oldpwbox = document.getElementById("oldpw");
   var initpw = oldpwbox.getAttribute("inited");
 
-  var success = false;
-
   if (initpw == "false" || initpw == "empty") {
     try {
       var oldpw = "";
       var passok = 0;
 
       if (initpw == "empty") {
         passok = 1;
       } else {
@@ -109,40 +108,32 @@ function setPassword() {
           }
           if (passok) {
             token.changePassword(oldpw, pw1.value);
             if (pw1.value == "") {
               createAlert("pw-change-success-title", "pw-erased-ok");
             } else {
               createAlert("pw-change-success-title", "pw-change-ok");
             }
-            success = true;
           }
         }
       } else {
         oldpwbox.focus();
         oldpwbox.setAttribute("value", "");
         createAlert("pw-change-failed-title", "incorrect-pw");
       }
     } catch (e) {
       createAlert("pw-change-failed-title", "failed-pw-change");
     }
   } else {
     token.initPassword(pw1.value);
     if (pw1.value == "") {
       createAlert("pw-change-success-title", "pw-not-wanted");
     }
-    success = true;
   }
-
-  // Terminate dialog
-  if (success)
-    window.close();
-
-  return success;
 }
 
 function setPasswordStrength() {
 // Here is how we weigh the quality of the password
 // number of characters
 // numbers
 // non-alpha-numeric chars
 // upper and lower case characters
--- a/toolkit/mozapps/preferences/changemp.xul
+++ b/toolkit/mozapps/preferences/changemp.xul
@@ -5,17 +5,16 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog id="changemp"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         style="width: 40em;"
-        ondialogaccept="setPassword();"
         onload="init()"
         data-l10n-id="set-password">
 
   <script type="application/javascript" src="chrome://mozapps/content/preferences/changemp.js"/>
 
   <linkset>
     <html:link rel="localization" href="branding/brand.ftl"/>
     <html:link rel="localization" href="toolkit/preferences/preferences.ftl"/>
--- a/toolkit/mozapps/preferences/removemp.js
+++ b/toolkit/mozapps/preferences/removemp.js
@@ -18,16 +18,17 @@ var gRemovePasswordDialog = {
 
     var pk11db = Cc["@mozilla.org/security/pk11tokendb;1"]
                    .getService(Ci.nsIPK11TokenDB);
     this._token = pk11db.getInternalKeyToken();
 
     // Initialize the enabled state of the Remove button by checking the
     // initial value of the password ("" should be incorrect).
     this.validateInput();
+    document.addEventListener("dialogaccept", function() { gRemovePasswordDialog.removePassword(); });
   },
 
   validateInput() {
     this._okButton.disabled = !this._token.checkPassword(this._password.value);
   },
 
   async createAlert(titleL10nId, messageL10nId) {
     const [title, message] = await document.l10n.formatValues([
--- a/toolkit/mozapps/preferences/removemp.xul
+++ b/toolkit/mozapps/preferences/removemp.xul
@@ -4,18 +4,17 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <dialog id="removemp"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        style="width: 35em;" 
-        ondialogaccept="gRemovePasswordDialog.removePassword();" 
+        style="width: 35em;"
         onload="gRemovePasswordDialog.init()"
         data-l10n-id="remove-password">
 
   <script type="application/javascript" src="chrome://mozapps/content/preferences/removemp.js"/>
 
   <linkset>
     <html:link rel="localization" href="toolkit/preferences/preferences.ftl"/>
   </linkset>
--- a/toolkit/profile/content/profileDowngrade.js
+++ b/toolkit/profile/content/profileDowngrade.js
@@ -18,17 +18,20 @@ function init() {
   if (AppConstants.MOZ_SERVICES_SYNC) {
     let hasSync = gParams.GetInt(0) & Ci.nsIToolkitProfileService.hasSync;
 
     document.getElementById("sync").hidden = !hasSync;
     document.getElementById("nosync").hidden = hasSync;
   }
 
   document.addEventListener("dialogextra1", createProfile);
+  document.addEventListener("dialogaccept", quit);
+  document.addEventListener("dialogcancel", quit);
 }
+
 function quit() {
   gParams.SetInt(1, Ci.nsIToolkitProfileService.quit);
 }
 
 function createProfile() {
   gParams.SetInt(1, Ci.nsIToolkitProfileService.createNewProfile);
   window.close();
 }
--- a/toolkit/profile/content/profileDowngrade.xul
+++ b/toolkit/profile/content/profileDowngrade.xul
@@ -20,17 +20,16 @@
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="&window.title;" onload="init()" style="&window.style;"
         buttonlabelextra1="&window.create;"
 #ifdef XP_WIN
         buttonlabelaccept="&window.quit-win;"
 #else
         buttonlabelaccept="&window.quit-nonwin;"
 #endif
-        ondialogaccept="quit()" ondialogcancel="quit()"
         buttons="accept,extra1" buttonpack="end">
 
   <script type="application/javascript" src="profileDowngrade.js"/>
 
   <hbox flex="1" align="start">
     <image id="info" role="presentation"/>
     <vbox flex="1">
       <description id="nosync">&window.nosync;</description>
--- a/toolkit/profile/content/profileSelection.js
+++ b/toolkit/profile/content/profileSelection.js
@@ -50,54 +50,52 @@ function startup() {
 
     var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
     autoSelectLastProfile.checked = gProfileService.startWithLastProfile;
     profilesElement.focus();
   } catch (e) {
     window.close();
     throw (e);
   }
+  document.addEventListener("dialogaccept", acceptDialog);
+  document.addEventListener("dialogcancel", exitDialog);
 }
 
-function acceptDialog() {
+function acceptDialog(event) {
   var appName = gBrandBundle.getString("brandShortName");
 
   var profilesElement = document.getElementById("profiles");
   var selectedProfile = profilesElement.selectedItem;
   if (!selectedProfile) {
     var pleaseSelectTitle = gProfileManagerBundle.getString("pleaseSelectTitle");
     var pleaseSelect =
       gProfileManagerBundle.getFormattedString("pleaseSelect", [appName]);
     Services.prompt.alert(window, pleaseSelectTitle, pleaseSelect);
-
-    return false;
+    event.preventDefault();
+    return;
   }
 
   gDialogParams.objects.insertElementAt(selectedProfile.profile.rootDir, 0);
   gDialogParams.objects.insertElementAt(selectedProfile.profile.localDir, 1);
 
   try {
     gProfileService.defaultProfile = selectedProfile.profile;
   } catch (e) {
     // This can happen on dev-edition. We'll still restart with the selected
     // profile based on the lock's directories.
   }
   updateStartupPrefs();
 
   gDialogParams.SetInt(0, 1);
   /* Bug 257777 */
   gDialogParams.SetInt(1, document.getElementById("offlineState").checked ? 1 : 0);
-
-  return true;
 }
 
 function exitDialog() {
   updateStartupPrefs();
-
-  return true;
 }
 
 function updateStartupPrefs() {
   var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
   gProfileService.startWithLastProfile = autoSelectLastProfile.checked;
 }
 
 // handle key event on listboxes
--- a/toolkit/profile/content/profileSelection.xul
+++ b/toolkit/profile/content/profileSelection.xul
@@ -19,18 +19,16 @@
   id="profileWindow"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   class="non-resizable"
   title="&windowtitle.label;"
   orient="vertical"
   buttons="accept,cancel"
   style="width: 30em;"
   onload="startup();"
-  ondialogaccept="return acceptDialog()"
-  ondialogcancel="return exitDialog()"
   buttonlabelaccept="&start.label;"
   buttonlabelcancel="&exit.label;">
 
   <script type="application/javascript"
           src="chrome://global/content/customElements.js"/>
 
   <stringbundle id="bundle_profileManager"
                 src="chrome://mozapps/locale/profile/profileSelection.properties"/>