Bug 1207491 - Part 7: Remove use of expression closure from browser/components/migration/. r=Gijs
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Sep 2015 18:36:21 +0900
changeset 264344 4ccaf6f18952fca135b42a6e494f21b38b60b24f
parent 264343 0d3daa1248da22bb391ee65debbde663ca0809dc
child 264345 f25628804471d31e92f31ab2ea0f4e10e3acc98c
push id65606
push userarai_a@mac.com
push dateFri, 25 Sep 2015 08:14:49 +0000
treeherdermozilla-inbound@e4f5f909df68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1207491
milestone44.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 1207491 - Part 7: Remove use of expression closure from browser/components/migration/. r=Gijs
browser/components/migration/360seProfileMigrator.js
browser/components/migration/FirefoxProfileMigrator.js
browser/components/migration/IEProfileMigrator.js
browser/components/migration/MSMigrationUtils.jsm
browser/components/migration/MigrationUtils.jsm
browser/components/migration/SafariProfileMigrator.js
--- a/browser/components/migration/360seProfileMigrator.js
+++ b/browser/components/migration/360seProfileMigrator.js
@@ -73,18 +73,17 @@ function parseINIStrings(file) {
       obj[section][key] = parser.getString(section, key);
     }
   }
   return obj;
 }
 
 function getHash(aStr) {
   // return the two-digit hexadecimal code for a byte
-  function toHexString(charCode)
-    ("0" + charCode.toString(16)).slice(-2);
+  let toHexString = charCode => ("0" + charCode.toString(16)).slice(-2);
 
   let hasher = Cc["@mozilla.org/security/hash;1"].
                createInstance(Ci.nsICryptoHash);
   hasher.init(Ci.nsICryptoHash.MD5);
   let stringStream = Cc["@mozilla.org/io/string-input-stream;1"].
                      createInstance(Ci.nsIStringInputStream);
   stringStream.data = aStr;
   hasher.updateFromStream(stringStream, -1);
--- a/browser/components/migration/FirefoxProfileMigrator.js
+++ b/browser/components/migration/FirefoxProfileMigrator.js
@@ -240,17 +240,17 @@ FirefoxProfileMigrator.prototype._getRes
   }
 
   return [r for each (r in [places, cookies, passwords, formData,
                             dictionary, bookmarksBackups, session,
                             times, healthReporter]) if (r)];
 };
 
 Object.defineProperty(FirefoxProfileMigrator.prototype, "startupOnlyMigrator", {
-  get: function() true
+  get: () => true
 });
 
 
 FirefoxProfileMigrator.prototype.classDescription = "Firefox Profile Migrator";
 FirefoxProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=firefox";
 FirefoxProfileMigrator.prototype.classID = Components.ID("{91185366-ba97-4438-acba-48deaca63386}");
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([FirefoxProfileMigrator]);
--- a/browser/components/migration/IEProfileMigrator.js
+++ b/browser/components/migration/IEProfileMigrator.js
@@ -39,17 +39,19 @@ let CtypesKernelHelpers = MSMigrationUti
 
 
 function History() {
 }
 
 History.prototype = {
   type: MigrationUtils.resourceTypes.HISTORY,
 
-  get exists() true,
+  get exists() {
+    return true;
+  },
 
   migrate: function H_migrate(aCallback) {
     let places = [];
     let typedURLs = MSMigrationUtils.getTypedURLs("Software\\Microsoft\\Internet Explorer");
     let historyEnumerator = Cc["@mozilla.org/profile/migrator/iehistoryenumerator;1"].
                             createInstance(Ci.nsISimpleEnumerator);
     while (historyEnumerator.hasMoreElements()) {
       let entry = historyEnumerator.getNext().QueryInterface(Ci.nsIPropertyBag2);
@@ -342,33 +344,35 @@ IE7FormPasswords.prototype = {
 };
 
 function Settings() {
 }
 
 Settings.prototype = {
   type: MigrationUtils.resourceTypes.SETTINGS,
 
-  get exists() true,
+  get exists() {
+    return true;
+  },
 
   migrate: function S_migrate(aCallback) {
     // Converts from yes/no to a boolean.
-    function yesNoToBoolean(v) v == "yes";
+    let yesNoToBoolean = v => v == "yes";
 
     // Converts source format like "en-us,ar-kw;q=0.7,ar-om;q=0.3" into
     // destination format like "en-us, ar-kw, ar-om".
     // Final string is sorted by quality (q=) param.
     function parseAcceptLanguageList(v) {
       return v.match(/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/gi)
               .sort(function (a , b) {
                 let qA = parseFloat(a.split(";q=")[1]) || 1.0;
                 let qB = parseFloat(b.split(";q=")[1]) || 1.0;
                 return qA < qB ? 1 : qA == qB ? 0 : -1;
               })
-              .map(function(a) a.split(";")[0]);
+              .map(a => a.split(";")[0]);
     }
 
     // For reference on some of the available IE Registry settings:
     //  * http://msdn.microsoft.com/en-us/library/cc980058%28v=prot.13%29.aspx
     //  * http://msdn.microsoft.com/en-us/library/cc980059%28v=prot.13%29.aspx
 
     // Note that only settings exposed in our UI should be migrated.
 
@@ -390,41 +394,41 @@ Settings.prototype = {
               yesNoToBoolean);
     this._set(kMainKey,
               "Anchor Underline",
               "browser.underline_anchors",
               yesNoToBoolean);
     this._set(kMainKey,
               "Display Inline Images",
               "permissions.default.image",
-              function (v) yesNoToBoolean(v) ? 1 : 2);
+              v => yesNoToBoolean(v) ? 1 : 2);
     this._set(kMainKey,
               "Move System Caret",
               "accessibility.browsewithcaret",
               yesNoToBoolean);
     this._set("Software\\Microsoft\\Internet Explorer\\Settings",
               "Always Use My Colors",
               "browser.display.document_color_use",
-              function (v) !Boolean(v) ? 0 : 2);
+              v => !Boolean(v) ? 0 : 2);
     this._set("Software\\Microsoft\\Internet Explorer\\Settings",
               "Always Use My Font Face",
               "browser.display.use_document_fonts",
-              function (v) !Boolean(v));
+              v => !Boolean(v));
     this._set(kMainKey,
               "SmoothScroll",
               "general.smoothScroll",
               Boolean);
     this._set("Software\\Microsoft\\Internet Explorer\\TabbedBrowsing\\",
               "WarnOnClose",
               "browser.tabs.warnOnClose",
               Boolean);
     this._set("Software\\Microsoft\\Internet Explorer\\TabbedBrowsing\\",
               "OpenInForeground",
               "browser.tabs.loadInBackground",
-              function (v) !Boolean(v));
+              v => !Boolean(v));
 
     aCallback(true);
   },
 
   /**
    * Reads a setting from the Registry and stores the converted result into
    * the appropriate Firefox preference.
    * 
--- a/browser/components/migration/MSMigrationUtils.jsm
+++ b/browser/components/migration/MSMigrationUtils.jsm
@@ -320,19 +320,23 @@ function getEdgeLocalDataFolder() {
 
 function Bookmarks(migrationType) {
   this._migrationType = migrationType;
 }
 
 Bookmarks.prototype = {
   type: MigrationUtils.resourceTypes.BOOKMARKS,
 
-  get exists() !!this._favoritesFolder,
+  get exists() {
+    return !!this._favoritesFolder;
+  },
 
-  get importedAppLabel() this._migrationType == MSMigrationUtils.MIGRATION_TYPE_IE ? "IE" : "Edge",
+  get importedAppLabel() {
+    return this._migrationType == MSMigrationUtils.MIGRATION_TYPE_IE ? "IE" : "Edge";
+  },
 
   __favoritesFolder: null,
   get _favoritesFolder() {
     if (!this.__favoritesFolder) {
       if (this._migrationType == MSMigrationUtils.MIGRATION_TYPE_IE) {
         let favoritesFolder = Services.dirsvc.get("Favs", Ci.nsIFile);
         if (favoritesFolder.exists() && favoritesFolder.isReadable())
           return this.__favoritesFolder = favoritesFolder;
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -93,17 +93,19 @@ this.MigratorPrototype = {
    *   name - a pretty name to display to the user in the UI
    *
    * Only profiles from which data can be imported should be listed.  Otherwise
    * the behavior of the migration wizard isn't well-defined.
    *
    * For a single-profile source (e.g. safari, ie), this returns null,
    * and not an empty array.  That is the default implementation.
    */
