Bug 1246591 - fix whitespace issues, r?MattN draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 08 Feb 2016 12:03:10 +0000
changeset 329532 a8aff743dac30977112b5ce6420631c432601b41
parent 329531 c5685dc73b4ecae52477e695aa598e2bca0e0195
child 329533 df5f44f84c5c56f76a65c887cd5b374284562a61
push id10541
push usergijskruitbosch@gmail.com
push dateMon, 08 Feb 2016 12:59:28 +0000
reviewersMattN
bugs1246591
milestone47.0a1
Bug 1246591 - fix whitespace issues, r?MattN
browser/components/migration/IEProfileMigrator.js
browser/components/migration/content/migration.js
browser/components/migration/tests/unit/test_Edge_availability.js
browser/components/migration/tests/unit/test_IE7_passwords.js
browser/components/migration/tests/unit/test_fx_telemetry.js
--- a/browser/components/migration/IEProfileMigrator.js
+++ b/browser/components/migration/IEProfileMigrator.js
@@ -426,17 +426,17 @@ Settings.prototype = {
               v => !Boolean(v));
 
     aCallback(true);
   },
 
   /**
    * Reads a setting from the Registry and stores the converted result into
    * the appropriate Firefox preference.
-   * 
+   *
    * @param aPath
    *        Registry path under HKCU.
    * @param aKey
    *        Name of the key.
    * @param aPref
    *        Firefox preference.
    * @param [optional] aTransformFn
    *        Conversion function from the Registry format to the pref format.
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -113,42 +113,42 @@ var MigrationWizard = {
     }
 
     // Advance to the next page if the caller told us to.
     if (this._migrator && this._skipImportSourcePage) {
       this._wiz.advance();
       this._wiz.canRewind = false;
     }
   },
-  
+
   onImportSourcePageAdvanced: function ()
   {
     var newSource = document.getElementById("importSourceGroup").selectedItem.id;
-    
+
     if (newSource == "nothing") {
       // Need to do telemetry here because we're closing the dialog before we get to
       // do actual migration. For actual migration, this doesn't happen until after
       // migration takes place.
       Services.telemetry.getHistogramById("FX_MIGRATION_SOURCE_BROWSER")
                         .add(MigrationUtils.getSourceIdForTelemetry("nothing"));
       document.documentElement.cancel();
       return false;
     }
-    
+
     if (!this._migrator || (newSource != this._source)) {
       // Create the migrator for the selected source.
       this._migrator = MigrationUtils.getMigrator(newSource);
 
       this._itemsFlags = kIMig.ALL;
       this._selectedProfile = null;
     }
     this._source = newSource;
 
     // check for more than one source profile
-    var sourceProfiles = this._migrator.sourceProfiles;    
+    var sourceProfiles = this._migrator.sourceProfiles;
     if (this._skipImportSourcePage) {
       this._wiz.currentPage.next = "homePageImport";
     }
     else if (sourceProfiles && sourceProfiles.length > 1) {
       this._wiz.currentPage.next = "selectProfile";
     }
     else {
       if (this._autoMigrate)
@@ -157,79 +157,79 @@ var MigrationWizard = {
         this._wiz.currentPage.next = "importItems";
 
       if (sourceProfiles && sourceProfiles.length == 1)
         this._selectedProfile = sourceProfiles[0];
       else
         this._selectedProfile = null;
     }
   },
-  
+
   // 2 - [Profile Selection]
   onSelectProfilePageShow: function ()
   {
     // Disabling this for now, since we ask about import sources in automigration
     // too and don't want to disable the back button
     // if (this._autoMigrate)
     //   document.documentElement.getButton("back").disabled = true;
-      
+
     var profiles = document.getElementById("profiles");
-    while (profiles.hasChildNodes()) 
+    while (profiles.hasChildNodes())
       profiles.removeChild(profiles.firstChild);
-    
+
     // Note that this block is still reached even if the user chose 'From File'
     // and we canceled the dialog.  When that happens, _migrator will be null.
     if (this._migrator) {
       var sourceProfiles = this._migrator.sourceProfiles;
 
       for (let profile of sourceProfiles) {
         var item = document.createElement("radio");
         item.id = profile.id;
         item.setAttribute("label", profile.name);
         profiles.appendChild(item);
       }
     }
-    
+
     profiles.selectedItem = this._selectedProfile ? document.getElementById(this._selectedProfile.id) : profiles.firstChild;
   },
-  
+
   onSelectProfilePageRewound: function ()
   {
     var profiles = document.getElementById("profiles");
     this._selectedProfile = this._migrator.sourceProfiles.find(
       profile => profile.id == profiles.selectedItem.id
     ) || null;
   },
-  
+
   onSelectProfilePageAdvanced: function ()
   {
     var profiles = document.getElementById("profiles");
     this._selectedProfile = this._migrator.sourceProfiles.find(
       profile => profile.id == profiles.selectedItem.id
     ) || null;
 
     // If we're automigrating or just doing bookmarks don't show the item selection page
     if (this._autoMigrate)
       this._wiz.currentPage.next = "homePageImport";
   },
-  
+
   // 3 - ImportItems
   onImportItemsPageShow: function ()
   {
     var dataSources = document.getElementById("dataSources");
     while (dataSources.hasChildNodes())
       dataSources.removeChild(dataSources.firstChild);
 
     var items = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate);
     for (var i = 0; i < 16; ++i) {
       var itemID = (items >> i) & 0x1 ? Math.pow(2, i) : 0;
       if (itemID > 0) {
         var checkbox = document.createElement("checkbox");
         checkbox.id = itemID;
-        checkbox.setAttribute("label", 
+        checkbox.setAttribute("label",
           MigrationUtils.getLocalizedString(itemID + "_" + this._source));
         dataSources.appendChild(checkbox);
         if (!this._itemsFlags || this._itemsFlags & itemID)
           checkbox.checked = true;
       }
     }
   },
 
@@ -244,17 +244,17 @@ var MigrationWizard = {
     var dataSources = document.getElementById("dataSources");
     this._itemsFlags = 0;
     for (var i = 0; i < dataSources.childNodes.length; ++i) {
       var checkbox = dataSources.childNodes[i];
       if (checkbox.localName == "checkbox" && checkbox.checked)
         this._itemsFlags |= parseInt(checkbox.id);
     }
   },
-  
+
   onImportItemCommand: function (aEvent)
   {
     var items = document.getElementById("dataSources");
     var checkboxes = items.getElementsByTagName("checkbox");
 
     var oneChecked = false;
     for (var i = 0; i < checkboxes.length; ++i) {
       if (checkboxes[i].checked) {
@@ -353,17 +353,17 @@ var MigrationWizard = {
   },
 
   // 5 - Migrating
   onMigratingPageShow: function ()
   {
     this._wiz.getButton("cancel").disabled = true;
     this._wiz.canRewind = false;
     this._wiz.canAdvance = false;
-    
+
     // When automigrating, show all of the data that can be received from this source.
     if (this._autoMigrate)
       this._itemsFlags = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate);
 
     this._listItems("migratingItems");
     setTimeout(() => this.onMigratingMigrate(), 0);
   },
 
@@ -381,17 +381,17 @@ var MigrationWizard = {
         if (items & 1) {
           hist.add(this._source, exp);
         }
         items = items >> 1;
         exp++
       }
     }
   },
-  
+
   _listItems: function (aID)
   {
     var items = document.getElementById(aID);
     while (items.hasChildNodes())
       items.removeChild(items.firstChild);
 
     var brandBundle = document.getElementById("brandBundle");
     var itemID;
@@ -402,23 +402,23 @@ var MigrationWizard = {
         label.id = itemID + "_migrated";
         try {
           label.setAttribute("value",
             MigrationUtils.getLocalizedString(itemID + "_" + this._source));
           items.appendChild(label);
         }
         catch (e) {
           // if the block above throws, we've enumerated all the import data types we
-          // currently support and are now just wasting time, break. 
+          // currently support and are now just wasting time, break.
           break;
         }
       }
     }
   },
-  
+
   observe: function (aSubject, aTopic, aData)
   {
     switch (aTopic) {
     case "Migration:Started":
       break;
     case "Migration:ItemBeforeMigrate":
       var label = document.getElementById(aData + "_migrated");
       if (label)
@@ -452,18 +452,18 @@ var MigrationWizard = {
                                          str);
             }
 
             var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                                    .getService(Components.interfaces.nsIProperties);
             var prefFile = dirSvc.get("ProfDS", Components.interfaces.nsIFile);
             prefFile.append("prefs.js");
             prefSvc.savePrefFile(prefFile);
-          } catch(ex) { 
-            dump(ex); 
+          } catch(ex) {
+            dump(ex);
           }
         }
 
         // We're done now.
         this._wiz.canAdvance = true;
         this._wiz.advance();
 
         setTimeout(close, 5000);
--- a/browser/components/migration/tests/unit/test_Edge_availability.js
+++ b/browser/components/migration/tests/unit/test_Edge_availability.js
@@ -1,9 +1,9 @@
-const EDGE_AVAILABLE_MIGRATIONS = 
+const EDGE_AVAILABLE_MIGRATIONS =
   MigrationUtils.resourceTypes.COOKIES |
   MigrationUtils.resourceTypes.BOOKMARKS |
   MigrationUtils.resourceTypes.HISTORY |
   MigrationUtils.resourceTypes.PASSWORDS;
 
 add_task(function* () {
   let migrator = MigrationUtils.getMigrator("edge");
   Cu.import("resource://gre/modules/AppConstants.jsm");
--- a/browser/components/migration/tests/unit/test_IE7_passwords.js
+++ b/browser/components/migration/tests/unit/test_IE7_passwords.js
@@ -1,387 +1,387 @@
-Cu.import("resource://gre/modules/AppConstants.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
-                                  "resource://gre/modules/WindowsRegistry.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "OSCrypto",
-                                  "resource://gre/modules/OSCrypto.jsm");
-
-const CRYPT_PROTECT_UI_FORBIDDEN = 1;
-const IE7_FORM_PASSWORDS_MIGRATOR_NAME = "IE7FormPasswords";
-const LOGINS_KEY =  "Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2";
-const EXTENSION = "-backup";
-const TESTED_WEBSITES = {
-  twitter: {
-    uri: makeURI("https://twitter.com"),
-    hash: "A89D42BC6406E27265B1AD0782B6F376375764A301",
-    data: [12, 0, 0, 0, 56, 0, 0, 0, 38, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 36, 67, 124, 118, 212, 208, 1, 8, 0, 0, 0, 18, 0, 0, 0, 68, 36, 67, 124, 118, 212, 208, 1, 9, 0, 0, 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 0, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, 57, 0, 0, 0],
-    logins: [
-      {
-        username: "abcdefgh",
-        password: "123456789",
-        hostname: "https://twitter.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439325854000,
-        timeLastUsed: 1439325854000,
-        timePasswordChanged: 1439325854000,
-        timesUsed: 1,
-      },
-    ],
-  },
-  facebook: {
-    uri: makeURI("https://www.facebook.com/"),
-    hash: "EF44D3E034009CB0FD1B1D81A1FF3F3335213BD796",
-    data: [12, 0, 0, 0, 152, 0, 0, 0, 160, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 182, 125, 18, 121, 212, 208, 1, 9, 0, 0, 0, 20, 0, 0, 0, 88, 182, 125, 18, 121, 212, 208, 1, 9, 0, 0, 0, 40, 0, 0, 0, 134, 65, 33, 37, 121, 212, 208, 1, 9, 0, 0, 0, 60, 0, 0, 0, 134, 65, 33, 37, 121, 212, 208, 1, 9, 0, 0, 0, 80, 0, 0, 0, 45, 242, 246, 62, 121, 212, 208, 1, 9, 0, 0, 0, 100, 0, 0, 0, 45, 242, 246, 62, 121, 212, 208, 1, 9, 0, 0, 0, 120, 0, 0, 0, 28, 10, 193, 80, 121, 212, 208, 1, 9, 0, 0, 0, 140, 0, 0, 0, 28, 10, 193, 80, 121, 212, 208, 1, 9, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 48, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 48, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 49, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 49, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 50, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 50, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 51, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 51, 0, 0, 0],
-    logins: [
-      {
-        username: "username0",
-        password: "password0",
-        hostname: "https://www.facebook.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439326966000,
-        timeLastUsed: 1439326966000,
-        timePasswordChanged: 1439326966000,
-        timesUsed: 1,
-     },
-     {
-        username: "username1",
-        password: "password1",
-        hostname: "https://www.facebook.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439326997000,
-        timeLastUsed: 1439326997000,
-        timePasswordChanged: 1439326997000,
-        timesUsed: 1,
-      },
-      {
-        username: "username2",
-        password: "password2",
-        hostname: "https://www.facebook.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439327040000,
-        timeLastUsed: 1439327040000,
-        timePasswordChanged: 1439327040000,
-        timesUsed: 1,
-      },
-      {
-        username: "username3",
-        password: "password3",
-        hostname: "https://www.facebook.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439327070000,
-        timeLastUsed: 1439327070000,
-        timePasswordChanged: 1439327070000,
-        timesUsed: 1,
-      },
-    ],
-  },
-  live: {
-    uri: makeURI("https://login.live.com/"),
-    hash: "7B506F2D6B81D939A8E0456F036EE8970856FF705E",
-    data: [12, 0, 0, 0, 56, 0, 0, 0, 44, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212, 17, 219, 140, 148, 212, 208, 1, 9, 0, 0, 0, 20, 0, 0, 0, 212, 17, 219, 140, 148, 212, 208, 1, 11, 0, 0, 0, 114, 0, 105, 0, 97, 0, 100, 0, 104, 0, 49, 6, 74, 6, 39, 6, 54, 6, 0, 0, 39, 6, 66, 6, 49, 6, 35, 6, 80, 0, 192, 0, 223, 0, 119, 0, 246, 0, 114, 0, 100, 0, 0, 0],
-    logins: [
-      {
-        username: "riadhرياض",
-        password: "اقرأPÀßwörd",
-        hostname: "https://login.live.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439338767000,
-        timeLastUsed: 1439338767000,
-        timePasswordChanged: 1439338767000,
-        timesUsed: 1,
-       },
-    ],
-  },
-  reddit: {
-    uri: makeURI("http://www.reddit.com/"),
-    hash: "B644028D1C109A91EC2C4B9D1F145E55A1FAE42065",
-    data: [12, 0, 0, 0, 152, 0, 0, 0, 212, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 8, 234, 114, 153, 212, 208, 1, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 97, 93, 131, 116, 153, 212, 208, 1, 3, 0, 0, 0, 14, 0, 0, 0, 97, 93, 131, 116, 153, 212, 208, 1, 16, 0, 0, 0, 48, 0, 0, 0, 88, 150, 78, 174, 153, 212, 208, 1, 4, 0, 0, 0, 58, 0, 0, 0, 88, 150, 78, 174, 153, 212, 208, 1, 29, 0, 0, 0, 118, 0, 0, 0, 79, 102, 137, 34, 154, 212, 208, 1, 15, 0, 0, 0, 150, 0, 0, 0, 79, 102, 137, 34, 154, 212, 208, 1, 30, 0, 0, 0, 97, 0, 0, 0, 0, 0, 252, 140, 173, 138, 146, 48, 0, 0, 66, 0, 105, 0, 116, 0, 116, 0, 101, 0, 32, 0, 98, 0, 101, 0, 115, 0, 116, 0, 228, 0, 116, 0, 105, 0, 103, 0, 101, 0, 110, 0, 0, 0, 205, 145, 110, 127, 198, 91, 1, 120, 0, 0, 31, 4, 48, 4, 64, 4, 62, 4, 59, 4, 76, 4, 32, 0, 67, 4, 65, 4, 63, 4, 53, 4, 72, 4, 61, 4, 62, 4, 32, 0, 65, 4, 49, 4, 64, 4, 62, 4, 72, 4, 53, 4, 61, 4, 46, 0, 32, 0, 18, 4, 62, 4, 57, 4, 66, 4, 56, 4, 0, 0, 40, 6, 51, 6, 69, 6, 32, 0, 39, 6, 68, 6, 68, 6, 71, 6, 32, 0, 39, 6, 68, 6, 49, 6, 45, 6, 69, 6, 70, 6, 0, 0, 118, 0, 101, 0, 117, 0, 105, 0, 108, 0, 108, 0, 101, 0, 122, 0, 32, 0, 108, 0, 101, 0, 32, 0, 118, 0, 233, 0, 114, 0, 105, 0, 102, 0, 105, 0, 101, 0, 114, 0, 32, 0, 224, 0, 32, 0, 110, 0, 111, 0, 117, 0, 118, 0, 101, 0, 97, 0, 117, 0, 0, 0],
-    logins: [
-      {
-        username: "購読を",
-        password: "Bitte bestätigen",
-        hostname: "http://www.reddit.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439340874000,
-        timeLastUsed: 1439340874000,
-        timePasswordChanged: 1439340874000,
-        timesUsed: 1,
-      },
-      {
-        username: "重置密码",
-        password: "Пароль успешно сброшен. Войти",
-        hostname: "http://www.reddit.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439340971000,
-        timeLastUsed: 1439340971000,
-        timePasswordChanged: 1439340971000,
-        timesUsed: 1,
-      },
-      {
-        username: "بسم الله الرحمن",
-        password: "veuillez le vérifier à nouveau",
-        hostname: "http://www.reddit.com",
-        formSubmitURL: "",
-        httpRealm: null,
-        usernameField: "",
-        passwordField: "",
-        timeCreated: 1439341166000,
-        timeLastUsed: 1439341166000,
-        timePasswordChanged: 1439341166000,
-        timesUsed: 1,
-     },
-    ],
-  },
-};
-
-const TESTED_URLS = [
-  "http://a.foo.com",
-  "http://b.foo.com",
-  "http://c.foo.com",
-  "http://www.test.net",
-  "http://www.test.net/home",
-  "http://www.test.net/index",
-  "https://a.bar.com",
-  "https://b.bar.com",
-  "https://c.bar.com",
-];
-
-var nsIWindowsRegKey = Ci.nsIWindowsRegKey;
-var Storage2Key;
-
-/*
- * If the key value exists, it's going to be backed up and replaced, so the value could be restored.
- * Otherwise a new value is going to be created.
- */
-function backupAndStore(key, name, value) {
-  if (key.hasValue(name)) {
-    // backup the the current value
-    let type = key.getValueType(name);
-    // create a new value using use the current value name followed by EXTENSION as its new name
-    switch (type) {
-      case nsIWindowsRegKey.TYPE_STRING:
-        key.writeStringValue(name + EXTENSION, key.readStringValue(name));
-        break;
-      case nsIWindowsRegKey.TYPE_BINARY:
-        key.writeBinaryValue(name + EXTENSION, key.readBinaryValue(name));
-        break;
-      case nsIWindowsRegKey.TYPE_INT:
-        key.writeIntValue(name + EXTENSION, key.readIntValue(name));
-        break;
-      case nsIWindowsRegKey.TYPE_INT64:
-        key.writeInt64Value(name + EXTENSION, key.readInt64Value(name));
-        break;
-    }
-  }
-  key.writeBinaryValue(name, value);
-}
-
-// Remove all values where their names are members of the names array from the key of registry
-function removeAllValues(key, names) {
-  for (let name of names) {
-    key.removeValue(name);
-  }
-}
-
-// Restore all the backed up values
-function restore(key) {
-  let count = key.valueCount;
-  let names = []; // the names of the key values
-  for (let i = 0; i < count; ++i) {
-    names.push(key.getValueName(i));
-  }
-
-  for (let name of names) {
-    // backed up values have EXTENSION at the end of their names
-    if (name.lastIndexOf(EXTENSION) == name.length - EXTENSION.length) {
-      let valueName = name.substr(0, name.length - EXTENSION.length);
-      let type = key.getValueType(name);
-      // create a new value using the name before the backup and removed the backed up one
-      switch (type) {
-        case nsIWindowsRegKey.TYPE_STRING:
-          key.writeStringValue(valueName, key.readStringValue(name));
-          key.removeValue(name);
-          break;
-        case nsIWindowsRegKey.TYPE_BINARY:
-          key.writeBinaryValue(valueName, key.readBinaryValue(name));
-          key.removeValue(name);
-          break;
-        case nsIWindowsRegKey.TYPE_INT:
-          key.writeIntValue(valueName, key.readIntValue(name));
-          key.removeValue(name);
-          break;
-        case nsIWindowsRegKey.TYPE_INT64:
-          key.writeInt64Value(valueName, key.readInt64Value(name));
-          key.removeValue(name);
-          break;
-      }
-    }
-  }
-}
-
-function checkLoginsAreEqual(passwordManagerLogin, IELogin, id) {
-  passwordManagerLogin.QueryInterface(Ci.nsILoginMetaInfo);
-  for (let attribute in IELogin) {
-    Assert.equal(passwordManagerLogin[attribute], IELogin[attribute],
-                 "The two logins ID " + id + " have the same " + attribute);
-  }
-}
-
-function createRegistryPath(path) {
-  let loginPath = path.split("\\");
-  let parentKey = Cc["@mozilla.org/windows-registry-key;1"].
-                  createInstance(nsIWindowsRegKey);
-  let currentPath =[];
-  for (let currentKey of loginPath) {
-    parentKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, currentPath.join("\\"),
-                   nsIWindowsRegKey.ACCESS_ALL);
-
-    if (!parentKey.hasChild(currentKey)) {
-      parentKey.createChild(currentKey, 0);
-    }
-    currentPath.push(currentKey);
-    parentKey.close();
-  }
-}
-
-function getFirstResourceOfType(type) {
-  let migrator = Cc["@mozilla.org/profile/migrator;1?app=browser&type=ie"]
-                 .createInstance(Ci.nsISupports)
-                 .wrappedJSObject;
-  let migrators = migrator.getResources();
-  for (let m of migrators) {
-    if (m.name == IE7_FORM_PASSWORDS_MIGRATOR_NAME && m.type == type) {
-      return m;
-    }
-  }
-  throw new Error("failed to find the " + type + " migrator");
-}
-
-function makeURI(aURL) {
-  return Services.io.newURI(aURL, null, null);
-}
-
-add_task(function* setup() {
-  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
-    Assert.throws(() => getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS),
-                  "The migrator doesn't exist for win8+");
-    return;
-  }
-  // create the path to Storage2 in the registry if it doest exist.
-  createRegistryPath(LOGINS_KEY);
-  Storage2Key = Cc["@mozilla.org/windows-registry-key;1"].
-                createInstance(nsIWindowsRegKey);
-  Storage2Key.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, LOGINS_KEY,
-                   nsIWindowsRegKey.ACCESS_ALL);
-
-  // create a dummy value otherwise the migrator doesn't exist
-  if (!Storage2Key.hasValue("dummy")) {
-    Storage2Key.writeBinaryValue("dummy", "dummy");
-  }
-});
-
-add_task(function* test_passwordsNotAvailable() {
-  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
-    return;
-  }
-
-  let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
-  Assert.ok(migrator.exists, "The migrator has to exist");
-  let logins = Services.logins.getAllLogins({});
-  Assert.equal(logins.length, 0, "There are no logins at the beginning of the test");
-
-  let uris = []; // the uris of the migrated logins
-  for (let url of TESTED_URLS) {
-    uris.push(makeURI(url));
-     // in this test, there is no IE login data in the registry, so after the migration, the number
-     // of logins in the store should be 0
-    migrator._migrateURIs(uris);
-    logins = Services.logins.getAllLogins({});
-    Assert.equal(logins.length, 0,
-                 "There are no logins after doing the migration without adding values to the registry");
-  }
-});
-
-add_task(function* test_passwordsAvailable() {
-  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
-    return;
-  }
-
-  let crypto = new OSCrypto();
-  let hashes = []; // the hashes of all migrator websites, this is going to be used for the clean up
-
-  do_register_cleanup(() => {
-    Services.logins.removeAllLogins();
-    logins = Services.logins.getAllLogins({});
-    Assert.equal(logins.length, 0, "There are no logins after the cleanup");
-    //remove all the values created in this test from the registry
-    removeAllValues(Storage2Key, hashes);
-    // restore all backed up values
-    restore(Storage2Key);
-
-    // clean the dummy value
-    if (Storage2Key.hasValue("dummy")) {
-      Storage2Key.removeValue("dummy");
-    }
-    Storage2Key.close();
-    crypto.finalize();
-  });
-
-  let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
-  Assert.ok(migrator.exists, "The migrator has to exist");
-  let logins = Services.logins.getAllLogins({});
-  Assert.equal(logins.length, 0, "There are no logins at the beginning of the test");
-
-  let uris = []; // the uris of the migrated logins
-
-  let loginCount = 0;
-  for (let current in TESTED_WEBSITES) {
-    let website = TESTED_WEBSITES[current];
-    // backup the current the registry value if it exists and replace the existing value/create a
-    // new value with the encrypted data
-    backupAndStore(Storage2Key, website.hash,
-                   crypto.encryptData(crypto.arrayToString(website.data),
-                                      website.uri.spec, true));
-    Assert.ok(migrator.exists, "The migrator has to exist");
-    uris.push(website.uri);
-    hashes.push(website.hash);
-
-    migrator._migrateURIs(uris);
-    logins = Services.logins.getAllLogins({});
-    // check that the number of logins in the password manager has increased as expected which means
-    // that all the values for the current website were imported
-    loginCount += website.logins.length;
-    Assert.equal(logins.length, loginCount,
-                 "The number of logins has increased after the migration");
-    let startIndex = loginCount - website.logins.length;
-    // compares the imported password manager logins with their expected logins
-    for (let i = 0; i < website.logins.length; i++) {
-      checkLoginsAreEqual(logins[startIndex + i], website.logins[i],
-                          " " + current + " - " + i + " ");
-    }
-  }
-});
+Cu.import("resource://gre/modules/AppConstants.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
+                                  "resource://gre/modules/WindowsRegistry.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "OSCrypto",
+                                  "resource://gre/modules/OSCrypto.jsm");
+
+const CRYPT_PROTECT_UI_FORBIDDEN = 1;
+const IE7_FORM_PASSWORDS_MIGRATOR_NAME = "IE7FormPasswords";
+const LOGINS_KEY =  "Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2";
+const EXTENSION = "-backup";
+const TESTED_WEBSITES = {
+  twitter: {
+    uri: makeURI("https://twitter.com"),
+    hash: "A89D42BC6406E27265B1AD0782B6F376375764A301",
+    data: [12, 0, 0, 0, 56, 0, 0, 0, 38, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 36, 67, 124, 118, 212, 208, 1, 8, 0, 0, 0, 18, 0, 0, 0, 68, 36, 67, 124, 118, 212, 208, 1, 9, 0, 0, 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 0, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, 57, 0, 0, 0],
+    logins: [
+      {
+        username: "abcdefgh",
+        password: "123456789",
+        hostname: "https://twitter.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439325854000,
+        timeLastUsed: 1439325854000,
+        timePasswordChanged: 1439325854000,
+        timesUsed: 1,
+      },
+    ],
+  },
+  facebook: {
+    uri: makeURI("https://www.facebook.com/"),
+    hash: "EF44D3E034009CB0FD1B1D81A1FF3F3335213BD796",
+    data: [12, 0, 0, 0, 152, 0, 0, 0, 160, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 182, 125, 18, 121, 212, 208, 1, 9, 0, 0, 0, 20, 0, 0, 0, 88, 182, 125, 18, 121, 212, 208, 1, 9, 0, 0, 0, 40, 0, 0, 0, 134, 65, 33, 37, 121, 212, 208, 1, 9, 0, 0, 0, 60, 0, 0, 0, 134, 65, 33, 37, 121, 212, 208, 1, 9, 0, 0, 0, 80, 0, 0, 0, 45, 242, 246, 62, 121, 212, 208, 1, 9, 0, 0, 0, 100, 0, 0, 0, 45, 242, 246, 62, 121, 212, 208, 1, 9, 0, 0, 0, 120, 0, 0, 0, 28, 10, 193, 80, 121, 212, 208, 1, 9, 0, 0, 0, 140, 0, 0, 0, 28, 10, 193, 80, 121, 212, 208, 1, 9, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 48, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 48, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 49, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 49, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 50, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 50, 0, 0, 0, 117, 0, 115, 0, 101, 0, 114, 0, 110, 0, 97, 0, 109, 0, 101, 0, 51, 0, 0, 0, 112, 0, 97, 0, 115, 0, 115, 0, 119, 0, 111, 0, 114, 0, 100, 0, 51, 0, 0, 0],
+    logins: [
+      {
+        username: "username0",
+        password: "password0",
+        hostname: "https://www.facebook.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439326966000,
+        timeLastUsed: 1439326966000,
+        timePasswordChanged: 1439326966000,
+        timesUsed: 1,
+     },
+     {
+        username: "username1",
+        password: "password1",
+        hostname: "https://www.facebook.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439326997000,
+        timeLastUsed: 1439326997000,
+        timePasswordChanged: 1439326997000,
+        timesUsed: 1,
+      },
+      {
+        username: "username2",
+        password: "password2",
+        hostname: "https://www.facebook.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439327040000,
+        timeLastUsed: 1439327040000,
+        timePasswordChanged: 1439327040000,
+        timesUsed: 1,
+      },
+      {
+        username: "username3",
+        password: "password3",
+        hostname: "https://www.facebook.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439327070000,
+        timeLastUsed: 1439327070000,
+        timePasswordChanged: 1439327070000,
+        timesUsed: 1,
+      },
+    ],
+  },
+  live: {
+    uri: makeURI("https://login.live.com/"),
+    hash: "7B506F2D6B81D939A8E0456F036EE8970856FF705E",
+    data: [12, 0, 0, 0, 56, 0, 0, 0, 44, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212, 17, 219, 140, 148, 212, 208, 1, 9, 0, 0, 0, 20, 0, 0, 0, 212, 17, 219, 140, 148, 212, 208, 1, 11, 0, 0, 0, 114, 0, 105, 0, 97, 0, 100, 0, 104, 0, 49, 6, 74, 6, 39, 6, 54, 6, 0, 0, 39, 6, 66, 6, 49, 6, 35, 6, 80, 0, 192, 0, 223, 0, 119, 0, 246, 0, 114, 0, 100, 0, 0, 0],
+    logins: [
+      {
+        username: "riadhرياض",
+        password: "اقرأPÀßwörd",
+        hostname: "https://login.live.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439338767000,
+        timeLastUsed: 1439338767000,
+        timePasswordChanged: 1439338767000,
+        timesUsed: 1,
+       },
+    ],
+  },
+  reddit: {
+    uri: makeURI("http://www.reddit.com/"),
+    hash: "B644028D1C109A91EC2C4B9D1F145E55A1FAE42065",
+    data: [12, 0, 0, 0, 152, 0, 0, 0, 212, 0, 0, 0, 87, 73, 67, 75, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 8, 234, 114, 153, 212, 208, 1, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 97, 93, 131, 116, 153, 212, 208, 1, 3, 0, 0, 0, 14, 0, 0, 0, 97, 93, 131, 116, 153, 212, 208, 1, 16, 0, 0, 0, 48, 0, 0, 0, 88, 150, 78, 174, 153, 212, 208, 1, 4, 0, 0, 0, 58, 0, 0, 0, 88, 150, 78, 174, 153, 212, 208, 1, 29, 0, 0, 0, 118, 0, 0, 0, 79, 102, 137, 34, 154, 212, 208, 1, 15, 0, 0, 0, 150, 0, 0, 0, 79, 102, 137, 34, 154, 212, 208, 1, 30, 0, 0, 0, 97, 0, 0, 0, 0, 0, 252, 140, 173, 138, 146, 48, 0, 0, 66, 0, 105, 0, 116, 0, 116, 0, 101, 0, 32, 0, 98, 0, 101, 0, 115, 0, 116, 0, 228, 0, 116, 0, 105, 0, 103, 0, 101, 0, 110, 0, 0, 0, 205, 145, 110, 127, 198, 91, 1, 120, 0, 0, 31, 4, 48, 4, 64, 4, 62, 4, 59, 4, 76, 4, 32, 0, 67, 4, 65, 4, 63, 4, 53, 4, 72, 4, 61, 4, 62, 4, 32, 0, 65, 4, 49, 4, 64, 4, 62, 4, 72, 4, 53, 4, 61, 4, 46, 0, 32, 0, 18, 4, 62, 4, 57, 4, 66, 4, 56, 4, 0, 0, 40, 6, 51, 6, 69, 6, 32, 0, 39, 6, 68, 6, 68, 6, 71, 6, 32, 0, 39, 6, 68, 6, 49, 6, 45, 6, 69, 6, 70, 6, 0, 0, 118, 0, 101, 0, 117, 0, 105, 0, 108, 0, 108, 0, 101, 0, 122, 0, 32, 0, 108, 0, 101, 0, 32, 0, 118, 0, 233, 0, 114, 0, 105, 0, 102, 0, 105, 0, 101, 0, 114, 0, 32, 0, 224, 0, 32, 0, 110, 0, 111, 0, 117, 0, 118, 0, 101, 0, 97, 0, 117, 0, 0, 0],
+    logins: [
+      {
+        username: "購読を",
+        password: "Bitte bestätigen",
+        hostname: "http://www.reddit.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439340874000,
+        timeLastUsed: 1439340874000,
+        timePasswordChanged: 1439340874000,
+        timesUsed: 1,
+      },
+      {
+        username: "重置密码",
+        password: "Пароль успешно сброшен. Войти",
+        hostname: "http://www.reddit.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439340971000,
+        timeLastUsed: 1439340971000,
+        timePasswordChanged: 1439340971000,
+        timesUsed: 1,
+      },
+      {
+        username: "بسم الله الرحمن",
+        password: "veuillez le vérifier à nouveau",
+        hostname: "http://www.reddit.com",
+        formSubmitURL: "",
+        httpRealm: null,
+        usernameField: "",
+        passwordField: "",
+        timeCreated: 1439341166000,
+        timeLastUsed: 1439341166000,
+        timePasswordChanged: 1439341166000,
+        timesUsed: 1,
+     },
+    ],
+  },
+};
+
+const TESTED_URLS = [
+  "http://a.foo.com",
+  "http://b.foo.com",
+  "http://c.foo.com",
+  "http://www.test.net",
+  "http://www.test.net/home",
+  "http://www.test.net/index",
+  "https://a.bar.com",
+  "https://b.bar.com",
+  "https://c.bar.com",
+];
+
+var nsIWindowsRegKey = Ci.nsIWindowsRegKey;
+var Storage2Key;
+
+/*
+ * If the key value exists, it's going to be backed up and replaced, so the value could be restored.
+ * Otherwise a new value is going to be created.
+ */
+function backupAndStore(key, name, value) {
+  if (key.hasValue(name)) {
+    // backup the the current value
+    let type = key.getValueType(name);
+    // create a new value using use the current value name followed by EXTENSION as its new name
+    switch (type) {
+      case nsIWindowsRegKey.TYPE_STRING:
+        key.writeStringValue(name + EXTENSION, key.readStringValue(name));
+        break;
+      case nsIWindowsRegKey.TYPE_BINARY:
+        key.writeBinaryValue(name + EXTENSION, key.readBinaryValue(name));
+        break;
+      case nsIWindowsRegKey.TYPE_INT:
+        key.writeIntValue(name + EXTENSION, key.readIntValue(name));
+        break;
+      case nsIWindowsRegKey.TYPE_INT64:
+        key.writeInt64Value(name + EXTENSION, key.readInt64Value(name));
+        break;
+    }
+  }
+  key.writeBinaryValue(name, value);
+}
+
+// Remove all values where their names are members of the names array from the key of registry
+function removeAllValues(key, names) {
+  for (let name of names) {
+    key.removeValue(name);
+  }
+}
+
+// Restore all the backed up values
+function restore(key) {
+  let count = key.valueCount;
+  let names = []; // the names of the key values
+  for (let i = 0; i < count; ++i) {
+    names.push(key.getValueName(i));
+  }
+
+  for (let name of names) {
+    // backed up values have EXTENSION at the end of their names
+    if (name.lastIndexOf(EXTENSION) == name.length - EXTENSION.length) {
+      let valueName = name.substr(0, name.length - EXTENSION.length);
+      let type = key.getValueType(name);
+      // create a new value using the name before the backup and removed the backed up one
+      switch (type) {
+        case nsIWindowsRegKey.TYPE_STRING:
+          key.writeStringValue(valueName, key.readStringValue(name));
+          key.removeValue(name);
+          break;
+        case nsIWindowsRegKey.TYPE_BINARY:
+          key.writeBinaryValue(valueName, key.readBinaryValue(name));
+          key.removeValue(name);
+          break;
+        case nsIWindowsRegKey.TYPE_INT:
+          key.writeIntValue(valueName, key.readIntValue(name));
+          key.removeValue(name);
+          break;
+        case nsIWindowsRegKey.TYPE_INT64:
+          key.writeInt64Value(valueName, key.readInt64Value(name));
+          key.removeValue(name);
+          break;
+      }
+    }
+  }
+}
+
+function checkLoginsAreEqual(passwordManagerLogin, IELogin, id) {
+  passwordManagerLogin.QueryInterface(Ci.nsILoginMetaInfo);
+  for (let attribute in IELogin) {
+    Assert.equal(passwordManagerLogin[attribute], IELogin[attribute],
+                 "The two logins ID " + id + " have the same " + attribute);
+  }
+}
+
+function createRegistryPath(path) {
+  let loginPath = path.split("\\");
+  let parentKey = Cc["@mozilla.org/windows-registry-key;1"].
+                  createInstance(nsIWindowsRegKey);
+  let currentPath =[];
+  for (let currentKey of loginPath) {
+    parentKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, currentPath.join("\\"),
+                   nsIWindowsRegKey.ACCESS_ALL);
+
+    if (!parentKey.hasChild(currentKey)) {
+      parentKey.createChild(currentKey, 0);
+    }
+    currentPath.push(currentKey);
+    parentKey.close();
+  }
+}
+
+function getFirstResourceOfType(type) {
+  let migrator = Cc["@mozilla.org/profile/migrator;1?app=browser&type=ie"]
+                 .createInstance(Ci.nsISupports)
+                 .wrappedJSObject;
+  let migrators = migrator.getResources();
+  for (let m of migrators) {
+    if (m.name == IE7_FORM_PASSWORDS_MIGRATOR_NAME && m.type == type) {
+      return m;
+    }
+  }
+  throw new Error("failed to find the " + type + " migrator");
+}
+
+function makeURI(aURL) {
+  return Services.io.newURI(aURL, null, null);
+}
+
+add_task(function* setup() {
+  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
+    Assert.throws(() => getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS),
+                  "The migrator doesn't exist for win8+");
+    return;
+  }
+  // create the path to Storage2 in the registry if it doest exist.
+  createRegistryPath(LOGINS_KEY);
+  Storage2Key = Cc["@mozilla.org/windows-registry-key;1"].
+                createInstance(nsIWindowsRegKey);
+  Storage2Key.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, LOGINS_KEY,
+                   nsIWindowsRegKey.ACCESS_ALL);
+
+  // create a dummy value otherwise the migrator doesn't exist
+  if (!Storage2Key.hasValue("dummy")) {
+    Storage2Key.writeBinaryValue("dummy", "dummy");
+  }
+});
+
+add_task(function* test_passwordsNotAvailable() {
+  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
+    return;
+  }
+
+  let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
+  Assert.ok(migrator.exists, "The migrator has to exist");
+  let logins = Services.logins.getAllLogins({});
+  Assert.equal(logins.length, 0, "There are no logins at the beginning of the test");
+
+  let uris = []; // the uris of the migrated logins
+  for (let url of TESTED_URLS) {
+    uris.push(makeURI(url));
+     // in this test, there is no IE login data in the registry, so after the migration, the number
+     // of logins in the store should be 0
+    migrator._migrateURIs(uris);
+    logins = Services.logins.getAllLogins({});
+    Assert.equal(logins.length, 0,
+                 "There are no logins after doing the migration without adding values to the registry");
+  }
+});
+
+add_task(function* test_passwordsAvailable() {
+  if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
+    return;
+  }
+
+  let crypto = new OSCrypto();
+  let hashes = []; // the hashes of all migrator websites, this is going to be used for the clean up
+
+  do_register_cleanup(() => {
+    Services.logins.removeAllLogins();
+    logins = Services.logins.getAllLogins({});
+    Assert.equal(logins.length, 0, "There are no logins after the cleanup");
+    //remove all the values created in this test from the registry
+    removeAllValues(Storage2Key, hashes);
+    // restore all backed up values
+    restore(Storage2Key);
+
+    // clean the dummy value
+    if (Storage2Key.hasValue("dummy")) {
+      Storage2Key.removeValue("dummy");
+    }
+    Storage2Key.close();
+    crypto.finalize();
+  });
+
+  let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
+  Assert.ok(migrator.exists, "The migrator has to exist");
+  let logins = Services.logins.getAllLogins({});
+  Assert.equal(logins.length, 0, "There are no logins at the beginning of the test");
+
+  let uris = []; // the uris of the migrated logins
+
+  let loginCount = 0;
+  for (let current in TESTED_WEBSITES) {
+    let website = TESTED_WEBSITES[current];
+    // backup the current the registry value if it exists and replace the existing value/create a
+    // new value with the encrypted data
+    backupAndStore(Storage2Key, website.hash,
+                   crypto.encryptData(crypto.arrayToString(website.data),
+                                      website.uri.spec, true));
+    Assert.ok(migrator.exists, "The migrator has to exist");
+    uris.push(website.uri);
+    hashes.push(website.hash);
+
+    migrator._migrateURIs(uris);
+    logins = Services.logins.getAllLogins({});
+    // check that the number of logins in the password manager has increased as expected which means
+    // that all the values for the current website were imported
+    loginCount += website.logins.length;
+    Assert.equal(logins.length, loginCount,
+                 "The number of logins has increased after the migration");
+    let startIndex = loginCount - website.logins.length;
+    // compares the imported password manager logins with their expected logins
+    for (let i = 0; i < website.logins.length; i++) {
+      checkLoginsAreEqual(logins[startIndex + i], website.logins[i],
+                          " " + current + " - " + i + " ");
+    }
+  }
+});
--- a/browser/components/migration/tests/unit/test_fx_telemetry.js
+++ b/browser/components/migration/tests/unit/test_fx_telemetry.js
@@ -1,288 +1,288 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {});
-
-function run_test() {
-  run_next_test();
-}
-
-function readFile(file) {
-  let stream = Cc['@mozilla.org/network/file-input-stream;1']
-               .createInstance(Ci.nsIFileInputStream);
-  stream.init(file, -1, -1, Ci.nsIFileInputStream.CLOSE_ON_EOF);
-
-  let sis = Cc["@mozilla.org/scriptableinputstream;1"]
-            .createInstance(Ci.nsIScriptableInputStream);
-  sis.init(stream);
-  let contents = sis.read(file.fileSize);
-  sis.close();
-  return contents;
-}
-
-function checkDirectoryContains(dir, files) {
-  print("checking " + dir.path + " - should contain " + Object.keys(files));
-  let seen = new Set();
-  let enumerator = dir.directoryEntries;
-  while (enumerator.hasMoreElements()) {
-    let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
-    print("found file: " + file.path);
-    Assert.ok(file.leafName in files, file.leafName + " exists, but shouldn't");
-
-    let expectedContents = files[file.leafName];
-    if (typeof expectedContents != "string") {
-      // it's a subdir - recurse!
-      Assert.ok(file.isDirectory(), "should be a subdir");
-      let newDir = dir.clone();
-      newDir.append(file.leafName);
-      checkDirectoryContains(newDir, expectedContents);
-    } else {
-      Assert.ok(!file.isDirectory(), "should be a regular file");
-      let contents = readFile(file);
-      Assert.equal(contents, expectedContents);
-    }
-    seen.add(file.leafName);
-  }
-  let missing = [];
-  for (let x in files) {
-    if (!seen.has(x)) {
-      missing.push(x);
-    }
-  }
-  Assert.deepEqual(missing, [], "no missing files in " + dir.path);
-}
-
-function getTestDirs() {
-  // we make a directory structure in a temp dir which mirrors what we are
-  // testing.
-  let tempDir = do_get_tempdir();
-  let srcDir = tempDir.clone();
-  srcDir.append("test_source_dir");
-  srcDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-
-  let targetDir = tempDir.clone();
-  targetDir.append("test_target_dir");
-  targetDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-
-  // no need to cleanup these dirs - the xpcshell harness will do it for us.
-  return [srcDir, targetDir];
-}
-
-function writeToFile(dir, leafName, contents) {
-  let file = dir.clone();
-  file.append(leafName);
-
-  let outputStream = FileUtils.openFileOutputStream(file);
-  outputStream.write(contents, contents.length);
-  outputStream.close();
-}
-
-function createSubDir(dir, subDirName) {
-  let subDir = dir.clone();
-  subDir.append(subDirName);
-  subDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-  return subDir;
-}
-
-function promiseMigrator(name, srcDir, targetDir) {
-  let migrator = Cc["@mozilla.org/profile/migrator;1?app=browser&type=firefox"]
-                 .createInstance(Ci.nsISupports)
-                 .wrappedJSObject;
-  let migrators = migrator._getResourcesInternal(srcDir, targetDir);
-  for (let m of migrators) {
-    if (m.name == name) {
-      return new Promise((resolve, reject) => {
-        m.migrate(resolve);
-      });
-    }
-  }
-  throw new Error("failed to find the " + name + " migrator");
-}
-
-function promiseTelemetryMigrator(srcDir, targetDir) {
-  return promiseMigrator("telemetry", srcDir, targetDir);
-}
-
-add_task(function* test_empty() {
-  let [srcDir, targetDir] = getTestDirs();
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true with empty directories");
-  // check both are empty
-  checkDirectoryContains(srcDir, {});
-  checkDirectoryContains(targetDir, {});
-});
-
-add_task(function* test_migrate_files() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Set up datareporting files, some to copy, some not.
-  let stateContent = JSON.stringify({
-    clientId: "68d5474e-19dc-45c1-8e9a-81fca592707c",
-  });
-  let sessionStateContent = "foobar 5432";
-  let subDir = createSubDir(srcDir, "datareporting");
-  writeToFile(subDir, "state.json", stateContent);
-  writeToFile(subDir, "session-state.json", sessionStateContent);
-  writeToFile(subDir, "other.file", "do not copy");
-
-  let archived = createSubDir(subDir, "archived");
-  writeToFile(archived, "other.file", "do not copy");
-
-  // Set up FHR files, they should not be copied.
-  writeToFile(srcDir, "healthreport.sqlite", "do not copy");
-  writeToFile(srcDir, "healthreport.sqlite-wal", "do not copy");
-  subDir = createSubDir(srcDir, "healthreport");
-  writeToFile(subDir, "state.json", "do not copy");
-  writeToFile(subDir, "other.file", "do not copy");
-
-  // Perform migration.
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true with important telemetry files copied");
-
-  checkDirectoryContains(targetDir, {
-    "datareporting": {
-      "state.json": stateContent,
-      "session-state.json": sessionStateContent,
-    },
-  });
-});
-
-add_task(function* test_fallback_fhr_state() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Test that we fall back to migrating FHR state if the datareporting
-  // state file does not exist.
-  let stateContent = JSON.stringify({
-    clientId: "68d5474e-19dc-45c1-8e9a-81fca592707c",
-  });
-  let subDir = createSubDir(srcDir, "healthreport");
-  writeToFile(subDir, "state.json", stateContent);
-
-  // Perform migration.
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  checkDirectoryContains(targetDir, {
-    "healthreport": {
-      "state.json": stateContent,
-    },
-  });
-});
-
-
-add_task(function* test_datareporting_not_dir() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  writeToFile(srcDir, "datareporting", "I'm a file but should be a directory");
-
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true even though the directory was a file");
-
-  checkDirectoryContains(targetDir, {});
-});
-
-add_task(function* test_datareporting_empty() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Migrate with an empty 'datareporting' subdir.
-  let subDir = createSubDir(srcDir, "datareporting");
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  // We should end up with no migrated files.
-  checkDirectoryContains(targetDir, {
-    "datareporting": {},
-  });
-});
-
-add_task(function* test_healthreport_empty() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Migrate with no 'datareporting' and an empty 'healthreport' subdir.
-  let subDir = createSubDir(srcDir, "healthreport");
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  // We should end up with no migrated files.
-  checkDirectoryContains(targetDir, {});
-});
-
-add_task(function* test_datareporting_many() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Create some datareporting files.
-  let subDir = createSubDir(srcDir, "datareporting");
-  let shouldBeCopied = "should be copied";
-  writeToFile(subDir, "state.json", shouldBeCopied);
-  writeToFile(subDir, "session-state.json", shouldBeCopied);
-  writeToFile(subDir, "something.else", "should not");
-  createSubDir(subDir, "emptyDir");
-
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  checkDirectoryContains(targetDir, {
-    "datareporting" : {
-      "state.json": shouldBeCopied,
-      "session-state.json": shouldBeCopied,
-    }
-  });
-});
-
-add_task(function* test_no_session_state() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Check that migration still works properly if we only have state.json.
-  let subDir = createSubDir(srcDir, "datareporting");
-  let stateContent = "abcd984";
-  writeToFile(subDir, "state.json", stateContent);
-
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  checkDirectoryContains(targetDir, {
-    "datareporting" : {
-      "state.json": stateContent,
-    }
-  });
-});
-
-add_task(function* test_no_state() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // Check that migration still works properly if we only have session-state.json.
-  let subDir = createSubDir(srcDir, "datareporting");
-  let sessionStateContent = "abcd512";
-  writeToFile(subDir, "session-state.json", sessionStateContent);
-
-  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-
-  checkDirectoryContains(targetDir, {
-    "datareporting" : {
-      "session-state.json": sessionStateContent,
-    }
-  });
-});
-
-add_task(function* test_times_migration() {
-  let [srcDir, targetDir] = getTestDirs();
-
-  // create a times.json in the source directory.
-  let contents = JSON.stringify({created: 1234});
-  writeToFile(srcDir, "times.json", contents);
-
-  let earliest = Date.now();
-  let ok = yield promiseMigrator("times", srcDir, targetDir);
-  Assert.ok(ok, "callback should have been true");
-  let latest = Date.now();
-
-  let timesFile = targetDir.clone();
-  timesFile.append("times.json");
-
-  let raw = readFile(timesFile);
-  let times = JSON.parse(raw);
-  Assert.ok(times.reset >= earliest && times.reset <= latest);
-  // and it should have left the creation time alone.
-  Assert.equal(times.created, 1234);
-});
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {});
+
+function run_test() {
+  run_next_test();
+}
+
+function readFile(file) {
+  let stream = Cc['@mozilla.org/network/file-input-stream;1']
+               .createInstance(Ci.nsIFileInputStream);
+  stream.init(file, -1, -1, Ci.nsIFileInputStream.CLOSE_ON_EOF);
+
+  let sis = Cc["@mozilla.org/scriptableinputstream;1"]
+            .createInstance(Ci.nsIScriptableInputStream);
+  sis.init(stream);
+  let contents = sis.read(file.fileSize);
+  sis.close();
+  return contents;
+}
+
+function checkDirectoryContains(dir, files) {
+  print("checking " + dir.path + " - should contain " + Object.keys(files));
+  let seen = new Set();
+  let enumerator = dir.directoryEntries;
+  while (enumerator.hasMoreElements()) {
+    let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
+    print("found file: " + file.path);
+    Assert.ok(file.leafName in files, file.leafName + " exists, but shouldn't");
+
+    let expectedContents = files[file.leafName];
+    if (typeof expectedContents != "string") {
+      // it's a subdir - recurse!
+      Assert.ok(file.isDirectory(), "should be a subdir");
+      let newDir = dir.clone();
+      newDir.append(file.leafName);
+      checkDirectoryContains(newDir, expectedContents);
+    } else {
+      Assert.ok(!file.isDirectory(), "should be a regular file");
+      let contents = readFile(file);
+      Assert.equal(contents, expectedContents);
+    }
+    seen.add(file.leafName);
+  }
+  let missing = [];
+  for (let x in files) {
+    if (!seen.has(x)) {
+      missing.push(x);
+    }
+  }
+  Assert.deepEqual(missing, [], "no missing files in " + dir.path);
+}
+
+function getTestDirs() {
+  // we make a directory structure in a temp dir which mirrors what we are
+  // testing.
+  let tempDir = do_get_tempdir();
+  let srcDir = tempDir.clone();
+  srcDir.append("test_source_dir");
+  srcDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+
+  let targetDir = tempDir.clone();
+  targetDir.append("test_target_dir");
+  targetDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+
+  // no need to cleanup these dirs - the xpcshell harness will do it for us.
+  return [srcDir, targetDir];
+}
+
+function writeToFile(dir, leafName, contents) {
+  let file = dir.clone();
+  file.append(leafName);
+
+  let outputStream = FileUtils.openFileOutputStream(file);
+  outputStream.write(contents, contents.length);
+  outputStream.close();
+}
+
+function createSubDir(dir, subDirName) {
+  let subDir = dir.clone();
+  subDir.append(subDirName);
+  subDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+  return subDir;
+}
+
+function promiseMigrator(name, srcDir, targetDir) {
+  let migrator = Cc["@mozilla.org/profile/migrator;1?app=browser&type=firefox"]
+                 .createInstance(Ci.nsISupports)
+                 .wrappedJSObject;
+  let migrators = migrator._getResourcesInternal(srcDir, targetDir);
+  for (let m of migrators) {
+    if (m.name == name) {
+      return new Promise((resolve, reject) => {
+        m.migrate(resolve);
+      });
+    }
+  }
+  throw new Error("failed to find the " + name + " migrator");
+}
+
+function promiseTelemetryMigrator(srcDir, targetDir) {
+  return promiseMigrator("telemetry", srcDir, targetDir);
+}
+
+add_task(function* test_empty() {
+  let [srcDir, targetDir] = getTestDirs();
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true with empty directories");
+  // check both are empty
+  checkDirectoryContains(srcDir, {});
+  checkDirectoryContains(targetDir, {});
+});
+
+add_task(function* test_migrate_files() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Set up datareporting files, some to copy, some not.
+  let stateContent = JSON.stringify({
+    clientId: "68d5474e-19dc-45c1-8e9a-81fca592707c",
+  });
+  let sessionStateContent = "foobar 5432";
+  let subDir = createSubDir(srcDir, "datareporting");
+  writeToFile(subDir, "state.json", stateContent);
+  writeToFile(subDir, "session-state.json", sessionStateContent);
+  writeToFile(subDir, "other.file", "do not copy");
+
+  let archived = createSubDir(subDir, "archived");
+  writeToFile(archived, "other.file", "do not copy");
+
+  // Set up FHR files, they should not be copied.
+  writeToFile(srcDir, "healthreport.sqlite", "do not copy");
+  writeToFile(srcDir, "healthreport.sqlite-wal", "do not copy");
+  subDir = createSubDir(srcDir, "healthreport");
+  writeToFile(subDir, "state.json", "do not copy");
+  writeToFile(subDir, "other.file", "do not copy");
+
+  // Perform migration.
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true with important telemetry files copied");
+
+  checkDirectoryContains(targetDir, {
+    "datareporting": {
+      "state.json": stateContent,
+      "session-state.json": sessionStateContent,
+    },
+  });
+});
+
+add_task(function* test_fallback_fhr_state() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Test that we fall back to migrating FHR state if the datareporting
+  // state file does not exist.
+  let stateContent = JSON.stringify({
+    clientId: "68d5474e-19dc-45c1-8e9a-81fca592707c",
+  });
+  let subDir = createSubDir(srcDir, "healthreport");
+  writeToFile(subDir, "state.json", stateContent);
+
+  // Perform migration.
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  checkDirectoryContains(targetDir, {
+    "healthreport": {
+      "state.json": stateContent,
+    },
+  });
+});
+
+
+add_task(function* test_datareporting_not_dir() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  writeToFile(srcDir, "datareporting", "I'm a file but should be a directory");
+
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true even though the directory was a file");
+
+  checkDirectoryContains(targetDir, {});
+});
+
+add_task(function* test_datareporting_empty() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Migrate with an empty 'datareporting' subdir.
+  let subDir = createSubDir(srcDir, "datareporting");
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  // We should end up with no migrated files.
+  checkDirectoryContains(targetDir, {
+    "datareporting": {},
+  });
+});
+
+add_task(function* test_healthreport_empty() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Migrate with no 'datareporting' and an empty 'healthreport' subdir.
+  let subDir = createSubDir(srcDir, "healthreport");
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  // We should end up with no migrated files.
+  checkDirectoryContains(targetDir, {});
+});
+
+add_task(function* test_datareporting_many() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Create some datareporting files.
+  let subDir = createSubDir(srcDir, "datareporting");
+  let shouldBeCopied = "should be copied";
+  writeToFile(subDir, "state.json", shouldBeCopied);
+  writeToFile(subDir, "session-state.json", shouldBeCopied);
+  writeToFile(subDir, "something.else", "should not");
+  createSubDir(subDir, "emptyDir");
+
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  checkDirectoryContains(targetDir, {
+    "datareporting" : {
+      "state.json": shouldBeCopied,
+      "session-state.json": shouldBeCopied,
+    }
+  });
+});
+
+add_task(function* test_no_session_state() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Check that migration still works properly if we only have state.json.
+  let subDir = createSubDir(srcDir, "datareporting");
+  let stateContent = "abcd984";
+  writeToFile(subDir, "state.json", stateContent);
+
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  checkDirectoryContains(targetDir, {
+    "datareporting" : {
+      "state.json": stateContent,
+    }
+  });
+});
+
+add_task(function* test_no_state() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // Check that migration still works properly if we only have session-state.json.
+  let subDir = createSubDir(srcDir, "datareporting");
+  let sessionStateContent = "abcd512";
+  writeToFile(subDir, "session-state.json", sessionStateContent);
+
+  let ok = yield promiseTelemetryMigrator(srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+
+  checkDirectoryContains(targetDir, {
+    "datareporting" : {
+      "session-state.json": sessionStateContent,
+    }
+  });
+});
+
+add_task(function* test_times_migration() {
+  let [srcDir, targetDir] = getTestDirs();
+
+  // create a times.json in the source directory.
+  let contents = JSON.stringify({created: 1234});
+  writeToFile(srcDir, "times.json", contents);
+
+  let earliest = Date.now();
+  let ok = yield promiseMigrator("times", srcDir, targetDir);
+  Assert.ok(ok, "callback should have been true");
+  let latest = Date.now();
+
+  let timesFile = targetDir.clone();
+  timesFile.append("times.json");
+
+  let raw = readFile(timesFile);
+  let times = JSON.parse(raw);
+  Assert.ok(times.reset >= earliest && times.reset <= latest);
+  // and it should have left the creation time alone.
+  Assert.equal(times.created, 1234);
+});