Bug 1484640 - Enable ESLint for mobile/android/chrome/content/browser.js (Manual Changes). r=snorp
☠☠ backed out by e91f6d3bc047 ☠ ☠
authorchampionshuttler <shivams2799@gmail.com>
Sat, 16 Mar 2019 13:13:00 +0000
changeset 524090 54f421232d08b49c1bd3769e680f3c61e163f72e
parent 524089 5914426902ac204d49683d56695d1adf45e2c1cd
child 524091 446d785e076b7f9ffaa32c0506715083d4752961
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1484640
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 1484640 - Enable ESLint for mobile/android/chrome/content/browser.js (Manual Changes). r=snorp Differential Revision: https://phabricator.services.mozilla.com/D22891
.eslintignore
mobile/android/chrome/content/browser.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -261,19 +261,16 @@ mobile/android/app/geckoview-prefs.js
 
 # Uses `#expand`
 mobile/android/chrome/content/about.js
 
 # Not much JS to lint and non-standard at that
 mobile/android/installer/
 mobile/android/locales/
 
-# Non-standard `(catch ex if ...)`
-mobile/android/chrome/content/browser.js
-
 # Pre-processed/pref files
 modules/libpref/greprefs.js
 modules/libpref/init/all.js
 modules/libpref/test/unit/*data/**
 
 # Only contains non-standard test files.
 python/**
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1495,17 +1495,17 @@ var BrowserApp = {
 
     // Tell session store to forget about this window
     if (aClear.dontSaveSession) {
       let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
       ss.removeWindow(window);
     }
 
     BrowserApp.sanitize(aClear.sanitize, function() {
-      let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
+      let appStartup = Services.startup;
       appStartup.quit(Ci.nsIAppStartup.eForceQuit);
     }, true);
   },
 
   saveAsPDF: function saveAsPDF(aBrowser) {
     RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE).then(function(permissionGranted) {
       if (!permissionGranted) {
         return;
@@ -1717,16 +1717,17 @@ var BrowserApp = {
 
   setLocalizedPref: function(pref, value) {
     let pls = Cc["@mozilla.org/pref-localizedstring;1"]
                 .createInstance(Ci.nsIPrefLocalizedString);
     pls.data = value;
     Services.prefs.setComplexValue(pref, Ci.nsIPrefLocalizedString, pls);
   },
 
+  // eslint-disable-next-line complexity
   onEvent: function(event, data, callback) {
     let browser = this.selectedBrowser;
 
     switch (event) {
       case "Browser:LoadManifest": {
         installManifest(browser, data);
         break;
       }
@@ -1787,22 +1788,17 @@ var BrowserApp = {
         }
 
         console.log("Gecko display locale: " + this.getUALocalePref());
 
         // Rebuild strings to reflect the new locale.
         Strings.flush();
 
         // Make sure we use the right Accept-Language header.
-        let osLocale;
-        try {
-          // This should never not be set at this point, but better safe than sorry.
-          osLocale = Services.prefs.getCharPref("intl.locale.os");
-        } catch (e) {
-        }
+        let osLocale = Services.prefs.getCharPref("intl.locale.os");
 
         this.computeAcceptLanguages(osLocale, data && data.languageTag);
         break;
       }
 
       case "Passwords:Init": {
         let storage = Cc["@mozilla.org/login-manager/storage/mozStorage;1"].
                       getService(Ci.nsILoginManagerStorage);
@@ -1886,16 +1882,17 @@ var BrowserApp = {
               } else {
                 Services.perms.add(normalizedUrl, "trackingprotection", Services.perms.ALLOW_ACTION);
                 Telemetry.addData("TRACKING_PROTECTION_EVENTS", 1);
               }
             } else {
               // Remove the current host from the 'trackingprotection' consumer
               // of the permission manager. This effectively removes this host
               // from the tracking protection white list (any list actually).
+              // eslint-disable-next-line no-lonely-if
               if (PrivateBrowsingUtils.isBrowserPrivate(browser)) {
                 PrivateBrowsingUtils.removeFromTrackingAllowlist(normalizedUrl);
               } else {
                 Services.perms.remove(normalizedUrl, "trackingprotection");
                 Telemetry.addData("TRACKING_PROTECTION_EVENTS", 2);
               }
             }
           }
@@ -3493,16 +3490,17 @@ var DesktopUserAgent = {
 
 
 function nsBrowserAccess() {
 }
 
 nsBrowserAccess.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIBrowserDOMWindow]),
 
+  // eslint-disable-next-line complexity
   _getBrowser: function _getBrowser(aURI, aOpener, aWhere, aFlags, aTriggeringPrincipal) {
     let isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
     if (isExternal && aURI && aURI.schemeIs("chrome"))
       return null;
 
     let loadflags = isExternal ?
                       Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
                       Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
@@ -3696,16 +3694,17 @@ function getBaseDomain(aURI) {
         baseDomain = IDNService.convertACEtoUTF8(baseDomain);
       }
     } catch (e) {}
   }
   return baseDomain;
 }
 
 Tab.prototype = {
+  // eslint-disable-next-line complexity
   create: function(aURL, aParams) {
     if (this.browser)
       return;
 
     aParams = aParams || {};
 
     this.browser = document.createElement("browser");
     this.browser.setAttribute("type", "content");
@@ -4231,16 +4230,17 @@ Tab.prototype = {
       return this.browser.currentURI;
     }
       // For zombie tabs we need to fall back to the session store data.
       let data = this.browser.__SS_data;
       let url = data.entries[data.index - 1].url;
       return Services.io.newURI(url);
   },
 
+  // eslint-disable-next-line complexity
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "DOMContentLoaded": {
         let target = aEvent.originalTarget;
 
         // ignore on frames and other documents
         if (target != this.browser.contentDocument)
           return;
@@ -4611,16 +4611,17 @@ Tab.prototype = {
         state: aStateFlags,
         restoring: restoring,
         success: success,
       };
       GlobalEventDispatcher.sendRequest(message);
     }
   },
 
+  // eslint-disable-next-line complexity
   onLocationChange: function(aWebProgress, aRequest, aLocationURI, aFlags) {
     let contentWin = aWebProgress.DOMWindow;
     let webNav = contentWin.docShell.QueryInterface(Ci.nsIWebNavigation);
 
     // Browser webapps may load content inside iframes that can not reach across the app/frame boundary
     // i.e. even though the page is loaded in an iframe window.top != webapp
     // Make cure this window is a top level tab before moving on.
     if (BrowserApp.getBrowserForWindow(contentWin) == null) {
@@ -5021,16 +5022,17 @@ var BrowserEventHandler = {
     if (!this._highlightElement)
       return;
 
     this._highlightElement = null;
   },
 };
 
 var ErrorPageEventHandler = {
+  // eslint-disable-next-line complexity
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "click": {
         // Don't trust synthetic events
         if (!aEvent.isTrusted)
           return;
 
         let target = aEvent.originalTarget;
@@ -5087,17 +5089,17 @@ var ErrorPageEventHandler = {
           } else if (errorDoc.documentURI.includes("e=harmfulBlocked")) {
             sendTelemetry = true;
             bucketName = "WARNING_HARMFUL_PAGE_";
           }
           let nsISecTel = Ci.nsISecurityUITelemetry;
           let isIframe = (errorDoc.defaultView.parent === errorDoc.defaultView);
           bucketName += isIframe ? "TOP_" : "FRAME_";
 
-          let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
+          let formatter = Services.urlFormatter;
 
           if (target == errorDoc.getElementById("getMeOutButton")) {
             if (sendTelemetry) {
               Telemetry.addData(probe, nsISecTel[bucketName + "GET_ME_OUT_OF_HERE"]);
             }
             errorDoc.location = "about:home";
           } else if (target == errorDoc.getElementById("reportButton")) {
             // We log even if malware/phishing info URL couldn't be found:
@@ -5316,30 +5318,28 @@ var XPInstallObserver = {
     let needsRestart = false;
     if (aInstall.existingAddon && (aInstall.existingAddon.pendingOperations & AddonManager.PENDING_UPGRADE))
       needsRestart = true;
     else if (aAddon.pendingOperations & AddonManager.PENDING_INSTALL)
       needsRestart = true;
 
     if (needsRestart) {
       this.showRestartPrompt();
-    } else {
+    } else if (!aInstall.existingAddon || !AddonManager.shouldAutoUpdate(aInstall.existingAddon)) {
       // Display completion message for new installs or updates not done Automatically
-      if (!aInstall.existingAddon || !AddonManager.shouldAutoUpdate(aInstall.existingAddon)) {
-        let message = Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.message");
-        Snackbars.show(message, Snackbars.LENGTH_LONG, {
-          action: {
-            label: Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.action2"),
-            callback: () => {
-              UITelemetry.addEvent("show.1", "toast", null, "addons");
-              BrowserApp.selectOrAddTab("about:addons", { parentId: BrowserApp.selectedTab.id });
-            },
+      let message = Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.message");
+      Snackbars.show(message, Snackbars.LENGTH_LONG, {
+        action: {
+          label: Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.action2"),
+          callback: () => {
+            UITelemetry.addEvent("show.1", "toast", null, "addons");
+            BrowserApp.selectOrAddTab("about:addons", { parentId: BrowserApp.selectedTab.id });
           },
-        });
-      }
+        },
+      });
     }
   },
 
   onInstallFailed: function(aInstall) {
     this._showErrorMessage(aInstall);
   },
 
   onDownloadProgress: function(aInstall) {},
@@ -5402,20 +5402,20 @@ var XPInstallObserver = {
     let buttons = [{
       label: Strings.browser.GetStringFromName("notificationRestart.button"),
       callback: function() {
         // Notify all windows that an application quit has been requested
         let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
         Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
 
         // If nothing aborted, quit the app
-        if (cancelQuit.data == false) {
+        if (!cancelQuit.data) {
           Services.obs.notifyObservers(null, "quit-application-proceeding");
           SharedPreferences.forApp().setBoolPref("browser.sessionstore.resume_session_once", true);
-          let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
+          let appStartup = Services.startup;
           appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
         }
       },
       positive: true,
     }];
 
     let message = Strings.browser.GetStringFromName("notificationRestart.normal");
     NativeWindow.doorhanger.show(message, "addon-app-restart", buttons, BrowserApp.selectedTab.id, { persistence: -1 }, "ADDON");