-  get sourceProfiles() null,
+  get sourceProfiles() {
+    return null;
+  },
 
   /**
    * MUST BE OVERRIDDEN.
    *
    * Returns an array of "migration resources" objects for the given profile,
    * or for the "default" profile, if the migrator does not support multiple
    * profiles.
    *
@@ -154,39 +156,45 @@ this.MigratorPrototype = {
    *
    * Startup-only migrators are different in two ways:
    * - they may only be used during startup.
    * - the user-profile is half baked during migration.  The folder exists,
    *   but it's only accessible through MigrationUtils.profileStartup.
    *   The migrator can call MigrationUtils.profileStartup.doStartup
    *   at any point in order to initialize the profile.
    */
-  get startupOnlyMigrator() false,
+  get startupOnlyMigrator() {
+    return false;
+  },
 
   /**
    * OVERRIDE IF AND ONLY IF your migrator supports importing the homepage.
    * @see nsIBrowserProfileMigrator
    */
-  get sourceHomePageURL() "",
+  get sourceHomePageURL() {
+    return "";
+  },
 
   /**
    * Override if the data to migrate is locked/in-use and the user should
    * probably shutdown the source browser.
    */
-  get sourceLocked() false,
+  get sourceLocked() {
+    return false;
+  },
 
   /**
    * DO NOT OVERRIDE - After deCOMing migration, the UI will just call
    * getResources.
    *
    * @see nsIBrowserProfileMigrator
    */
   getMigrateData: function MP_getMigrateData(aProfile) {
     let types = [r.type for each (r in this._getMaybeCachedResources(aProfile))];
-    return types.reduce(function(a, b) a |= b, 0);
+    return types.reduce((a, b) => a |= b, 0);
   },
 
   /**
    * DO NOT OVERRIDE - After deCOMing migration, the UI will just call
    * migrate for each resource.
    *
    * @see nsIBrowserProfileMigrator
    */
