bug 1347642 - Fixed sanitizeDialog.js running in ESLint r=standard8
authorRajesh Kathiriya <rajesh.kathiriya507@gmail.com>
Fri, 31 Mar 2017 00:19:31 +0530
changeset 398987 4cf4dd146988f6f8a9da34fdc55824721970626a
parent 398986 a7c5382ee7181e73d1638228ad9bde164cc8cae0
child 398988 6ba6c3b755870fbc711b5050b88d887d2fdff851
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1347642
milestone55.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 1347642 - Fixed sanitizeDialog.js running in ESLint r=standard8 MozReview-Commit-ID: A7mVW5hbvya
.eslintignore
browser/base/content/sanitizeDialog.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -50,17 +50,16 @@ xulrunner/**
 # b2g exclusions (pref files).
 b2g/app/b2g.js
 b2g/graphene/graphene.js
 b2g/locales/en-US/b2g-l10n.js
 
 # browser/ exclusions
 browser/app/**
 browser/branding/**/firefox-branding.js
-browser/base/content/sanitizeDialog.js
 browser/base/content/test/general/file_csp_block_all_mixedcontent.html
 browser/base/content/test/urlbar/file_blank_but_not_blank.html
 browser/base/content/newtab/**
 browser/components/downloads/**
 # Test files that are really json not js, and don't need to be linted.
 browser/components/sessionstore/test/unit/data/sessionstore_valid.js
 browser/components/sessionstore/test/unit/data/sessionstore_invalid.js
 browser/components/tabview/**
--- a/browser/base/content/sanitizeDialog.js
+++ b/browser/base/content/sanitizeDialog.js
@@ -6,66 +6,59 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cu = Components.utils;
 
 var {Sanitizer} = Cu.import("resource:///modules/Sanitizer.jsm", {});
 
 var gSanitizePromptDialog = {
 
-  get bundleBrowser()
-  {
+  get bundleBrowser() {
     if (!this._bundleBrowser)
       this._bundleBrowser = document.getElementById("bundleBrowser");
     return this._bundleBrowser;
   },
 
-  get selectedTimespan()
-  {
+  get selectedTimespan() {
     var durList = document.getElementById("sanitizeDurationChoice");
     return parseInt(durList.value);
   },
 
-  get sanitizePreferences()
-  {
+  get sanitizePreferences() {
     if (!this._sanitizePreferences) {
       this._sanitizePreferences =
         document.getElementById("sanitizePreferences");
     }
     return this._sanitizePreferences;
   },
 
-  get warningBox()
-  {
+  get warningBox() {
     return document.getElementById("sanitizeEverythingWarningBox");
   },
 
-  init: function ()
-  {
+  init() {
     // This is used by selectByTimespan() to determine if the window has loaded.
     this._inited = true;
 
     var s = new Sanitizer();
     s.prefDomain = "privacy.cpd.";
 
     document.documentElement.getButton("accept").label =
       this.bundleBrowser.getString("sanitizeButtonOK");
 
     if (this.selectedTimespan === Sanitizer.TIMESPAN_EVERYTHING) {
       this.prepareWarning();
       this.warningBox.hidden = false;
       document.title =
         this.bundleBrowser.getString("sanitizeDialog2.everything.title");
-    }
-    else
+    } else
       this.warningBox.hidden = true;
   },
 
-  selectByTimespan: function ()
-  {
+  selectByTimespan() {
     // This method is the onselect handler for the duration dropdown.  As a
     // result it's called a couple of times before onload calls init().
     if (!this._inited)
       return;
 
     var warningBox = this.warningBox;
 
     // If clearing everything
@@ -84,18 +77,17 @@ var gSanitizePromptDialog = {
     if (!warningBox.hidden) {
       window.resizeBy(0, -warningBox.boxObject.height);
       warningBox.hidden = true;
     }
     window.document.title =
       window.document.documentElement.getAttribute("noneverythingtitle");
   },
 
-  sanitize: function ()
-  {
+  sanitize() {
     // Update pref values before handing off to the sanitizer (bug 453440)
     this.updatePrefs();
     var s = new Sanitizer();
     s.prefDomain = "privacy.cpd.";
 
     s.range = Sanitizer.getClearRange(this.selectedTimespan);
     s.ignoreTimespan = !s.range;
 
@@ -109,90 +101,86 @@ var gSanitizePromptDialog = {
     acceptButton.setAttribute("label",
                               this.bundleBrowser.getString("sanitizeButtonClearing"));
     docElt.getButton("cancel").disabled = true;
 
     try {
       s.sanitize().then(null, Components.utils.reportError)
                   .then(() => window.close())
                   .then(null, Components.utils.reportError);
+      return false;
     } catch (er) {
       Components.utils.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.
    *
    * @param aDontShowItemList Whether only the warning message should be updated.
    *                          True means the item list visibility status should not
    *                          be changed.
    */
