Bug 1532098 - Update login instead delete then add. r=nalexander
authorEdouard Oger <eoger@fastmail.com>
Wed, 06 Mar 2019 17:52:30 +0000
changeset 520538 632248682d293fdc5f47aa5dc78ea4718bd0239b
parent 520537 783538d74b6ab0dbffd89ac71eda0d8952394037
child 520539 318d0fe526a048c5340bf6095b1d567d1d60bdc4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1532098
milestone67.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 1532098 - Update login instead delete then add. r=nalexander Differential Revision: https://phabricator.services.mozilla.com/D22346
mobile/android/chrome/content/aboutLogins.js
--- a/mobile/android/chrome/content/aboutLogins.js
+++ b/mobile/android/chrome/content/aboutLogins.js
@@ -288,22 +288,28 @@ var Logins = {
         this._showList();
         return;
       }
 
       let logins = Services.logins.findLogins({}, origDomain, origDomain, null);
 
       for (let i = 0; i < logins.length; i++) {
         if (logins[i].username == origUsername) {
-          let clone = logins[i].clone();
-          clone.username = newUsername;
-          clone.password = newPassword;
-          clone.hostname = newDomain;
-          Services.logins.removeLogin(logins[i]);
-          Services.logins.addLogin(clone);
+          let propBag = Cc["@mozilla.org/hash-property-bag;1"].
+            createInstance(Ci.nsIWritablePropertyBag);
+          if (newUsername !== origUsername) {
+            propBag.setProperty("username", newUsername);
+          }
+          if (newPassword !== origPassword) {
+            propBag.setProperty("password", newPassword);
+          }
+          if (newDomain !== origDomain) {
+            propBag.setProperty("hostname", newDomain);
+          }
+          Services.logins.modifyLogin(logins[i], propBag);
           break;
         }
       }
     } catch (e) {
       Snackbars.show(gStringBundle.GetStringFromName("editLogin.couldNotSave"), Snackbars.LENGTH_LONG);
       return;
     }
     Snackbars.show(gStringBundle.GetStringFromName("editLogin.saved1"), Snackbars.LENGTH_LONG);