@@ -261,17 +269,17 @@ this.MigratorPrototype = {
     if (MigrationUtils.isStartupMigration && !this.startupOnlyMigrator) {
       MigrationUtils.profileStartup.doStartup();
 
       // If we're about to migrate bookmarks, first import the default bookmarks.
       // Note We do not need to do so for the Firefox migrator
       // (=startupOnlyMigrator), as it just copies over the places database
       // from another profile.
       const BOOKMARKS = MigrationUtils.resourceTypes.BOOKMARKS;
-      let migratingBookmarks = resources.some(function(r) r.type == BOOKMARKS);
+      let migratingBookmarks = resources.some(r => r.type == BOOKMARKS);
       if (migratingBookmarks) {
         let browserGlue = Cc["@mozilla.org/browser/browserglue;1"].
                           getService(Ci.nsIObserver);
         browserGlue.observe(null, TOPIC_WILL_IMPORT_BOOKMARKS, "");
 
         // Note doMigrate doesn't care about the success of the import.
         let onImportComplete = function() {
           browserGlue.observe(null, TOPIC_DID_IMPORT_BOOKMARKS, "");
@@ -504,35 +512,39 @@ this.MigrationUtils = Object.freeze({
       "firefox", "chrome", "chromium"
 #endif
     ];
 
     // If a supported default browser is found check it first
     // so that the wizard defaults to import from that browser.
     let defaultBrowserKey = getMigratorKeyForDefaultBrowser();
     if (defaultBrowserKey)
-      migratorKeysOrdered.sort(function (a, b) b == defaultBrowserKey ? 1 : 0);
+      migratorKeysOrdered.sort((a, b) => b == defaultBrowserKey ? 1 : 0);
 
     for (let migratorKey of migratorKeysOrdered) {
       let migrator = this.getMigrator(migratorKey);
       if (migrator)
         yield migrator;
     }
   },
 
   // Whether or not we're in the process of startup migration
-  get isStartupMigration() gProfileStartup != null,
+  get isStartupMigration() {
+    return gProfileStartup != null;
+  },
 
   /**
    * In the case of startup migration, this is set to the nsIProfileStartup
    * instance passed to ProfileMigrator's migrate.
    *
    * @see showMigrationWizard
    */
-  get profileStartup() gProfileStartup,
+  get profileStartup() {
+    return gProfileStartup;
+  },
 
   /**
    * Show the migration wizard.  On mac, this may just focus the wizard if it's
    * already running, in which case aOpener and aParams are ignored.
    *
    * @param [optional] aOpener
    *        the window that asks to open the wizard.
    * @param [optioanl] aParams
--- a/browser/components/migration/SafariProfileMigrator.js
+++ b/browser/components/migration/SafariProfileMigrator.js
@@ -320,45 +320,45 @@ Preferences.prototype = {
   migrate: function MPR_migrate(aCallback) {
     this._mainPreferencesPropertyList.read(aDict => {
       Task.spawn(function* () {
         if (!aDict)
           throw new Error("Could not read preferences file");
 
         this._dict = aDict;
 
-        let invert = function(webkitVal) !webkitVal;
+        let invert = webkitVal => !webkitVal;
         this._set("AutoFillPasswords", "signon.rememberSignons");
         this._set("OpenNewTabsInFront", "browser.tabs.loadInBackground", invert);
         this._set("WebKitJavaScriptCanOpenWindowsAutomatically",
                    "dom.disable_open_during_load", invert);
 
         // layout.spellcheckDefault is a boolean stored as a number.
         this._set("WebContinuousSpellCheckingEnabled",
                   "layout.spellcheckDefault", Number);
 
         // Auto-load images
         // Firefox has an elaborate set of Image preferences. The correlation is:
         // Mode:                            Safari    Firefox
         // Blocked                          FALSE     2
         // Allowed                          TRUE      1
         // Allowed, originating site only   --        3
         this._set("WebKitDisplayImagesKey", "permissions.default.image",
-                  function(webkitVal) webkitVal ? 1 : 2);
+                  webkitVal => webkitVal ? 1 : 2);
 
 #ifdef XP_WIN
         // Cookie-accept policy.
         // For the OS X version, see WebFoundationCookieBehavior.
         // Setting                    Safari          Firefox
         // Always Accept              0               0
         // Accept from Originating    2               1
         // Never Accept               1               2
         this._set("WebKitCookieStorageAcceptPolicy",
           "network.cookie.cookieBehavior",
-          function(webkitVal) webkitVal == 0 ? 0 : webkitVal == 1 ? 2 : 1);
+          webkitVal => webkitVal == 0 ? 0 : webkitVal == 1 ? 2 : 1);
 #endif
 
         this._migrateFontSettings();
         yield this._migrateDownloadsFolder();
 
       }.bind(this)).then(() => aCallback(true), ex => {
         Cu.reportError(ex);
         aCallback(false);