commit 5de158f01823e0fc2b7bd989115bb71b3aabb171 parent 57912b1d826ebd7207cdf746f284f8ae4222648c Author: Johannes Salas Schmidt <joschmidt@mozilla.com> Date: Fri, 12 Dec 2025 10:18:05 +0000 Bug 1846334 - Replace usage of nsILoginManager::searchLogins with searchLoginsAsync r=mtigley,credential-management-reviewers,dimi Differential Revision: https://phabricator.services.mozilla.com/D274734 Diffstat:
16 files changed, 297 insertions(+), 225 deletions(-)
diff --git a/browser/base/content/nsContextMenu.sys.mjs b/browser/base/content/nsContextMenu.sys.mjs @@ -1250,19 +1250,7 @@ export class nsContextMenu { } // Update sub-menu items. - let fragment = lazy.LoginManagerContextMenu.addLoginsToMenu( - this.targetIdentifier, - this.browser, - formOrigin - ); - - if (!fragment) { - return; - } - - showUseSavedLogin = true; - let popup = document.getElementById("fill-login-popup"); - popup.appendChild(fragment); + this.updatePasswordManagerSubMenuItems(document, formOrigin); } finally { const documentURI = this.contentData?.documentURIObject; const showRelay = @@ -1288,6 +1276,25 @@ export class nsContextMenu { } } + async updatePasswordManagerSubMenuItems(document, formOrigin) { + const fragment = await lazy.LoginManagerContextMenu.addLoginsToMenu( + this.targetIdentifier, + this.browser, + formOrigin + ); + + if (!fragment) { + return; + } + + let popup = document.getElementById("fill-login-popup"); + popup.appendChild(fragment); + + this.showItem("fill-login", true); + + this.setItemAttr("passwordmgr-items-separator", "ensureHidden", null); + } + initSyncItems() { this.syncItemsShown = this.window.gSync.updateContentContextMenu(this); } diff --git a/browser/components/aboutlogins/AboutLoginsParent.sys.mjs b/browser/components/aboutlogins/AboutLoginsParent.sys.mjs @@ -142,7 +142,7 @@ export class AboutLoginsParent extends JSWindowActorParent { break; } case "AboutLogins:UpdateLogin": { - this.#updateLogin(message.data.login); + await this.#updateLogin(message.data.login); break; } case "AboutLogins:ExportPasswords": { @@ -341,8 +341,8 @@ export class AboutLoginsParent extends JSWindowActorParent { } } - #updateLogin(loginUpdates) { - let logins = lazy.LoginHelper.searchLoginsWithObject({ + async #updateLogin(loginUpdates) { + let logins = await Services.logins.searchLoginsAsync({ guid: loginUpdates.guid, }); if (logins.length != 1) { diff --git a/browser/components/aboutlogins/tests/browser/head.js b/browser/components/aboutlogins/tests/browser/head.js @@ -83,13 +83,10 @@ const CryptoErrors = { async function addLogin(login) { const result = await Services.logins.addLoginAsync(login); - registerCleanupFunction(() => { - let matchData = Cc["@mozilla.org/hash-property-bag;1"].createInstance( - Ci.nsIWritablePropertyBag2 - ); - matchData.setPropertyAsAUTF8String("guid", result.guid); - - let logins = Services.logins.searchLogins(matchData); + registerCleanupFunction(async () => { + let logins = await Services.logins.searchLoginsAsync({ + guid: result.guid, + }); if (!logins.length) { return; } diff --git a/toolkit/components/passwordmgr/LoginManager.sys.mjs b/toolkit/components/passwordmgr/LoginManager.sys.mjs @@ -397,8 +397,10 @@ LoginManager.prototype = { `Searching for matching logins for origin: ${matchData.origin}` ); - if (!matchData.origin) { - throw new Error("searchLoginsAsync: An `origin` is required"); + if (!matchData.guid && !matchData.origin) { + lazy.log.warn( + "A `guid` or `origin` field is recommended for searchLoginsAsync matchData." + ); } return this._storage.searchLoginsAsync(matchData); @@ -406,6 +408,7 @@ LoginManager.prototype = { /** * @return {nsILoginInfo[]} which are decrypted. + * Deprecated: use searchLoginsAsync instead */ searchLogins(matchData) { lazy.log.debug( diff --git a/toolkit/components/passwordmgr/LoginManagerAuthPrompter.sys.mjs b/toolkit/components/passwordmgr/LoginManagerAuthPrompter.sys.mjs @@ -373,6 +373,15 @@ LoginManagerAuthPrompter.prototype = { /** * Looks up a username and password in the database. Will prompt the user * with a dialog, even if a username and password are found. + * + * Returns a promise, resolving to an object containing the result as well as + * the password and username: + * Eg: + * { + * ok: true, + * username: "user", + * password: "secure", + * } */ async asyncPromptUsernameAndPassword( aDialogTitle, @@ -403,13 +412,10 @@ LoginManagerAuthPrompter.prototype = { } // Look for existing logins. - // We don't use searchLoginsAsync here and in asyncPromptPassword - // because of bug 1848682 - let matchData = lazy.LoginHelper.newPropertyBag({ + foundLogins = await Services.logins.searchLoginsAsync({ origin, httpRealm: realm, }); - foundLogins = Services.logins.searchLogins(matchData); // XXX Like the original code, we can't deal with multiple // account selection. (bug 227632) @@ -446,12 +452,20 @@ LoginManagerAuthPrompter.prototype = { ); if (!ok || !canRememberLogin) { - return ok; + return { + ok, + username: aUsername.value, + password: aPassword.value, + }; } if (!aPassword.value) { this.log("No password entered, so won't offer to save."); - return ok; + return { + ok, + username: aUsername.value, + password: aPassword.value, + }; } // XXX We can't prompt with multiple logins yet (bug 227632), so @@ -486,7 +500,11 @@ LoginManagerAuthPrompter.prototype = { ); } - return ok; + return { + ok, + username: aUsername.value, + password: aPassword.value, + }; }, /** @@ -496,6 +514,14 @@ LoginManagerAuthPrompter.prototype = { * If a password is not found in the database, the user will be prompted * with a dialog with a text field and ok/cancel buttons. If the user * allows it, then the password will be saved in the database. + * + * Returns a promise, resolving to an object containing the result as well as + * the password: + * Eg: + * { + * ok: true, + * password: "secure", + * } */ async asyncPromptPassword( aDialogTitle, @@ -523,11 +549,10 @@ LoginManagerAuthPrompter.prototype = { Services.logins.getLoginSavingEnabled(origin); if (!aPassword.value) { // Look for existing logins. - let matchData = lazy.LoginHelper.newPropertyBag({ + let foundLogins = await Services.logins.searchLoginsAsync({ origin, httpRealm: realm, }); - let foundLogins = Services.logins.searchLogins(matchData); // XXX Like the original code, we can't deal with multiple // account selection (bug 227632). We can deal with finding the @@ -535,9 +560,13 @@ LoginManagerAuthPrompter.prototype = { // just return the first match. for (var i = 0; i < foundLogins.length; ++i) { if (foundLogins[i].username == username) { - aPassword.value = foundLogins[i].password; // wallet returned straight away, so this mimics that code - return true; + aPassword.value = foundLogins[i].password; + // returning the found password + return { + ok: true, + password: aPassword.value, + }; } } } @@ -564,7 +593,11 @@ LoginManagerAuthPrompter.prototype = { await Services.logins.addLoginAsync(newLogin); } - return ok; + // returning the provided password + return { + ok, + password: aPassword.value, + }; }, /* ---------- nsIAuthPrompt helpers ---------- */ diff --git a/toolkit/components/passwordmgr/LoginManagerContextMenu.sys.mjs b/toolkit/components/passwordmgr/LoginManagerContextMenu.sys.mjs @@ -23,10 +23,10 @@ export const LoginManagerContextMenu = { * The origin of the document that the context menu was activated from. * This isn't the same as the browser's top-level document origin * when subframes are involved. - * @returns {DocumentFragment} a document fragment with all the login items. + * @returns Promise {DocumentFragment} a promise resolving to a document fragment with all the login items. */ - addLoginsToMenu(inputElementIdentifier, browser, formOrigin) { - let foundLogins = this._findLogins(formOrigin); + async addLoginsToMenu(inputElementIdentifier, browser, formOrigin) { + let foundLogins = await this._findLogins(formOrigin); if (!foundLogins.length) { return null; @@ -107,12 +107,12 @@ export const LoginManagerContextMenu = { * * @returns {nsILoginInfo[]} a login list */ - _findLogins(formOrigin) { + async _findLogins(formOrigin) { let searchParams = { origin: formOrigin, schemeUpgrades: lazy.LoginHelper.schemeUpgrades, }; - let logins = lazy.LoginHelper.searchLoginsWithObject(searchParams); + let logins = await Services.logins.searchLoginsAsync(searchParams); let resolveBy = ["scheme", "timePasswordChanged"]; logins = lazy.LoginHelper.dedupeLogins( logins, diff --git a/toolkit/components/passwordmgr/LoginManagerPrompter.sys.mjs b/toolkit/components/passwordmgr/LoginManagerPrompter.sys.mjs @@ -248,11 +248,8 @@ export class LoginManagerPrompter { } }; - const updateButtonLabel = () => { - if (!currentNotification) { - console.error("updateButtonLabel, no currentNotification"); - } - const foundLogins = lazy.LoginHelper.searchLoginsWithObject({ + const updateButtonLabel = async () => { + const foundLogins = await Services.logins.searchLoginsAsync({ formActionOrigin: login.formActionOrigin, origin: login.origin, httpRealm: login.httpRealm, @@ -270,6 +267,11 @@ export class LoginManagerPrompter { const mainButton = this.getLabelAndAccessKey(messageIds.mainButton); + if (!currentNotification) { + console.error("updateButtonLabel, no currentNotification"); + return; + } + // Update the labels for the next time the panel is opened. currentNotification.mainAction.label = mainButton.label; currentNotification.mainAction.accessKey = mainButton.accessKey; @@ -352,7 +354,7 @@ export class LoginManagerPrompter { }; const persistData = async () => { - const foundLogins = lazy.LoginHelper.searchLoginsWithObject({ + const foundLogins = await Services.logins.searchLoginsAsync({ formActionOrigin: login.formActionOrigin, origin: login.origin, httpRealm: login.httpRealm, diff --git a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_httpsUpgrade.js b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_httpsUpgrade.js @@ -298,7 +298,7 @@ add_task(async function test_httpsUpgradeCaptureFields_captureMatchingHTTP() { logins = await Services.logins.getAllLogins(); Assert.equal(logins.length, 2, "Should have both HTTP and HTTPS still"); - let httpsLogins = LoginHelper.searchLoginsWithObject({ + let httpsLogins = await Services.logins.searchLoginsAsync({ origin: "https://example.com", }); Assert.equal(httpsLogins.length, 1, "Check https logins count"); @@ -306,7 +306,7 @@ add_task(async function test_httpsUpgradeCaptureFields_captureMatchingHTTP() { Assert.ok(httpsLogin.equals(login1HTTPS), "Check HTTPS login didn't change"); Assert.equal(httpsLogin.timesUsed, 1, "Check times used"); - let httpLogins = LoginHelper.searchLoginsWithObject({ + let httpLogins = await Services.logins.searchLoginsAsync({ origin: "http://example.com", }); Assert.equal(httpLogins.length, 1, "Check http logins count"); diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html @@ -136,11 +136,11 @@ add_task(async function test_promptPassword_defaultAccept() { }; pword.value = "inputpw"; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "secret", "Checking returned password"); + is(password, "secret", "Checking returned password"); }); add_task(async function test_promptPassword_defaultCancel() { @@ -165,7 +165,7 @@ add_task(async function test_promptPassword_defaultCancel() { }; pword.value = "inputpw"; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", + const { ok: isOk } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); await promptDone; ok(!isOk, "Checking dialog return value (cancel)"); @@ -194,20 +194,20 @@ add_task(async function test_promptPassword_emptyAccept() { }; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://nonexample.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "secret", "Checking returned password"); + is(password, "secret", "Checking returned password"); }); add_task(async function test_promptPassword_saved() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "examplepass", "Checking returned password"); + is(password, "examplepass", "Checking returned password"); }); add_task(async function test_promptPassword_noMatchingPasswordForEmptyUN() { @@ -234,56 +234,56 @@ add_task(async function test_promptPassword_noMatchingPasswordForEmptyUN() { }; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "secret", "Checking returned password"); + is(password, "secret", "Checking returned password"); }); add_task(async function test_promptPassword_matchingPWForUN() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user1name@example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user1name@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "user1pass", "Checking returned password"); + is(password, "user1pass", "Checking returned password"); }); add_task(async function test_promptPassword_matchingPWForUN2() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user2name@example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user2name@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "user2pass", "Checking returned password"); + is(password, "user2pass", "Checking returned password"); }); add_task(async function test_promptPassword_matchingPWForUN3() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user3%2Ename%40host@example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://user3%2Ename%40host@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "user3pass", "Checking returned password"); + is(password, "user3pass", "Checking returned password"); }); add_task(async function test_promptPassword_extraAt() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://100@beef@example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://100@beef@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "user3pass", "Checking returned password"); + is(password, "user3pass", "Checking returned password"); }); add_task(async function test_promptPassword_usernameEncoding() { // No default password provided, matching login is returned w/o prompting. pword.value = null; - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://100%25beef@example2.com", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "http://100%25beef@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "user3pass", "Checking returned password"); + is(password, "user3pass", "Checking returned password"); // XXX test saving a password with Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY }); @@ -311,11 +311,11 @@ add_task(async function test_promptPassword_realm() { }; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "fill2pass", "Checking returned password"); + is(password, "fill2pass", "Checking returned password"); }); add_task(async function test_promptPassword_realm2() { @@ -341,11 +341,11 @@ add_task(async function test_promptPassword_realm2() { }; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", + const { ok: isOk, password } = await prompter1.asyncPromptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(pword.value, "fill2pass", "Checking returned password"); + is(password, "fill2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_accept() { @@ -372,12 +372,12 @@ add_task(async function test_promptUsernameAndPassword_accept() { uname.value = "inuser"; pword.value = "inpass"; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "outuser", "Checking returned username"); - is(pword.value, "outpass", "Checking returned password"); + is(username, "outuser", "Checking returned username"); + is(password, "outpass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_cancel() { @@ -402,7 +402,7 @@ add_task(async function test_promptUsernameAndPassword_cancel() { uname.value = "inuser"; pword.value = "inpass"; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", + const { ok: isOk } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); await promptDone; ok(!isOk, "Checking dialog return value (cancel)"); @@ -431,12 +431,12 @@ add_task(async function test_promptUsernameAndPassword_autofill() { uname.value = null; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "", "Checking returned username"); - is(pword.value, "examplepass", "Checking returned password"); + is(username, "", "Checking returned username"); + is(password, "examplepass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_multipleExisting() { @@ -463,12 +463,12 @@ add_task(async function test_promptUsernameAndPassword_multipleExisting() { uname.value = null; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - ok(uname.value == "user1name" || uname.value == "user2name", "Checking returned username"); - ok(pword.value == "user1pass" || uname.value == "user2pass", "Checking returned password"); + ok(username == "user1name" || username == "user2name", "Checking returned username"); + ok(password == "user1pass" || username == "user2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_multipleExisting1() { @@ -494,12 +494,12 @@ add_task(async function test_promptUsernameAndPassword_multipleExisting1() { uname.value = "user1name"; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "user1name", "Checking returned username"); - is(pword.value, "user1pass", "Checking returned password"); + is(username, "user1name", "Checking returned username"); + is(password, "user1pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_multipleExisting2() { @@ -525,12 +525,12 @@ add_task(async function test_promptUsernameAndPassword_multipleExisting2() { uname.value = "user2name"; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "user2name", "Checking returned username"); - is(pword.value, "user2pass", "Checking returned password"); + is(username, "user2name", "Checking returned username"); + is(password, "user2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_passwordChange() { @@ -557,12 +557,12 @@ add_task(async function test_promptUsernameAndPassword_passwordChange() { uname.value = "user2name"; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "user2name", "Checking returned username"); - is(pword.value, "NEWuser2pass", "Checking returned password"); + is(username, "user2name", "Checking returned username"); + is(password, "NEWuser2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_changePasswordBack() { @@ -589,12 +589,12 @@ add_task(async function test_promptUsernameAndPassword_changePasswordBack() { uname.value = "user2name"; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "user2name", "Checking returned username"); - is(pword.value, "user2pass", "Checking returned password"); + is(username, "user2name", "Checking returned username"); + is(password, "user2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_realm() { @@ -622,12 +622,12 @@ add_task(async function test_promptUsernameAndPassword_realm() { uname.value = null; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "fill2user", "Checking returned username"); - is(pword.value, "fill2pass", "Checking returned password"); + is(username, "fill2user", "Checking returned username"); + is(password, "fill2pass", "Checking returned password"); }); add_task(async function test_promptUsernameAndPassword_realm2() { @@ -655,12 +655,12 @@ add_task(async function test_promptUsernameAndPassword_realm2() { uname.value = null; pword.value = null; promptDone = handlePrompt(state, action); - isOk = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", + const { ok: isOk, username, password } = await prompter1.asyncPromptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); await promptDone; ok(isOk, "Checking dialog return value (accept)"); - is(uname.value, "fill2user", "Checking returned username"); - is(pword.value, "fill2pass", "Checking returned password"); + is(username, "fill2user", "Checking returned username"); + is(password, "fill2pass", "Checking returned password"); }); </script> diff --git a/toolkit/components/passwordmgr/test/unit/test_context_menu.js b/toolkit/components/passwordmgr/test/unit/test_context_menu.js @@ -255,7 +255,7 @@ async function runTestcase({ formOrigin, savedLogins, expectedItems }) { await Services.logins.addLogins(savedLogins); // Create the logins menuitems fragment. - let { fragment, document } = createLoginsFragment( + let { fragment, document } = await createLoginsFragment( formOrigin, DOCUMENT_CONTENT ); @@ -285,7 +285,7 @@ async function runTestcase({ formOrigin, savedLogins, expectedItems }) { /** * Create a fragment with a menuitem for each login. */ -function createLoginsFragment(url, content) { +async function createLoginsFragment(url, content) { const CHROME_URL = "chrome://mock-chrome/content/"; // Create a mock document. @@ -302,13 +302,14 @@ function createLoginsFragment(url, content) { }; let formOrigin = LoginHelper.getLoginOrigin(url); + let fragment = await LoginManagerContextMenu.addLoginsToMenu( + null, + browser, + formOrigin + ); return { document, - fragment: LoginManagerContextMenu.addLoginsToMenu( - null, - browser, - formOrigin - ), + fragment, }; } diff --git a/toolkit/components/passwordmgr/test/unit/test_legacy_empty_formActionOrigin.js b/toolkit/components/passwordmgr/test/unit/test_legacy_empty_formActionOrigin.js @@ -69,12 +69,12 @@ add_task(async function test_addLogin_wildcard() { * that have an empty formActionOrigin in the store, even when a formActionOrigin is * specified. */ -add_task(function test_search_all_wildcard() { +add_task(async function test_search_all_wildcard() { // Search a given formActionOrigin on any host. - let matchData = newPropertyBag({ + const result = await Services.logins.searchLoginsAsync({ formActionOrigin: "http://www.example.com", }); - Assert.equal(Services.logins.searchLogins(matchData).length, 2); + Assert.equal(result.length, 2); Assert.equal( Services.logins.countLogins("", "http://www.example.com", null), @@ -82,8 +82,11 @@ add_task(function test_search_all_wildcard() { ); // Restrict the search to one host. - matchData.setProperty("origin", "http://any.example.com"); - Assert.equal(Services.logins.searchLogins(matchData).length, 1); + const result2 = await Services.logins.searchLoginsAsync({ + formActionOrigin: "http://www.example.com", + origin: "http://any.example.com", + }); + Assert.equal(result2.length, 1); Assert.equal( Services.logins.countLogins( @@ -99,10 +102,10 @@ add_task(function test_search_all_wildcard() { * Verifies that specifying an empty string for formActionOrigin in searchLogins * includes only logins that have an empty formActionOrigin in the store. */ -add_task(function test_searchLogins_wildcard() { - let logins = Services.logins.searchLogins( - newPropertyBag({ formActionOrigin: "" }) - ); +add_task(async function test_searchLogins_wildcard() { + let logins = await Services.logins.searchLoginsAsync({ + formActionOrigin: "", + }); let loginInfo = TestData.formLogin({ origin: "http://any.example.com", diff --git a/toolkit/components/passwordmgr/test/unit/test_logins_decrypt_failure.js b/toolkit/components/passwordmgr/test/unit/test_logins_decrypt_failure.js @@ -36,8 +36,8 @@ add_task(async function test_logins_decrypt_failure() { // These functions don't see the non-decryptable entries anymore. let savedLogins = await Services.logins.getAllLogins(); Assert.equal(savedLogins.length, 0, "getAllLogins length"); - await Assert.rejects(Services.logins.searchLoginsAsync({}), /is required/); - Assert.equal(Services.logins.searchLogins(newPropertyBag()).length, 0); + const result = await Services.logins.searchLoginsAsync({}); + Assert.equal(result.length, 0); Assert.throws( () => Services.logins.modifyLogin(logins[0], newPropertyBag()), /No matching logins/ @@ -69,8 +69,9 @@ add_task(async function test_logins_decrypt_failure() { ).length, 1 ); - let matchData = newPropertyBag({ origin: "http://www.example.com" }); - Assert.equal(Services.logins.searchLogins(matchData).length, 1); + let matchData = { origin: "http://www.example.com" }; + const result2 = await Services.logins.searchLoginsAsync(matchData); + Assert.equal(result2.length, 1); // Removing single logins does not remove non-decryptable logins. for (let loginInfo of TestData.loginList()) { @@ -119,12 +120,8 @@ add_task(async function test_add_logins_with_decrypt_failure() { await Services.logins.addLoginAsync(login); // We can search for this login by GUID. - let searchProp = Cc["@mozilla.org/hash-property-bag;1"].createInstance( - Ci.nsIWritablePropertyBag2 - ); - searchProp.setPropertyAsAUTF8String("guid", login.guid); - - equal(Services.logins.searchLogins(searchProp).length, 1); + const result = await Services.logins.searchLoginsAsync({ guid: login.guid }); + equal(result.length, 1); // We should fail to re-add it as it remains good. await Assert.rejects( @@ -141,11 +138,13 @@ add_task(async function test_add_logins_with_decrypt_failure() { resetPrimaryPassword(); // We can no longer find it in our search. - equal(Services.logins.searchLogins(searchProp).length, 0); + const result1 = await Services.logins.searchLoginsAsync({ guid: login.guid }); + equal(result1.length, 0); // So we should be able to re-add a login with that same GUID. await Services.logins.addLoginAsync(login); - equal(Services.logins.searchLogins(searchProp).length, 1); + const result2 = await Services.logins.searchLoginsAsync({ guid: login.guid }); + equal(result2.length, 1); Services.logins.removeAllUserFacingLogins(); }); diff --git a/toolkit/components/passwordmgr/test/unit/test_logins_metainfo.js b/toolkit/components/passwordmgr/test/unit/test_logins_metainfo.js @@ -248,34 +248,28 @@ add_task(async function test_modifyLogin_nsIProperyBag_metainfo_duplicate() { /** * Tests searching logins using nsILoginMetaInfo properties. */ -add_task(function test_searchLogins_metainfo() { +add_task(async function test_searchLogins_metainfo() { // Find by GUID. - let logins = Services.logins.searchLogins( - newPropertyBag({ - guid: gLoginMetaInfo1.guid, - }) - ); + let logins = await Services.logins.searchLoginsAsync({ + guid: gLoginMetaInfo1.guid, + }); Assert.equal(logins.length, 1); let foundLogin = logins[0].QueryInterface(Ci.nsILoginMetaInfo); assertMetaInfoEqual(foundLogin, gLoginMetaInfo1); // Find by timestamp. - logins = Services.logins.searchLogins( - newPropertyBag({ - timePasswordChanged: gLoginMetaInfo2.timePasswordChanged, - }) - ); + logins = await Services.logins.searchLoginsAsync({ + timePasswordChanged: gLoginMetaInfo2.timePasswordChanged, + }); Assert.equal(logins.length, 1); foundLogin = logins[0].QueryInterface(Ci.nsILoginMetaInfo); assertMetaInfoEqual(foundLogin, gLoginMetaInfo2); // Find using two properties at the same time. - logins = Services.logins.searchLogins( - newPropertyBag({ - guid: gLoginMetaInfo3.guid, - timePasswordChanged: gLoginMetaInfo3.timePasswordChanged, - }) - ); + logins = await Services.logins.searchLoginsAsync({ + guid: gLoginMetaInfo3.guid, + timePasswordChanged: gLoginMetaInfo3.timePasswordChanged, + }); Assert.equal(logins.length, 1); foundLogin = logins[0].QueryInterface(Ci.nsILoginMetaInfo); assertMetaInfoEqual(foundLogin, gLoginMetaInfo3); diff --git a/toolkit/components/passwordmgr/test/unit/test_logins_search.js b/toolkit/components/passwordmgr/test/unit/test_logins_search.js @@ -35,13 +35,13 @@ function buildExpectedLogins(aQuery) { * this value is just used to verify that modifications to the test data * don't make the current test meaningless. */ -function checkSearchLogins(aQuery, aExpectedCount) { +async function checkSearchLogins(aQuery, aExpectedCount) { info("Testing searchLogins for " + JSON.stringify(aQuery)); let expectedLogins = buildExpectedLogins(aQuery); Assert.equal(expectedLogins.length, aExpectedCount); - let logins = Services.logins.searchLogins(newPropertyBag(aQuery)); + let logins = await Services.logins.searchLoginsAsync(aQuery); LoginTestUtils.assertLoginListsEqual(logins, expectedLogins); } @@ -58,7 +58,7 @@ function checkSearchLogins(aQuery, aExpectedCount) { * this value is just used to verify that modifications to the test data * don't make the current test meaningless. */ -function checkAllSearches(aQuery, aExpectedCount) { +async function checkAllSearches(aQuery, aExpectedCount) { info("Testing all search functions for " + JSON.stringify(aQuery)); let expectedLogins = buildExpectedLogins(aQuery); @@ -77,7 +77,7 @@ function checkAllSearches(aQuery, aExpectedCount) { Assert.equal(count, expectedLogins.length); // Test searchLogins. - checkSearchLogins(aQuery, aExpectedCount); + await checkSearchLogins(aQuery, aExpectedCount); } // Tests @@ -92,48 +92,51 @@ add_setup(async () => { /** * Tests searchLogins, and countLogins with basic queries. */ -add_task(function test_search_all_basic() { +add_task(async function test_search_all_basic() { // Find all logins, using no filters in the search functions. - checkAllSearches({}, 28); + await checkAllSearches({}, 28); // Find all form logins, then all authentication logins. - checkAllSearches({ httpRealm: null }, 17); - checkAllSearches({ formActionOrigin: null }, 11); + await checkAllSearches({ httpRealm: null }, 17); + await checkAllSearches({ formActionOrigin: null }, 11); // Find all form logins on one host, then all authentication logins. - checkAllSearches({ origin: "http://www4.example.com", httpRealm: null }, 3); - checkAllSearches( + await checkAllSearches( + { origin: "http://www4.example.com", httpRealm: null }, + 3 + ); + await checkAllSearches( { origin: "http://www2.example.org", formActionOrigin: null }, 2 ); // Verify that scheme and subdomain are distinct in the origin. - checkAllSearches({ origin: "http://www.example.com" }, 1); - checkAllSearches({ origin: "https://www.example.com" }, 1); - checkAllSearches({ origin: "https://example.com" }, 1); - checkAllSearches({ origin: "http://www3.example.com" }, 3); + await checkAllSearches({ origin: "http://www.example.com" }, 1); + await checkAllSearches({ origin: "https://www.example.com" }, 1); + await checkAllSearches({ origin: "https://example.com" }, 1); + await checkAllSearches({ origin: "http://www3.example.com" }, 3); // Verify that scheme and subdomain are distinct in formActionOrigin. - checkAllSearches({ formActionOrigin: "http://www.example.com" }, 2); - checkAllSearches({ formActionOrigin: "https://www.example.com" }, 2); - checkAllSearches({ formActionOrigin: "http://example.com" }, 1); + await checkAllSearches({ formActionOrigin: "http://www.example.com" }, 2); + await checkAllSearches({ formActionOrigin: "https://www.example.com" }, 2); + await checkAllSearches({ formActionOrigin: "http://example.com" }, 1); // Find by formActionOrigin on a single host. - checkAllSearches( + await checkAllSearches( { origin: "http://www3.example.com", formActionOrigin: "http://www.example.com", }, 1 ); - checkAllSearches( + await checkAllSearches( { origin: "http://www3.example.com", formActionOrigin: "https://www.example.com", }, 1 ); - checkAllSearches( + await checkAllSearches( { origin: "http://www3.example.com", formActionOrigin: "http://example.com", @@ -142,20 +145,20 @@ add_task(function test_search_all_basic() { ); // Find by httpRealm on all hosts. - checkAllSearches({ httpRealm: "The HTTP Realm" }, 3); - checkAllSearches({ httpRealm: "ftp://ftp.example.org" }, 1); - checkAllSearches({ httpRealm: "The HTTP Realm Other" }, 2); + await checkAllSearches({ httpRealm: "The HTTP Realm" }, 3); + await checkAllSearches({ httpRealm: "ftp://ftp.example.org" }, 1); + await checkAllSearches({ httpRealm: "The HTTP Realm Other" }, 2); // Find by httpRealm on a single host. - checkAllSearches( + await checkAllSearches( { origin: "http://example.net", httpRealm: "The HTTP Realm" }, 1 ); - checkAllSearches( + await checkAllSearches( { origin: "http://example.net", httpRealm: "The HTTP Realm Other" }, 1 ); - checkAllSearches( + await checkAllSearches( { origin: "ftp://example.net", httpRealm: "ftp://example.net" }, 1 ); @@ -164,18 +167,18 @@ add_task(function test_search_all_basic() { /** * Tests searchLogins with advanced queries. */ -add_task(function test_searchLogins() { - checkSearchLogins({ usernameField: "form_field_username" }, 12); - checkSearchLogins({ passwordField: "form_field_password" }, 13); +add_task(async function test_searchLogins() { + await checkSearchLogins({ usernameField: "form_field_username" }, 12); + await checkSearchLogins({ passwordField: "form_field_password" }, 13); // Find all logins with an empty usernameField, including for authentication. - checkSearchLogins({ usernameField: "" }, 16); + await checkSearchLogins({ usernameField: "" }, 16); // Find form logins with an empty usernameField. - checkSearchLogins({ httpRealm: null, usernameField: "" }, 5); + await checkSearchLogins({ httpRealm: null, usernameField: "" }, 5); // Find logins with an empty usernameField on one host. - checkSearchLogins( + await checkSearchLogins( { origin: "http://www6.example.com", usernameField: "" }, 1 ); @@ -184,9 +187,9 @@ add_task(function test_searchLogins() { /** * Tests searchLogins with invalid arguments. */ -add_task(function test_searchLogins_invalid() { - Assert.throws( - () => Services.logins.searchLogins(newPropertyBag({ username: "value" })), +add_task(async function test_searchLogins_invalid() { + await Assert.rejects( + Services.logins.searchLoginsAsync({ foo: "value" }), /Unexpected field/ ); }); @@ -215,13 +218,13 @@ add_task(function test_search_all_full_case_sensitive() { * Tests searchLogins, and countLogins with queries that should * return no values. */ -add_task(function test_search_all_empty() { +add_task(async function test_search_all_empty() { checkAllSearches({ origin: "http://nonexistent.example.com" }, 0); checkAllSearches( { formActionOrigin: "http://www.example.com", httpRealm: "The HTTP Realm" }, 0 ); - checkSearchLogins({ origin: "" }, 0); - checkSearchLogins({ id: "1000" }, 0); + await checkSearchLogins({ origin: "" }, 0); + await checkSearchLogins({ id: "1000" }, 0); }); diff --git a/toolkit/components/passwordmgr/test/unit/test_maybeImportLogin.js b/toolkit/components/passwordmgr/test/unit/test_maybeImportLogin.js @@ -64,7 +64,9 @@ add_task(async function test_new_logins() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -84,14 +86,18 @@ add_task(async function test_new_logins() { importedLogin, "Return value should indicate another imported login." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, `There should still be 1 login for ${HOST1}` ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST2 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST2, + }); Assert.equal( matchingLogins.length, 1, @@ -115,7 +121,9 @@ add_task(async function test_duplicate_logins() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -134,7 +142,9 @@ add_task(async function test_duplicate_logins() { !importedLogin, "Return value should indicate no new login was imported." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -154,7 +164,9 @@ add_task(async function test_different_passwords() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -175,7 +187,9 @@ add_task(async function test_different_passwords() { !importedLogin, "Return value should not indicate imported login (as we updated an existing one)." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -201,7 +215,9 @@ add_task(async function test_different_passwords() { !importedLogin, "Return value should not indicate imported login (as we didn't update anything)." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -226,7 +242,9 @@ add_task(async function test_different_usernames_without_guid() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -245,7 +263,9 @@ add_task(async function test_different_usernames_without_guid() { importedLogin, "Return value should indicate another imported login." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 2, @@ -265,7 +285,9 @@ add_task(async function test_different_usernames_with_guid() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -287,7 +309,9 @@ add_task(async function test_different_usernames_with_guid() { "modified", "Return value should indicate an update" ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST2 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST2, + }); Assert.equal( matchingLogins.length, 1, @@ -311,7 +335,9 @@ add_task(async function test_different_targets() { }, ]); Assert.ok(importedLogin, "Return value should indicate imported login."); - let matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + let matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -332,7 +358,9 @@ add_task(async function test_different_targets() { "Return value should NOT indicate imported login " + "(because a missing formActionOrigin and httpRealm should be duped to the existing login)." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 1, @@ -357,7 +385,9 @@ add_task(async function test_different_targets() { "Return value should indicate another imported login " + "as an httpRealm login shouldn't be duped." ); - matchingLogins = LoginHelper.searchLoginsWithObject({ origin: HOST1 }); + matchingLogins = await Services.logins.searchLoginsAsync({ + origin: HOST1, + }); Assert.equal( matchingLogins.length, 2, diff --git a/toolkit/components/passwordmgr/test/unit/test_search_schemeUpgrades.js b/toolkit/components/passwordmgr/test/unit/test_search_schemeUpgrades.js @@ -42,13 +42,13 @@ function buildExpectedLogins(aQuery) { * this value is just used to verify that modifications to the test data * don't make the current test meaningless. */ -function checkSearch(aQuery, aExpectedCount) { +async function checkSearch(aQuery, aExpectedCount) { info("Testing searchLogins for " + JSON.stringify(aQuery)); let expectedLogins = buildExpectedLogins(aQuery); Assert.equal(expectedLogins.length, aExpectedCount); - let logins = Services.logins.searchLogins(newPropertyBag(aQuery)); + let logins = await Services.logins.searchLoginsAsync(aQuery); LoginTestUtils.assertLoginListsEqual(logins, expectedLogins); } @@ -62,29 +62,29 @@ add_setup(async () => { /** * Tests searchLogins with the `schemeUpgrades` property */ -add_task(function test_search_schemeUpgrades_origin() { +add_task(async function test_search_schemeUpgrades_origin() { // Origin-only - checkSearch( + await checkSearch( { origin: HTTPS_ORIGIN, }, 1 ); - checkSearch( + await checkSearch( { origin: HTTPS_ORIGIN, schemeUpgrades: false, }, 1 ); - checkSearch( + await checkSearch( { origin: HTTPS_ORIGIN, schemeUpgrades: undefined, }, 1 ); - checkSearch( + await checkSearch( { origin: HTTPS_ORIGIN, schemeUpgrades: true, @@ -96,28 +96,28 @@ add_task(function test_search_schemeUpgrades_origin() { /** * Same as above but replacing origin with formActionOrigin. */ -add_task(function test_search_schemeUpgrades_formActionOrigin() { - checkSearch( +add_task(async function test_search_schemeUpgrades_formActionOrigin() { + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, schemeUpgrades: false, }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, schemeUpgrades: undefined, }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, schemeUpgrades: true, @@ -126,15 +126,15 @@ add_task(function test_search_schemeUpgrades_formActionOrigin() { ); }); -add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { - checkSearch( +add_task(async function test_search_schemeUpgrades_origin_formActionOrigin() { + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, }, 1 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -142,7 +142,7 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { }, 1 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -150,7 +150,7 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { }, 1 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -158,7 +158,7 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -167,7 +167,7 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -177,7 +177,7 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { }, 2 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTPS_ORIGIN, @@ -193,8 +193,8 @@ add_task(function test_search_schemeUpgrades_origin_formActionOrigin() { /** * HTTP submitting to HTTPS */ -add_task(function test_http_to_https() { - checkSearch( +add_task(async function test_http_to_https() { + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTP3_ORIGIN, @@ -203,7 +203,7 @@ add_task(function test_http_to_https() { }, 1 ); - checkSearch( + await checkSearch( { formActionOrigin: HTTPS_ORIGIN, origin: HTTP3_ORIGIN, @@ -217,8 +217,8 @@ add_task(function test_http_to_https() { /** * schemeUpgrades shouldn't cause downgrades */ -add_task(function test_search_schemeUpgrades_downgrade() { - checkSearch( +add_task(async function test_search_schemeUpgrades_downgrade() { + await checkSearch( { formActionOrigin: HTTP_ORIGIN, origin: HTTP_ORIGIN, @@ -228,7 +228,7 @@ add_task(function test_search_schemeUpgrades_downgrade() { info( "The same number should be found with schemeUpgrades since we're searching for HTTP" ); - checkSearch( + await checkSearch( { formActionOrigin: HTTP_ORIGIN, origin: HTTP_ORIGIN,