Bug 1549814 - LoginHelper.searchLoginsWithObject always returns an array so no need to check for a falsy return value. r?MattN draft
authorpulselistener
Sat, 18 May 2019 06:49:20 +0000
changeset 2008573 7b25b65910f86ee3f7534cd2aca748c90fcb9fbf
parent 2008572 5d36f520c456447f354447c462c5c6364d85c04d
child 2008574 125909675145ef08262d8459821b1221087cadf4
push id363923
push userreviewbot
push dateSat, 18 May 2019 06:49:52 +0000
treeherdertry@6eb4ec2cb49f [default view] [failures only]
reviewersMattN
bugs1549814
milestone68.0a1
Bug 1549814 - LoginHelper.searchLoginsWithObject always returns an array so no need to check for a falsy return value. r?MattN Differential Revision: https://phabricator.services.mozilla.com/D31712 Differential Diff: PHID-DIFF-2ngrvlumrmlv67s3kufz
browser/components/aboutlogins/AboutLoginsParent.jsm
--- a/browser/components/aboutlogins/AboutLoginsParent.jsm
+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
@@ -73,18 +73,18 @@ var AboutLoginsParent = {
       case "AboutLogins:DeleteLogin": {
         let login = LoginHelper.vanillaObjectToLogin(message.data.login);
         Services.logins.removeLogin(login);
         break;
       }
       case "AboutLogins:OpenSite": {
         let guid = message.data.login.guid;
         let logins = LoginHelper.searchLoginsWithObject({guid});
-        if (!logins || logins.length != 1) {
-          log.warn(`AboutLogins:OpenSite: expected to find a login for guid: ${guid} but found ${(logins || []).length}`);
+        if (logins.length != 1) {
+          log.warn(`AboutLogins:OpenSite: expected to find a login for guid: ${guid} but found ${logins.length}`);
           return;
         }
 
         message.target.ownerGlobal.openWebLinkIn(logins[0].hostname, "tab", {relatedToCurrent: true});
         break;
       }
       case "AboutLogins:Subscribe": {
         if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) {
@@ -94,18 +94,18 @@ var AboutLoginsParent = {
 
         let messageManager = message.target.messageManager;
         messageManager.sendAsyncMessage("AboutLogins:AllLogins", this.getAllLogins());
         break;
       }
       case "AboutLogins:UpdateLogin": {
         let loginUpdates = message.data.login;
         let logins = LoginHelper.searchLoginsWithObject({guid: loginUpdates.guid});
-        if (!logins || logins.length != 1) {
-          log.warn(`AboutLogins:UpdateLogin: expected to find a login for guid: ${loginUpdates.guid} but found ${(logins || []).length}`);
+        if (logins.length != 1) {
+          log.warn(`AboutLogins:UpdateLogin: expected to find a login for guid: ${loginUpdates.guid} but found ${logins.length}`);
           return;
         }
 
         let modifiedLogin = logins[0].clone();
         if (loginUpdates.hasOwnProperty("username")) {
           modifiedLogin.username = loginUpdates.username;
         }
         if (loginUpdates.hasOwnProperty("password")) {