Bug 1399197 - Enable ESLint for osfile.jsm, nsURLFormatter.js and nsHelperAppDlg.js r=standard8
authorDan Banner <dbugs@thebanners.uk>
Wed, 10 Jan 2018 19:47:43 +0000
changeset 410650 9ac9d64f983563909721836f971048d13bf3f6af
parent 410649 3aa7da8fa0785f3cc6ff39a9fc7e3d0a93c624e5
child 410651 a6fba6948018606931d31509773c40f83d9c7396
push id33733
push useraciure@mozilla.com
push dateThu, 29 Mar 2018 22:05:29 +0000
treeherdermozilla-central@7ca58ce09779 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1399197
milestone61.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 1399197 - Enable ESLint for osfile.jsm, nsURLFormatter.js and nsHelperAppDlg.js r=standard8 MozReview-Commit-ID: JpW8i9QKxVL
.eslintignore
toolkit/components/osfile/osfile.jsm
toolkit/components/urlformatter/nsURLFormatter.js
toolkit/mozapps/downloads/nsHelperAppDlg.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -407,17 +407,14 @@ toolkit/modules/tests/xpcshell/test_task
 toolkit/components/microformats/test/**
 toolkit/components/microformats/microformat-shiv.js
 toolkit/components/reader/Readability.js
 toolkit/components/reader/JSDOMParser.js
 toolkit/components/payments/res/vendor/*
 
 # Uses preprocessing
 toolkit/content/widgets/wizard.xml
-toolkit/components/osfile/osfile.jsm
-toolkit/components/urlformatter/nsURLFormatter.js
 toolkit/modules/AppConstants.jsm
-toolkit/mozapps/downloads/nsHelperAppDlg.js
 toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
 
 # Third party
 toolkit/modules/third_party/**
 third_party/**
--- a/toolkit/components/osfile/osfile.jsm
+++ b/toolkit/components/osfile/osfile.jsm
@@ -5,16 +5,17 @@
 /**
  * Common front for various implementations of OS.File
  */
 
 if (typeof Components != "undefined") {
   this.EXPORTED_SYMBOLS = ["OS"];
   ChromeUtils.import("resource://gre/modules/osfile/osfile_async_front.jsm", this);
 } else {
+  /* eslint-env worker */
   importScripts("resource://gre/modules/workers/require.js");
 
   var SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
 
   // At this stage, we need to import all sources at once to avoid
   // a unique failure on tbpl + talos that seems caused by a
   // what looks like a nested event loop bug (see bug 794091).
   if (SharedAll.Constants.Win) {
--- a/toolkit/components/urlformatter/nsURLFormatter.js
+++ b/toolkit/components/urlformatter/nsURLFormatter.js
@@ -19,26 +19,20 @@ ChromeUtils.import("resource://gre/modul
 
 const PREF_APP_DISTRIBUTION           = "distribution.id";
 const PREF_APP_DISTRIBUTION_VERSION   = "distribution.version";
 
 ChromeUtils.defineModuleGetter(this, "UpdateUtils",
                                "resource://gre/modules/UpdateUtils.jsm");
 
 function nsURLFormatterService() {
-  XPCOMUtils.defineLazyGetter(this, "appInfo", function UFS_appInfo() {
-    return Cc["@mozilla.org/xre/app-info;1"].
-           getService(Ci.nsIXULAppInfo).
-           QueryInterface(Ci.nsIXULRuntime);
-  });
-
   XPCOMUtils.defineLazyGetter(this, "ABI", function UFS_ABI() {
     let ABI = "default";
     try {
-      ABI = this.appInfo.XPCOMABI;
+      ABI = Services.appinfo.XPCOMABI;
 
       if ("@mozilla.org/xpcom/mac-utils;1" in Cc) {
         // Mac universal build should report a different ABI than either macppc
         // or mactel.
         let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"]
                          .getService(Ci.nsIMacUtils);
         if (macutils && macutils.isUniversalBinary) {
           ABI = "Universal-gcc3";
@@ -58,103 +52,95 @@ function nsURLFormatterService() {
                   sysInfo.getProperty("version");
       OSVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
     } catch (e) {}
 
     return encodeURIComponent(OSVersion);
   });
 
   XPCOMUtils.defineLazyGetter(this, "distribution", function UFS_distribution() {
-    let distribution = { id: "default", version: "default" };
+    let defaults = Services.prefs.getDefaultBranch(null);
+    let id = defaults.getCharPref(PREF_APP_DISTRIBUTION, "default");
+    let version = defaults.getCharPref(PREF_APP_DISTRIBUTION_VERSION, "default");
 
-    let defaults = Services.prefs.getDefaultBranch(null);
-    try {
-      distribution.id = defaults.getCharPref(PREF_APP_DISTRIBUTION);
-    } catch (e) {}
-    try {
-      distribution.version = defaults.getCharPref(PREF_APP_DISTRIBUTION_VERSION);
-    } catch (e) {}
-
-    return distribution;
+    return {id, version};
   });
 }
 
 nsURLFormatterService.prototype = {
   classID: Components.ID("{e6156350-2be8-11db-a98b-0800200c9a66}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIURLFormatter]),
 
   _defaults: {
     LOCALE:           () => Services.locale.getAppLocaleAsLangTag(),
-    REGION:           function() {
+    REGION() {
       try {
         // When the geoip lookup failed to identify the region, we fallback to
         // the 'ZZ' region code to mean 'unknown'.
         return Services.prefs.getCharPref("browser.search.region") || "ZZ";
-      } catch(e) {
+      } catch (e) {
         return "ZZ";
       }
     },
-    VENDOR:           function() { return this.appInfo.vendor; },
-    NAME:             function() { return this.appInfo.name; },
-    ID:               function() { return this.appInfo.ID; },
-    VERSION:          function() { return this.appInfo.version; },
-    MAJOR_VERSION:    function() { return this.appInfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); },
-    APPBUILDID:       function() { return this.appInfo.appBuildID; },
-    PLATFORMVERSION:  function() { return this.appInfo.platformVersion; },
-    PLATFORMBUILDID:  function() { return this.appInfo.platformBuildID; },
-    APP:              function() { return this.appInfo.name.toLowerCase().replace(/ /, ""); },
-    OS:               function() { return this.appInfo.OS; },
-    XPCOMABI:         function() { return this.ABI; },
-    BUILD_TARGET:     function() { return this.appInfo.OS + "_" + this.ABI; },
-    OS_VERSION:       function() { return this.OSVersion; },
+    VENDOR() { return Services.appinfo.vendor; },
+    NAME() { return Services.appinfo.name; },
+    ID() { return Services.appinfo.ID; },
+    VERSION() { return Services.appinfo.version; },
+    MAJOR_VERSION() { return Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); },
+    APPBUILDID() { return Services.appinfo.appBuildID; },
+    PLATFORMVERSION() { return Services.appinfo.platformVersion; },
+    PLATFORMBUILDID() { return Services.appinfo.platformBuildID; },
+    APP() { return Services.appinfo.name.toLowerCase().replace(/ /, ""); },
+    OS() { return Services.appinfo.OS; },
+    XPCOMABI() { return this.ABI; },
+    BUILD_TARGET() { return Services.appinfo.OS + "_" + this.ABI; },
+    OS_VERSION() { return this.OSVersion; },
     CHANNEL:          () => UpdateUtils.UpdateChannel,
     MOZILLA_API_KEY:  () => AppConstants.MOZ_MOZILLA_API_KEY,
     GOOGLE_API_KEY:   () => AppConstants.MOZ_GOOGLE_API_KEY,
-    BING_API_CLIENTID:() => AppConstants.MOZ_BING_API_CLIENTID,
+    BING_API_CLIENTID: () => AppConstants.MOZ_BING_API_CLIENTID,
     BING_API_KEY:     () => AppConstants.MOZ_BING_API_KEY,
-    DISTRIBUTION:     function() { return this.distribution.id; },
-    DISTRIBUTION_VERSION: function() { return this.distribution.version; }
+    DISTRIBUTION() { return this.distribution.id; },
+    DISTRIBUTION_VERSION() { return this.distribution.version; }
   },
 
   formatURL: function uf_formatURL(aFormat) {
     var _this = this;
     var replacementCallback = function(aMatch, aKey) {
       if (aKey in _this._defaults) {
         return _this._defaults[aKey].call(_this);
       }
       Cu.reportError("formatURL: Couldn't find value for key: " + aKey);
       return aMatch;
-    }
+    };
     return aFormat.replace(/%([A-Z_]+)%/g, replacementCallback);
   },
 
   formatURLPref: function uf_formatURLPref(aPref) {
     var format = null;
-    var PS = Cc['@mozilla.org/preferences-service;1'].
-             getService(Ci.nsIPrefBranch);
 
     try {
-      format = PS.getStringPref(aPref);
-    } catch(ex) {
+      format = Services.prefs.getStringPref(aPref);
+    } catch (ex) {
       Cu.reportError("formatURLPref: Couldn't get pref: " + aPref);
       return "about:blank";
     }
 
-    if (!PS.prefHasUserValue(aPref) &&
+    if (!Services.prefs.prefHasUserValue(aPref) &&
         /^(data:text\/plain,.+=.+|chrome:\/\/.+\/locale\/.+\.properties)$/.test(format)) {
       // This looks as if it might be a localised preference
       try {
-        format = PS.getComplexValue(aPref, Ci.nsIPrefLocalizedString).data;
-      } catch(ex) {}
+        format = Services.prefs.getComplexValue(aPref, Ci.nsIPrefLocalizedString).data;
+      } catch (ex) {}
     }
 
     return this.formatURL(format);
   },
 
   trimSensitiveURLs: function uf_trimSensitiveURLs(aMsg) {
     // Only the google API key is sensitive for now.
-    return AppConstants.MOZ_GOOGLE_API_KEY ? aMsg.replace(RegExp(AppConstants.MOZ_GOOGLE_API_KEY, 'g'),
+    return AppConstants.MOZ_GOOGLE_API_KEY ? aMsg.replace(RegExp(AppConstants.MOZ_GOOGLE_API_KEY, "g"),
                                                  "[trimmed-google-api-key]")
                                   : aMsg;
   }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsURLFormatterService]);
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -3,89 +3,88 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "EnableDelayHelper",
                                "resource://gre/modules/SharedPromptUtils.jsm");
 
-///////////////////////////////////////////////////////////////////////////////
-//// Helper Functions
+// /////////////////////////////////////////////////////////////////////////////
+// // Helper Functions
 
 /**
  * Determines if a given directory is able to be used to download to.
  *
  * @param aDirectory
  *        The directory to check.
  * @return true if we can use the directory, false otherwise.
  */
-function isUsableDirectory(aDirectory)
-{
+function isUsableDirectory(aDirectory) {
   return aDirectory.exists() && aDirectory.isDirectory() &&
          aDirectory.isWritable();
 }
 
 // Web progress listener so we can detect errors while mLauncher is
 // streaming the data to a temporary file.
 function nsUnknownContentTypeDialogProgressListener(aHelperAppDialog) {
   this.helperAppDlg = aHelperAppDialog;
 }
 
 nsUnknownContentTypeDialogProgressListener.prototype = {
   // nsIWebProgressListener methods.
   // Look for error notifications and display alert to user.
-  onStatusChange: function( aWebProgress, aRequest, aStatus, aMessage ) {
+  onStatusChange( aWebProgress, aRequest, aStatus, aMessage ) {
     if ( aStatus != Cr.NS_OK ) {
       // Display error alert (using text supplied by back-end).
       // FIXME this.dialog is undefined?
       Services.prompt.alert( this.dialog, this.helperAppDlg.mTitle, aMessage );
       // Close the dialog.
       this.helperAppDlg.onCancel();
       if ( this.helperAppDlg.mDialog ) {
         this.helperAppDlg.mDialog.close();
       }
     }
   },
 
   // Ignore onProgressChange, onProgressChange64, onStateChange, onLocationChange, onSecurityChange, and onRefreshAttempted notifications.
-  onProgressChange: function( aWebProgress,
-                              aRequest,
-                              aCurSelfProgress,
-                              aMaxSelfProgress,
-                              aCurTotalProgress,
-                              aMaxTotalProgress ) {
+  onProgressChange(aWebProgress,
+                   aRequest,
+                   aCurSelfProgress,
+                   aMaxSelfProgress,
+                   aCurTotalProgress,
+                   aMaxTotalProgress) {
   },
 
-  onProgressChange64: function( aWebProgress,
-                                aRequest,
-                                aCurSelfProgress,
-                                aMaxSelfProgress,
-                                aCurTotalProgress,
-                                aMaxTotalProgress ) {
+  onProgressChange64(aWebProgress,
+                     aRequest,
+                     aCurSelfProgress,
+                     aMaxSelfProgress,
+                     aCurTotalProgress,
+                     aMaxTotalProgress) {
   },
 
 
 
-  onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {
+  onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
   },
 
-  onLocationChange: function( aWebProgress, aRequest, aLocation, aFlags ) {
+  onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
   },
 
-  onSecurityChange: function( aWebProgress, aRequest, state ) {
+  onSecurityChange(aWebProgress, aRequest, state) {
   },
 
-  onRefreshAttempted: function( aWebProgress, aURI, aDelay, aSameURI ) {
+  onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI) {
     return true;
   }
 };
 
-///////////////////////////////////////////////////////////////////////////////
-//// nsUnknownContentTypeDialog
+// /////////////////////////////////////////////////////////////////////////////
+// // nsUnknownContentTypeDialog
 
 /* This file implements the nsIHelperAppLauncherDialog interface.
  *
  * The implementation consists of a JavaScript "class" named nsUnknownContentTypeDialog,
  * comprised of:
  *   - a JS constructor function
  *   - a prototype providing all the interface methods and implementation stuff
  *
@@ -115,33 +114,33 @@ function nsUnknownContentTypeDialog() {
   this.givenDefaultApp = false;
   this.updateSelf = true;
   this.mTitle    = "";
 }
 
 nsUnknownContentTypeDialog.prototype = {
   classID: Components.ID("{F68578EB-6EC2-4169-AE19-8C6243F0ABE1}"),
 
-  nsIMIMEInfo  : Ci.nsIMIMEInfo,
+  nsIMIMEInfo: Ci.nsIMIMEInfo,
 
-  QueryInterface: function (iid) {
+  QueryInterface(iid) {
     if (!iid.equals(Ci.nsIHelperAppLauncherDialog) &&
         !iid.equals(Ci.nsITimerCallback) &&
         !iid.equals(Ci.nsISupports)) {
       throw Cr.NS_ERROR_NO_INTERFACE;
     }
     return this;
   },
 
   // ---------- nsIHelperAppLauncherDialog methods ----------
 
   // show: Open XUL dialog using window watcher.  Since the dialog is not
   //       modal, it needs to be a top level window and the way to open
   //       one of those is via that route).
-  show: function(aLauncher, aContext, aReason)  {
+  show(aLauncher, aContext, aReason) {
     this.mLauncher = aLauncher;
     this.mContext  = aContext;
     this.mReason   = aReason;
 
     // Cache some information in case this context goes away:
     try {
       let parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
       this._mDownloadDir = new downloadModule.DownloadLastDir(parent);
@@ -154,31 +153,29 @@ nsUnknownContentTypeDialog.prototype = {
                         .createInstance(nsITimer);
     this._showTimer.initWithCallback(this, 0, nsITimer.TYPE_ONE_SHOT);
   },
 
   // When opening from new tab, if tab closes while dialog is opening,
   // (which is a race condition on the XUL file being cached and the timer
   // in nsExternalHelperAppService), the dialog gets a blur and doesn't
   // activate the OK button.  So we wait a bit before doing opening it.
-  reallyShow: function() {
+  reallyShow() {
     try {
       let ir = this.mContext.QueryInterface(Ci.nsIInterfaceRequestor);
       let docShell = ir.getInterface(Ci.nsIDocShell);
       let rootWin = docShell.QueryInterface(Ci.nsIDocShellTreeItem)
                                  .rootTreeItem
                                  .QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsIDOMWindow);
-      let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]
-                 .getService(Ci.nsIWindowWatcher);
-      this.mDialog = ww.openWindow(rootWin,
-                                   "chrome://mozapps/content/downloads/unknownContentType.xul",
-                                   null,
-                                   "chrome,centerscreen,titlebar,dialog=yes,dependent",
-                                   null);
+      this.mDialog = Services.ww.openWindow(rootWin,
+                                            "chrome://mozapps/content/downloads/unknownContentType.xul",
+                                            null,
+                                            "chrome,centerscreen,titlebar,dialog=yes,dependent",
+                                            null);
     } catch (ex) {
       // The containing window may have gone away.  Break reference
       // cycles and stop doing the download.
       this.mLauncher.cancel(Cr.NS_BINDING_ABORTED);
       return;
     }
 
     // Hook this object to the dialog.
@@ -192,33 +189,31 @@ nsUnknownContentTypeDialog.prototype = {
     this.mLauncher.setWebProgressListener(progressListener);
   },
 
   //
   // displayBadPermissionAlert()
   //
   // Diplay an alert panel about the bad permission of folder/directory.
   //
-  displayBadPermissionAlert: function () {
+  displayBadPermissionAlert() {
     let bundle =
       Services.strings.createBundle("chrome://mozapps/locale/downloads/unknownContentType.properties");
 
     Services.prompt.alert(this.dialog,
                    bundle.GetStringFromName("badPermissions.title"),
                    bundle.GetStringFromName("badPermissions"));
   },
 
-  promptForSaveToFileAsync: function(aLauncher, aContext, aDefaultFileName,
+  promptForSaveToFileAsync(aLauncher, aContext, aDefaultFileName,
                                      aSuggestedFileExtension, aForcePrompt) {
     var result = null;
 
     this.mLauncher = aLauncher;
 
-    let prefs = Cc["@mozilla.org/preferences-service;1"]
-                  .getService(Ci.nsIPrefBranch);
     let bundle =
       Services.strings
               .createBundle("chrome://mozapps/locale/downloads/unknownContentType.properties");
 
     let parent;
     let gDownloadLastDir;
     try {
       parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
@@ -247,28 +242,27 @@ nsUnknownContentTypeDialog.prototype = {
                        "This should never happen.");
       }
     }
 
     (async () => {
       if (!aForcePrompt) {
         // Check to see if the user wishes to auto save to the default download
         // folder without prompting. Note that preference might not be set.
-        let autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false);
+        let autodownload = Services.prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false);
 
         if (autodownload) {
           // Retrieve the user's default download directory
           let preferredDir = await Downloads.getPreferredDownloadsDirectory();
           let defaultFolder = new FileUtils.File(preferredDir);
 
           try {
             result = this.validateLeafName(defaultFolder, aDefaultFileName,
                                            aSuggestedFileExtension);
-          }
-          catch (ex) {
+          } catch (ex) {
             // When the default download directory is write-protected,
             // prompt the user for a different target file.
           }
 
           // Check to make sure we have a valid directory, otherwise, prompt
           if (result) {
             // Notifications for CloudStorage API consumers to show offer
             // prompts while downloading. See Bug 1365129
@@ -287,22 +281,20 @@ nsUnknownContentTypeDialog.prototype = {
       picker.init(parent, windowTitle, nsIFilePicker.modeSave);
       if (aDefaultFileName) {
         picker.defaultString = this.getFinalLeafName(aDefaultFileName);
       }
 
       if (aSuggestedFileExtension) {
         // aSuggestedFileExtension includes the period, so strip it
         picker.defaultExtension = aSuggestedFileExtension.substring(1);
-      }
-      else {
+      } else {
         try {
           picker.defaultExtension = this.mLauncher.MIMEInfo.primaryExtension;
-        }
-        catch (ex) { }
+        } catch (ex) { }
       }
 
       var wildCardExtension = "*";
       if (aSuggestedFileExtension) {
         wildCardExtension += aSuggestedFileExtension;
         picker.appendFilter(this.mLauncher.MIMEInfo.description, wildCardExtension);
       }
 
@@ -333,31 +325,29 @@ nsUnknownContentTypeDialog.prototype = {
           if (result) {
             try {
               // Remove the file so that it's not there when we ensure non-existence later;
               // this is safe because for the file to exist, the user would have had to
               // confirm that he wanted the file overwritten.
               // Only remove file if final name exists
               if (result.exists() && this.getFinalLeafName(result.leafName) == result.leafName)
                 result.remove(false);
-            }
-            catch (ex) {
+            } catch (ex) {
               // As it turns out, the failure to remove the file, for example due to
               // permission error, will be handled below eventually somehow.
             }
 
             var newDir = result.parent.QueryInterface(Ci.nsIFile);
 
             // Do not store the last save directory as a pref inside the private browsing mode
             gDownloadLastDir.setFile(aLauncher.source, newDir);
 
             try {
               result = this.validateLeafName(newDir, result.leafName, null);
-            }
-            catch (ex) {
+            } catch (ex) {
               // When the chosen download directory is write-protected,
               // display an informative error message.
               // In all cases, download will be stopped.
 
               if (ex.result == Cr.NS_ERROR_FILE_ACCESS_DENIED) {
                 this.displayBadPermissionAlert();
                 aLauncher.saveDestinationAvailable(null);
                 return;
@@ -366,18 +356,17 @@ nsUnknownContentTypeDialog.prototype = {
             }
           }
           aLauncher.saveDestinationAvailable(result);
         });
       });
     })().catch(Cu.reportError);
   },
 
-  getFinalLeafName: function (aLeafName, aFileExt)
-  {
+  getFinalLeafName(aLeafName, aFileExt) {
     return DownloadPaths.sanitize(aLeafName) ||
            "unnamed" + (aFileExt ? "." + aFileExt : "");
   },
 
   /**
    * Ensures that a local folder/file combination does not already exist in
    * the file system (or finds such a combination with a reasonably similar
    * leaf name), creates the corresponding file, and returns it.
@@ -390,18 +379,17 @@ nsUnknownContentTypeDialog.prototype = {
    * @param   aFileExt
    *          the extension of the file, if one is known; this will be ignored
    *          if aLeafName is non-empty
    * @return  nsIFile
    *          the created file
    * @throw   an error such as permission doesn't allow creation of
    *          file, etc.
    */
-  validateLeafName: function (aLocalFolder, aLeafName, aFileExt)
-  {
+  validateLeafName(aLocalFolder, aLeafName, aFileExt) {
     if (!(aLocalFolder && isUsableDirectory(aLocalFolder))) {
       throw new Components.Exception("Destination directory non-existing or permission error",
                                      Cr.NS_ERROR_FILE_ACCESS_DENIED);
     }
 
     aLeafName = this.getFinalLeafName(aLeafName, aFileExt);
     aLocalFolder.append(aLeafName);
 
@@ -427,17 +415,17 @@ nsUnknownContentTypeDialog.prototype = {
     }
 
     return createdFile;
   },
 
   // ---------- implementation methods ----------
 
   // initDialog:  Fill various dialog fields with initial content.
-  initDialog : function() {
+  initDialog() {
     // Put file name in window title.
     var suggestedFileName = this.mLauncher.suggestedFileName;
 
     // 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;
 
@@ -487,18 +475,17 @@ nsUnknownContentTypeDialog.prototype = {
       acceptButton.label = this.dialogElement("strings")
                                .getString("unknownAccept.label");
       acceptButton.setAttribute("icon", "save");
       this.mDialog.document.documentElement.getButton("cancel").label = this.dialogElement("strings").getString("unknownCancel.label");
       // hide other handler
       this.dialogElement("openHandler").collapsed = true;
       // set save as the selected option
       this.dialogElement("mode").selectedItem = this.dialogElement("save");
-    }
-    else {
+    } else {
       this.initAppAndSaveToDiskValues();
 
       // Initialize "always ask me" box. This should always be disabled
       // and set to true for the ambiguous type application/octet-stream.
       // We don't also check for application/x-msdownload here since we
       // want users to be able to autodownload .exe files.
       var rememberChoice = this.dialogElement("rememberChoice");
 
@@ -519,18 +506,17 @@ nsUnknownContentTypeDialog.prototype = {
       // var mimeService = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
       // var type = mimeService.getTypeFromURI(this.mLauncher.source);
       // this.realMIMEInfo = mimeService.getFromTypeAndExtension(type, "");
 
       // if (type == "application/octet-stream") {
       if (shouldntRememberChoice) {
         rememberChoice.checked = false;
         rememberChoice.disabled = true;
-      }
-      else {
+      } else {
         rememberChoice.checked = !this.mLauncher.MIMEInfo.alwaysAskBeforeHandling &&
                                  this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.handleInternally;
       }
       this.toggleRememberChoice(rememberChoice);
 
       // XXXben - menulist won't init properly, hack.
       var openHandler = this.dialogElement("openHandler");
       openHandler.remove();
@@ -546,41 +532,40 @@ nsUnknownContentTypeDialog.prototype = {
       },
       enableDialog: () => {
         this.mDialog.document.documentElement.getButton("accept").disabled = false;
       },
       focusTarget: this.mDialog
     });
   },
 
-  notify: function (aTimer) {
+  notify(aTimer) {
     if (aTimer == this._showTimer) {
       if (!this.mDialog) {
         this.reallyShow();
       }
       // The timer won't release us, so we have to release it.
       this._showTimer = null;
-    }
-    else if (aTimer == this._saveToDiskTimer) {
+    } else if (aTimer == this._saveToDiskTimer) {
       // Since saveToDisk may open a file picker and therefore block this routine,
       // we should only call it once the dialog is closed.
       this.mLauncher.saveToDisk(null, false);
       this._saveToDiskTimer = null;
     }
   },
 
-  postShowCallback: function () {
+  postShowCallback() {
     this.mDialog.sizeToContent();
 
     // Set initial focus
     this.dialogElement("mode").focus();
   },
 
   // initIntro:
-  initIntro: function(url, filename, displayname) {
+  initIntro(url, filename, displayname) {
     this.dialogElement( "location" ).value = displayname;
     this.dialogElement( "location" ).setAttribute("realname", filename);
     this.dialogElement( "location" ).setAttribute("tooltiptext", displayname);
 
     // if mSourcePath is a local file, then let's use the pretty path name
     // instead of an ugly url...
     var pathString;
     if (url instanceof Ci.nsIFileURL) {
@@ -613,40 +598,38 @@ nsUnknownContentTypeDialog.prototype = {
     // 1. Try to use the pretty description of the type, if one is available.
     var typeString = mimeInfo.description;
 
     if (typeString == "") {
       // 2. If there is none, use the extension to identify the file, e.g. "ZIP file"
       var primaryExtension = "";
       try {
         primaryExtension = mimeInfo.primaryExtension;
-      }
-      catch (ex) {
+      } catch (ex) {
       }
       if (primaryExtension != "")
         typeString = this.dialogElement("strings").getFormattedString("fileType", [primaryExtension.toUpperCase()]);
       // 3. If we can't even do that, just give up and show the MIME type.
       else
         typeString = mimeInfo.MIMEType;
     }
     // When the length is unknown, contentLength would be -1
     if (this.mLauncher.contentLength >= 0) {
       let [size, unit] = DownloadUtils.
                          convertByteUnits(this.mLauncher.contentLength);
       type.value = this.dialogElement("strings")
-                       .getFormattedString("orderedFileSizeWithType", 
+                       .getFormattedString("orderedFileSizeWithType",
                                            [typeString, size, unit]);
-    }
-    else {
+    } else {
       type.value = typeString;
     }
   },
 
   // Returns true if opening the default application makes sense.
-  openWithDefaultOK: function() {
+  openWithDefaultOK() {
     // The checking is different on Windows...
     if (AppConstants.platform == "win") {
       // Windows presents some special cases.
       // We need to prevent use of "system default" when the file is
       // executable (so the user doesn't launch nasty programs downloaded
       // from the web), and, enable use of "system default" if it isn't
       // executable (because we will prompt the user for the default app
       // in that case).
@@ -656,53 +639,52 @@ nsUnknownContentTypeDialog.prototype = {
     }
     // On other platforms, default is Ok if there is a default app.
     // Note that nsIMIMEInfo providers need to ensure that this holds true
     // on each platform.
     return this.mLauncher.MIMEInfo.hasDefaultHandler;
   },
 
   // Set "default" application description field.
-  initDefaultApp: function() {
+  initDefaultApp() {
     // Use description, if we can get one.
     var desc = this.mLauncher.MIMEInfo.defaultDescription;
     if (desc) {
       var defaultApp = this.dialogElement("strings").getFormattedString("defaultApp", [desc]);
       this.dialogElement("defaultHandler").label = defaultApp;
-    }
-    else {
+    } else {
       this.dialogElement("modeDeck").setAttribute("selectedIndex", "1");
       // Hide the default handler item too, in case the user picks a
       // custom handler at a later date which triggers the menulist to show.
       this.dialogElement("defaultHandler").hidden = true;
     }
   },
 
   // getPath:
-  getPath: function (aFile) {
+  getPath(aFile) {
     if (AppConstants.platform == "macosx") {
       return aFile.leafName || aFile.path;
     }
     return aFile.path;
   },
 
   // initAppAndSaveToDiskValues:
-  initAppAndSaveToDiskValues: function() {
+  initAppAndSaveToDiskValues() {
     var modeGroup = this.dialogElement("mode");
 
     // We don't let users open .exe files or random binary data directly
     // from the browser at the moment because of security concerns.
     var openWithDefaultOK = this.openWithDefaultOK();
     var mimeType = this.mLauncher.MIMEInfo.MIMEType;
+    var openHandler = this.dialogElement("openHandler");
     if (this.mLauncher.targetFileIsExecutable || (
       (mimeType == "application/octet-stream" ||
        mimeType == "application/x-msdownload") &&
         !openWithDefaultOK)) {
       this.dialogElement("open").disabled = true;
-      var openHandler = this.dialogElement("openHandler");
       openHandler.disabled = true;
       openHandler.selectedItem = null;
       modeGroup.selectedItem = this.dialogElement("save");
       return;
     }
 
     // Fill in helper app info, if there is any.
     try {
@@ -722,17 +704,16 @@ nsUnknownContentTypeDialog.prototype = {
         this.chosenApp.executable.path) {
       otherHandler.setAttribute("path",
                                 this.getPath(this.chosenApp.executable));
 
       otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
       otherHandler.hidden = false;
     }
 
-    var openHandler = this.dialogElement("openHandler");
     openHandler.selectedIndex = 0;
     var defaultOpenHandler = this.dialogElement("defaultHandler");
 
     if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useSystemDefault) {
       // Open (using system default).
       modeGroup.selectedItem = this.dialogElement("open");
     } else if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useHelperApp) {
       // Open with given helper app.
@@ -757,95 +738,92 @@ nsUnknownContentTypeDialog.prototype = {
       }
     }
 
     otherHandler.nextSibling.hidden = otherHandler.nextSibling.nextSibling.hidden = false;
     this.updateOKButton();
   },
 
   // Returns the user-selected application
-  helperAppChoice: function() {
+  helperAppChoice() {
     return this.chosenApp;
   },
 
   get saveToDisk() {
     return this.dialogElement("save").selected;
   },
 
   get useOtherHandler() {
     return this.dialogElement("open").selected && this.dialogElement("openHandler").selectedIndex == 1;
   },
 
   get useSystemDefault() {
     return this.dialogElement("open").selected && this.dialogElement("openHandler").selectedIndex == 0;
   },
 
-  toggleRememberChoice: function (aCheckbox) {
+  toggleRememberChoice(aCheckbox) {
     this.dialogElement("settingsChange").hidden = !aCheckbox.checked;
     this.mDialog.sizeToContent();
   },
 
-  openHandlerCommand: function () {
+  openHandlerCommand() {
     var openHandler = this.dialogElement("openHandler");
     if (openHandler.selectedItem.id == "choose")
       this.chooseApp();
     else
       openHandler.setAttribute("lastSelectedItemID", openHandler.selectedItem.id);
   },
 
-  updateOKButton: function() {
+  updateOKButton() {
     var ok = false;
     if (this.dialogElement("save").selected) {
       // This is always OK.
       ok = true;
-    }
-    else if (this.dialogElement("open").selected) {
+    } else if (this.dialogElement("open").selected) {
       switch (this.dialogElement("openHandler").selectedIndex) {
       case 0:
         // No app need be specified in this case.
         ok = true;
         break;
       case 1:
         // only enable the OK button if we have a default app to use or if
         // the user chose an app....
-        ok = this.chosenApp || /\S/.test(this.dialogElement("otherHandler").getAttribute("path")); 
+        ok = this.chosenApp || /\S/.test(this.dialogElement("otherHandler").getAttribute("path"));
         break;
       }
     }
 
     // Enable Ok button if ok to press.
     this.mDialog.document.documentElement.getButton("accept").disabled = !ok;
   },
 
   // Returns true iff the user-specified helper app has been modified.
-  appChanged: function() {
+  appChanged() {
     return this.helperAppChoice() != this.mLauncher.MIMEInfo.preferredApplicationHandler;
   },
 
-  updateMIMEInfo: function() {
+  updateMIMEInfo() {
     // Don't update mime type preferences when the preferred action is set to
     // the internal handler -- this dialog is the result of the handler fallback
     // (e.g. Content-Disposition was set as attachment)
     var discardUpdate = this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.handleInternally &&
                         !this.dialogElement("rememberChoice").checked;
 
     var needUpdate = false;
     // If current selection differs from what's in the mime info object,
     // then we need to update.
     if (this.saveToDisk) {
       needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.saveToDisk;
       if (needUpdate)
         this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.saveToDisk;
-    }
-    else if (this.useSystemDefault) {
+    } else if (this.useSystemDefault) {
       needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.useSystemDefault;
       if (needUpdate)
         this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.useSystemDefault;
-    }
-    else {
+    } else {
       // For "open with", we need to check both preferred action and whether the user chose
       // a new app.
       needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.useHelperApp || this.appChanged();
       if (needUpdate) {
         this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.useHelperApp;
         // App may have changed - Update application
         var app = this.helperAppChoice();
         this.mLauncher.MIMEInfo.preferredApplicationHandler = app;
@@ -865,24 +843,24 @@ nsUnknownContentTypeDialog.prototype = {
     // Make sure mime info has updated setting for the "always ask" flag.
     this.mLauncher.MIMEInfo.alwaysAskBeforeHandling = !this.dialogElement("rememberChoice").checked;
 
     return needUpdate && !discardUpdate;
   },
 
   // See if the user changed things, and if so, store this mime type in the
   // handler service.
-  updateHelperAppPref: function() {
+  updateHelperAppPref() {
     var handlerInfo = this.mLauncher.MIMEInfo;
     var hs = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService);
     hs.store(handlerInfo);
   },
 
   // onOK:
-  onOK: function() {
+  onOK() {
     // 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")]);
@@ -932,79 +910,77 @@ nsUnknownContentTypeDialog.prototype = {
         */
 
         // see @notify
         // we cannot use opener's setTimeout, see bug 420405
         this._saveToDiskTimer = Cc["@mozilla.org/timer;1"]
                                   .createInstance(nsITimer);
         this._saveToDiskTimer.initWithCallback(this, 0,
                                                nsITimer.TYPE_ONE_SHOT);
-      }
-      else
+      } else
         this.mLauncher.launchWithApplication(null, false);
 
       // 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) { }
+    } catch (e) { }
 
     // Unhook dialog from this object.
     this.mDialog.dialog = null;
 
     // Close up dialog by returning true.
     return true;
   },
 
   // onCancel:
-  onCancel: function() {
+  onCancel() {
     // Remove our web progress listener.
     this.mLauncher.setWebProgressListener(null);
 
     // Cancel app launcher.
     try {
       this.mLauncher.cancel(Cr.NS_BINDING_ABORTED);
-    } catch(exception) {
+    } catch (exception) {
     }
 
     // Unhook dialog from this object.
     this.mDialog.dialog = null;
 
     // Close up dialog by returning true.
     return true;
   },
 
   // dialogElement:  Convenience.
-  dialogElement: function(id) {
+  dialogElement(id) {
     return this.mDialog.document.getElementById(id);
   },
 
   // Retrieve the pretty description from the file
-  getFileDisplayName: function getFileDisplayName(file)
-  {
+  getFileDisplayName: function getFileDisplayName(file) {
     if (AppConstants.platform == "win") {
       if (file instanceof Ci.nsILocalFileWin) {
         try {
           return file.getVersionInfoField("FileDescription");
         } catch (e) {}
       }
     } else if (AppConstants.platform == "macosx") {
       if (file instanceof Ci.nsILocalFileMac) {
         try {
           return file.bundleDisplayName;
         } catch (e) {}
       }
     }
     return file.leafName;
   },
 
-  finishChooseApp: function() {
+  finishChooseApp() {
     if (this.chosenApp) {
       // Show the "handler" menulist since we have a (user-specified)
       // application now.
       this.dialogElement("modeDeck").setAttribute("selectedIndex", "0");
 
       // Update dialog.
       var otherHandler = this.dialogElement("otherHandler");
       otherHandler.removeAttribute("hidden");
@@ -1012,33 +988,32 @@ nsUnknownContentTypeDialog.prototype = {
       if (AppConstants.platform == "win")
         otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
       else
         otherHandler.label = this.chosenApp.name;
       this.dialogElement("openHandler").selectedIndex = 1;
       this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler");
 
       this.dialogElement("mode").selectedItem = this.dialogElement("open");
-    }
-    else {
+    } else {
       var openHandler = this.dialogElement("openHandler");
       var lastSelectedID = openHandler.getAttribute("lastSelectedItemID");
       if (!lastSelectedID)
         lastSelectedID = "defaultHandler";
       openHandler.selectedItem = this.dialogElement(lastSelectedID);
     }
   },
   // chooseApp:  Open file picker and prompt user for application.
-  chooseApp: function() {
+  chooseApp() {
     if (AppConstants.platform == "win") {
       // Protect against the lack of an extension
       var fileExtension = "";
       try {
         fileExtension = this.mLauncher.MIMEInfo.primaryExtension;
-      } catch(ex) {
+      } catch (ex) {
       }
 
       // Try to use the pretty description of the type, if one is available.
       var typeString = this.mLauncher.MIMEInfo.description;
 
       if (!typeString) {
         // If there is none, use the extension to
         // identify the file, e.g. "ZIP file"
@@ -1112,39 +1087,16 @@ nsUnknownContentTypeDialog.prototype = {
 
     this.finishChooseApp();
   },
 
   // Turn this on to get debugging messages.
   debug: false,
 
   // Dump text (if debug is on).
-  dump: function( text ) {
+  dump( text ) {
     if ( this.debug ) {
       dump( text );
     }
   },
-
-  // dumpObj:
-  dumpObj: function( spec ) {
-    var val = "<undefined>";
-    try {
-      val = eval( "this."+spec ).toString();
-    } catch( exception ) {
-    }
-    this.dump( spec + "=" + val + "\n" );
-  },
-
-  // dumpObjectProperties
-  dumpObjectProperties: function( desc, obj ) {
-    for( prop in obj ) {
-      this.dump( desc + "." + prop + "=" );
-      var val = "<undefined>";
-      try {
-        val = obj[ prop ];
-      } catch ( exception ) {
-      }
-      this.dump( val + "\n" );
-    }
-  }
-}
+};
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsUnknownContentTypeDialog]);