From 3d6b345ffb25f7450d34d245e15d26a856eb1d40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:08:00 -0400 Subject: [PATCH] Refactor - auto update credential provider script (#22104) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../Assets/CC_Script/FormLikeFactory.sys.mjs | 14 ++++++-------- .../Assets/CC_Script/HeuristicsRegExp.sys.mjs | 7 +++++-- .../Assets/CC_Script/LoginFormFactory.sys.mjs | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/firefox-ios/Client/Assets/CC_Script/FormLikeFactory.sys.mjs b/firefox-ios/Client/Assets/CC_Script/FormLikeFactory.sys.mjs index dec7a6bf6b2c..972455145fa5 100644 --- a/firefox-ios/Client/Assets/CC_Script/FormLikeFactory.sys.mjs +++ b/firefox-ios/Client/Assets/CC_Script/FormLikeFactory.sys.mjs @@ -37,24 +37,22 @@ export let FormLikeFactory = { }, /** - * Create a FormLike object from an HTMLHtmlElement that is the root of the document + * Create a FormLike object from an element that is the root of the document * * Currently all not in a
are one LoginForm but this * shouldn't be relied upon as the heuristics may change to detect multiple * "forms" (e.g. registration and login) on one page with a . * - * @param {HTMLHtmlElement} aDocumentRoot + * @param {HTMLElement} aDocumentRoot * @param {Object} aOptions * @param {boolean} [aOptions.ignoreForm = false] * True to always use owner document as the `form` - * @return {FormLike} - * @throws Error if aDocumentRoot isn't an HTMLHtmlElement + * @return {formLike} + * @throws Error if aDocumentRoot is null */ createFromDocumentRoot(aDocumentRoot, aOptions = {}) { - if (!HTMLHtmlElement.isInstance(aDocumentRoot)) { - throw new Error( - "createFromDocumentRoot: aDocumentRoot must be an HTMLHtmlElement" - ); + if (!aDocumentRoot) { + throw new Error("createFromDocumentRoot: aDocumentRoot is null"); } let formLike = { diff --git a/firefox-ios/Client/Assets/CC_Script/HeuristicsRegExp.sys.mjs b/firefox-ios/Client/Assets/CC_Script/HeuristicsRegExp.sys.mjs index 359e9541108f..3fad1105fbfe 100644 --- a/firefox-ios/Client/Assets/CC_Script/HeuristicsRegExp.sys.mjs +++ b/firefox-ios/Client/Assets/CC_Script/HeuristicsRegExp.sys.mjs @@ -8,7 +8,6 @@ export const HeuristicsRegExp = { RULES: { email: undefined, tel: undefined, - organization: undefined, "street-address": undefined, "address-line1": undefined, "address-line2": undefined, @@ -16,6 +15,10 @@ export const HeuristicsRegExp = { "address-level2": undefined, "address-level1": undefined, "postal-code": undefined, + // Note: We place the `organization` field after the `address` fields, to + // ensure that all address-related fields that might contain organization + // info are matched as address fields first. + organization: undefined, country: undefined, // Note: We place the `cc-name` field for Credit Card first, because // it is more specific than the `name` field below and we want to check @@ -46,7 +49,7 @@ export const HeuristicsRegExp = { "address-line1": "addrline1|address_1|addl1", "address-line2": "addrline2|address_2|addl2", "address-line3": "addrline3|address_3|addl3", - "address-level1": "land", // de-DE + "country": "land", // de-DE "postal-code": "^PLZ(\\b|\\*)", // de-DE "additional-name": "apellido.?materno|lastlastname", "cc-name": diff --git a/firefox-ios/Client/Assets/CC_Script/LoginFormFactory.sys.mjs b/firefox-ios/Client/Assets/CC_Script/LoginFormFactory.sys.mjs index 57f46f16a12a..4619c72bf306 100644 --- a/firefox-ios/Client/Assets/CC_Script/LoginFormFactory.sys.mjs +++ b/firefox-ios/Client/Assets/CC_Script/LoginFormFactory.sys.mjs @@ -55,15 +55,15 @@ export const LoginFormFactory = { }, /** - * Create a LoginForm object from the HTMLHtmlElement that is the root of the document + * Create a LoginForm object from an elememt that is the root of the document * * Currently all not in a are one LoginForm but this * shouldn't be relied upon as the heuristics may change to detect multiple * "forms" (e.g. registration and login) on one page with a . * - * @param {HTMLHtmlElement} aDocumentRoot + * @param {HTMLElement} aDocumentRoot * @return {LoginForm} - * @throws Error if aDocumentRoot isn't an HTMLHtmlElement + * @throws Error if aDocumentRoot is null */ createFromDocumentRoot(aDocumentRoot) { const formLike = lazy.FormLikeFactory.createFromDocumentRoot(aDocumentRoot);