-  prepareWarning: function (aDontShowItemList) {
+  prepareWarning(aDontShowItemList) {
     // If the date and time-aware locale warning string is ever used again,
     // initialize it here.  Currently we use the no-visits warning string,
     // which does not include date and time.  See bug 480169 comment 48.
 
     var warningStringID;
     if (this.hasNonSelectedItems()) {
       warningStringID = "sanitizeSelectedWarning";
       if (!aDontShowItemList)
         this.showItemList();
-    }
-    else {
+    } else {
       warningStringID = "sanitizeEverythingWarning2";
     }
 
     var warningDesc = document.getElementById("sanitizeEverythingWarning");
     warningDesc.textContent =
       this.bundleBrowser.getString(warningStringID);
   },
 
   /**
    * Called when the value of a preference element is synced from the actual
    * pref.  Enables or disables the OK button appropriately.
    */
-  onReadGeneric: function ()
-  {
+  onReadGeneric() {
     var found = false;
 
     // Find any other pref that's checked and enabled.
     var i = 0;
     while (!found && i < this.sanitizePreferences.childNodes.length) {
       var preference = this.sanitizePreferences.childNodes[i];
 
       found = !!preference.value &&
               !preference.disabled;
       i++;
     }
 
     try {
       document.documentElement.getButton("accept").disabled = !found;
-    }
-    catch (e) { }
+    } catch (e) { }
 
     // Update the warning prompt if needed
     this.prepareWarning(true);
 
     return undefined;
   },
 
   /**
    * Sanitizer.prototype.sanitize() requires the prefs to be up-to-date.
    * Because the type of this prefwindow is "child" -- and that's needed because
    * without it the dialog has no OK and Cancel buttons -- the prefs are not
    * updated on dialogaccept on platforms that don't support instant-apply
    * (i.e., Windows).  We must therefore manually set the prefs from their
    * corresponding preference elements.
    */
-  updatePrefs : function ()
-  {
-    var tsPref = document.getElementById("privacy.sanitize.timeSpan");
+  updatePrefs() {
     Sanitizer.prefs.setIntPref("timeSpan", this.selectedTimespan);
 
     // Keep the pref for the download history in sync with the history pref.
     document.getElementById("privacy.cpd.downloads").value =
       document.getElementById("privacy.cpd.history").value;
 
     // Now manually set the prefs from their corresponding preference
     // elements.
@@ -201,60 +189,59 @@ var gSanitizePromptDialog = {
       var p = this.sanitizePreferences.childNodes[i];
       prefs.setBoolPref(p.name, p.value);
     }
   },
 
   /**
    * Check if all of the history items have been selected like the default status.
    */
-  hasNonSelectedItems: function () {
+  hasNonSelectedItems() {
     let checkboxes = document.querySelectorAll("#itemList > [preference]");
     for (let i = 0; i < checkboxes.length; ++i) {
       let pref = document.getElementById(checkboxes[i].getAttribute("preference"));
       if (!pref.value)
         return true;
     }
     return false;
   },
 
   /**
    * Show the history items list.
    */
-  showItemList: function () {
+  showItemList() {
     var itemList = document.getElementById("itemList");
     var expanderButton = document.getElementById("detailsExpander");
 
     if (itemList.collapsed) {
       expanderButton.className = "expander-up";
       itemList.setAttribute("collapsed", "false");
       if (document.documentElement.boxObject.height)
         window.resizeBy(0, itemList.boxObject.height);
     }
   },
 
   /**
    * Hide the history items list.
    */
-  hideItemList: function () {
+  hideItemList() {
     var itemList = document.getElementById("itemList");
     var expanderButton = document.getElementById("detailsExpander");
 
     if (!itemList.collapsed) {
       expanderButton.className = "expander-down";
       window.resizeBy(0, -itemList.boxObject.height);
       itemList.setAttribute("collapsed", "true");
     }
   },
 
   /**
    * Called by the item list expander button to toggle the list's visibility.
    */
-  toggleItemList: function ()
-  {
+  toggleItemList() {
     var itemList = document.getElementById("itemList");
 
     if (itemList.collapsed)
       this.showItemList();
     else
       this.hideItemList();
   }