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:44:29 +0000
changeset 2008540 af5c7a0c2cfa21e1b09a6eea005658e508357bc7
parent 2008539 a4376acc05b7c94b226d14671f04b681b44ddb96
child 2008541 feb98ece6f6565b43f58e724660ca8259b1ea587
push id363921
push userreviewbot
push dateSat, 18 May 2019 06:44:53 +0000
treeherdertry@feb98ece6f65 [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")) {