From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- .../passwordmgr/LoginAutoComplete.sys.mjs | 48 ++++------------------ 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'toolkit/components/passwordmgr/LoginAutoComplete.sys.mjs') diff --git a/toolkit/components/passwordmgr/LoginAutoComplete.sys.mjs b/toolkit/components/passwordmgr/LoginAutoComplete.sys.mjs index 411d9249db..187caf9d62 100644 --- a/toolkit/components/passwordmgr/LoginAutoComplete.sys.mjs +++ b/toolkit/components/passwordmgr/LoginAutoComplete.sys.mjs @@ -7,7 +7,10 @@ */ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; -import { GenericAutocompleteItem } from "resource://gre/modules/FillHelpers.sys.mjs"; +import { + GenericAutocompleteItem, + sendFillRequestToParent, +} from "resource://gre/modules/FillHelpers.sys.mjs"; const lazy = {}; @@ -487,7 +490,7 @@ export class LoginAutoComplete { * @param {string} aSearchString The value typed in the field. * @param {nsIAutoCompleteResult} aPreviousResult * @param {HTMLInputElement} aElement - * @param {nsIFormAutoCompleteObserver} aCallback + * @param {nsIFormFillCompleteObserver} aCallback */ startSearch(aSearchString, aPreviousResult, aElement, aCallback) { let { isNullPrincipal } = aElement.nodePrincipal; @@ -717,7 +720,6 @@ export class LoginAutoComplete { let gAutoCompleteListener = { added: false, - fillRequestId: 0, init() { if (!this.added) { @@ -729,45 +731,11 @@ let gAutoCompleteListener = { async observe(subject, topic, data) { switch (topic) { case "autocomplete-will-enter-text": { - await this.sendFillRequestToLoginManagerParent(subject, data); + if (subject && subject == lazy.formFillController.controller.input) { + await sendFillRequestToParent("LoginManager", subject, data); + } break; } } }, - - async sendFillRequestToLoginManagerParent(input, comment) { - if (!comment) { - return; - } - - if (input != lazy.formFillController.controller.input) { - return; - } - - const { fillMessageName, fillMessageData } = JSON.parse(comment ?? "{}"); - if (!fillMessageName) { - return; - } - - this.fillRequestId++; - const fillRequestId = this.fillRequestId; - const child = lazy.LoginManagerChild.forWindow( - input.focusedInput.ownerGlobal - ); - const value = await child.sendQuery(fillMessageName, fillMessageData ?? {}); - - // skip fill if another fill operation started during await - if (fillRequestId != this.fillRequestId) { - return; - } - - if (typeof value !== "string") { - return; - } - - // If LoginManagerParent returned a string to fill, we must do it here because - // nsAutoCompleteController.cpp already finished it's work before we finished await. - input.textValue = value; - input.selectTextRange(value.length, value.length); - }, }; -- cgit v1.2.3