Bug 1394820 - Enable ESLint for DownloadIntegration.jsm r=standard8
authorDan Banner <dbugs@thebanners.uk>
Tue, 29 Aug 2017 18:57:11 +0100
changeset 429584 341d93b956bed88f59d42d3ed9c73e62e4f2de31
parent 429583 dd814ec7af065e4764ec6c65d46c0b977292ff42
child 429585 929a062222d831fdeded632296d03f6d52752ffe
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1394820
milestone57.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 1394820 - Enable ESLint for DownloadIntegration.jsm r=standard8 MozReview-Commit-ID: INwMSXSJ31f
.eslintignore
toolkit/components/jsdownloads/src/DownloadIntegration.jsm
--- a/.eslintignore
+++ b/.eslintignore
@@ -343,17 +343,16 @@ toolkit/modules/tests/xpcshell/test_task
 # External code:
 toolkit/components/microformats/test/**
 toolkit/components/microformats/microformat-shiv.js
 toolkit/components/reader/Readability.js
 toolkit/components/reader/JSDOMParser.js
 
 # Uses preprocessing
 toolkit/content/widgets/wizard.xml
-toolkit/components/jsdownloads/src/DownloadIntegration.jsm
 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/**
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -75,16 +75,17 @@ XPCOMUtils.defineLazyServiceGetter(this,
            Ci.nsIApplicationReputationService);
 
 XPCOMUtils.defineLazyServiceGetter(this, "volumeService",
                                    "@mozilla.org/telephony/volume-service;1",
                                    "nsIVolumeService");
 
 // We have to use the gCombinedDownloadIntegration identifier because, in this
 // module only, the DownloadIntegration identifier refers to the base version.
+/* global gCombinedDownloadIntegration:false */
 Integration.downloads.defineModuleGetter(this, "gCombinedDownloadIntegration",
             "resource://gre/modules/DownloadIntegration.jsm",
             "DownloadIntegration");
 
 const Timer = Components.Constructor("@mozilla.org/timer;1", "nsITimer",
                                      "initWithCallback");
 
 /**
@@ -271,17 +272,17 @@ this.DownloadIntegration = {
       this._downloadsDirectory = gEnvironment.get("DOWNLOADS_DIRECTORY");
       if (!this._downloadsDirectory) {
         throw new Components.Exception("DOWNLOADS_DIRECTORY is not set.",
                                        Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH);
       }
     } else {
       try {
         this._downloadsDirectory = this._getDirectory("DfltDwnld");
-      } catch(e) {
+      } catch (e) {
         this._downloadsDirectory = await this._createDownloadsDirectory("Home");
       }
     }
 
     return this._downloadsDirectory;
   },
   _downloadsDirectory: null,
 
@@ -290,38 +291,38 @@ this.DownloadIntegration = {
    *
    * @return {Promise}
    * @resolves The downloads directory string path.
    */
   async getPreferredDownloadsDirectory() {
     let directoryPath = null;
     let prefValue = Services.prefs.getIntPref("browser.download.folderList", 1);
 
-    switch(prefValue) {
+    switch (prefValue) {
       case 0: // Desktop
         directoryPath = this._getDirectory("Desk");
         break;
       case 1: // Downloads
         directoryPath = await this.getSystemDownloadsDirectory();
         break;
       case 2: // Custom
         try {
           let directory = Services.prefs.getComplexValue("browser.download.dir",
                                                          Ci.nsIFile);
           directoryPath = directory.path;
           await OS.File.makeDir(directoryPath, { ignoreExisting: true });
-        } catch(ex) {
+        } catch (ex) {
           // Either the preference isn't set or the directory cannot be created.
           directoryPath = await this.getSystemDownloadsDirectory();
         }
         break;
       case 3: // Cloud Storage
         try {
           directoryPath = await CloudStorage.getDownloadFolder();
-        } catch(ex) {}
+        } catch (ex) {}
         if (!directoryPath) {
           directoryPath = await this.getSystemDownloadsDirectory();
         }
         break;
       default:
         directoryPath = await this.getSystemDownloadsDirectory();
     }
     return directoryPath;
@@ -672,17 +673,17 @@ this.DownloadIntegration = {
    * Asks for confirmation for launching the specified executable file. This
    * can be overridden by regression tests to avoid the interactive prompt.
    */
   async confirmLaunchExecutable(path) {
     // We don't anchor the prompt to a specific window intentionally, not
     // only because this is the same behavior as the system-level prompt,
     // but also because the most recently active window is the right choice
     // in basically all cases.
-    return await DownloadUIHelper.getPrompter().confirmLaunchExecutable(path);
+    return DownloadUIHelper.getPrompter().confirmLaunchExecutable(path);
   },
 
   /**
    * Launches the specified file, unless overridden by regression tests.
    */
   launchFile(file, mimeInfo) {
     if (mimeInfo) {
       mimeInfo.launchWithFile(file);
@@ -957,20 +958,18 @@ this.DownloadObserver = {
         }
         for (let download of this._privateInProgressDownloads) {
           download.cancel();
           this._canceledOfflineDownloads.add(download);
         }
         break;
       case "wake_notification":
       case "resume_process_notification":
-        let wakeDelay = 10000;
-        try {
-          wakeDelay = Services.prefs.getIntPref("browser.download.manager.resumeOnWakeDelay");
-        } catch(e) {}
+        let wakeDelay =
+          Services.prefs.getIntPref("browser.download.manager.resumeOnWakeDelay", 10000);
 
         if (wakeDelay >= 0) {
           this._wakeTimer = new Timer(this._resumeOfflineDownloads.bind(this), wakeDelay,
                                       Ci.nsITimer.TYPE_ONE_SHOT);
         }
         break;
       case "network:offline-status-changed":
         if (aData == "online") {
@@ -999,18 +998,17 @@ this.DownloadObserver = {
  * reflected on the provided list of downloads.
  *
  * You do not need to keep a reference to this object in order to keep it alive,
  * because the history service already keeps a strong reference to it.
  *
  * @param aList
  *        DownloadList object linked to this observer.
  */
-this.DownloadHistoryObserver = function (aList)
-{
+this.DownloadHistoryObserver = function(aList) {
   this._list = aList;
   PlacesUtils.history.addObserver(this);
 }
 
 this.DownloadHistoryObserver.prototype = {
   /**
    * DownloadList object linked to this observer.
    */
@@ -1024,40 +1022,39 @@ this.DownloadHistoryObserver.prototype =
                                                       download.source.url)));
   },
 
   // nsINavHistoryObserver
   onClearHistory: function DL_onClearHistory() {
     this._list.removeFinished();
   },
 
-  onTitleChanged: function () {},
-  onBeginUpdateBatch: function () {},
-  onEndUpdateBatch: function () {},
-  onVisit: function () {},
-  onPageChanged: function () {},
-  onDeleteVisits: function () {},
+  onTitleChanged() {},
+  onBeginUpdateBatch() {},
+  onEndUpdateBatch() {},
+  onVisit() {},
+  onPageChanged() {},
+  onDeleteVisits() {},
 };
 
 /**
  * This view can be added to a DownloadList object to trigger a save operation
  * in the given DownloadStore object when a relevant change occurs.  You should
  * call the "initialize" method in order to register the view and load the
  * current state from disk.
  *
  * You do not need to keep a reference to this object in order to keep it alive,
  * because the DownloadList object already keeps a strong reference to it.
  *
  * @param aList
  *        The DownloadList object on which the view should be registered.
  * @param aStore
  *        The DownloadStore object used for saving.
  */
-this.DownloadAutoSaveView = function (aList, aStore)
-{
+this.DownloadAutoSaveView = function(aList, aStore) {
   this._list = aList;
   this._store = aStore;
   this._downloadsMap = new Map();
   this._writer = new DeferredTask(() => this._store.save(), kSaveDelayMs);
   AsyncShutdown.profileBeforeChange.addBlocker("DownloadAutoSaveView: writing data",
                                                () => this._writer.finalize());
 }
 
@@ -1079,18 +1076,17 @@ this.DownloadAutoSaveView.prototype = {
 
   /**
    * Registers the view and loads the current state from disk.
    *
    * @return {Promise}
    * @resolves When the view has been registered.
    * @rejects JavaScript exception.
    */
-  initialize: function ()
-  {
+  initialize() {
     // We set _initialized to true after adding the view, so that
     // onDownloadAdded doesn't cause a save to occur.
     return this._list.addView(this).then(() => this._initialized = true);
   },
 
   /**
    * This map contains only Download objects that should be saved to disk, and
    * associates them with the result of their getSerializationHash function, for
@@ -1102,51 +1098,47 @@ this.DownloadAutoSaveView.prototype = {
    * DeferredTask for the save operation.
    */
   _writer: null,
 
   /**
    * Called when the list of downloads changed, this triggers the asynchronous
    * serialization of the list of downloads.
    */
-  saveSoon: function ()
-  {
+  saveSoon() {
     this._writer.arm();
   },
 
   // DownloadList callback
-  onDownloadAdded: function (aDownload)
-  {
+  onDownloadAdded(aDownload) {
     if (gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
       this._downloadsMap.set(aDownload, aDownload.getSerializationHash());
       if (this._initialized) {
         this.saveSoon();
       }
     }
   },
 
   // DownloadList callback
-  onDownloadChanged: function (aDownload)
-  {
+  onDownloadChanged(aDownload) {
     if (!gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
       if (this._downloadsMap.has(aDownload)) {
         this._downloadsMap.delete(aDownload);
         this.saveSoon();
       }
       return;
     }
 
     let hash = aDownload.getSerializationHash();
     if (this._downloadsMap.get(aDownload) != hash) {
       this._downloadsMap.set(aDownload, hash);
       this.saveSoon();
     }
   },
 
   // DownloadList callback
-  onDownloadRemoved: function (aDownload)
-  {
+  onDownloadRemoved(aDownload) {
     if (this._downloadsMap.has(aDownload)) {
       this._downloadsMap.delete(aDownload);
       this.saveSoon();
     }
   },
 };