Backed out changeset 5ce299ca9581 (bug 1840584) for causing bc failures on browser_OfficeDepot.js CLOSED TREE

This commit is contained in:
Norisz Fay 2023-07-04 12:34:01 +03:00
Родитель e2a456d64f
Коммит 8cc1f1a03a
7 изменённых файлов: 7 добавлений и 380 удалений

Просмотреть файл

@ -33,8 +33,6 @@ skip-if = ((os == "mac") || (os == 'linux') || (os == 'win'))
skip-if = ((!debug && os == "mac") || (os == 'linux') || (os == 'win'))
[browser_creditCard_heuristics.js]
skip-if = apple_silicon && !debug # Bug 1714221
[browser_creditCard_heuristics_autofill_name.js]
skip-if = apple_silicon && !debug # Bug 1714221
[browser_creditCard_heuristics_cc_type.js]
skip-if = apple_silicon && !debug # Bug 1714221
[browser_creditCard_submission_autodetect_type.js]

Просмотреть файл

@ -1,183 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_PROFILE = {
"cc-name": "John Doe",
"cc-number": "4111111111111111",
// "cc-type" should be remove from proile after fixing Bug 1834768.
"cc-type": "visa",
"cc-exp-month": 4,
"cc-exp-year": new Date().getFullYear(),
};
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.formautofill.creditCards.supported", "on"],
["extensions.formautofill.creditCards.enabled", true],
],
});
});
add_autofill_heuristic_tests([
{
description: `cc-number + first name with autocomplete attribute`,
fixtureData: `
<form>
<input id="cc-number" autocomplete="cc-number">
<input id="name" autocomplete="given-name">
</form>`,
profile: TEST_PROFILE,
expectedResult: [
{
fields: [
{
fieldName: "cc-number",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-number"],
},
{
fieldName: "cc-name",
reason: "update-heuristic",
autofill: TEST_PROFILE["cc-name"],
},
],
},
],
},
{
description: `cc-exp + first name with autocomplete attribute`,
fixtureData: `
<form>
<input id="cc-number" autocomplete="cc-number">
<input id="cc-exp" autocomplete="cc-exp">
<input id="name" autocomplete="given-name">
</form>`,
profile: TEST_PROFILE,
expectedResult: [
{
fields: [
{
fieldName: "cc-number",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-number"],
},
{
fieldName: "cc-exp",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-exp"],
},
{
fieldName: "cc-name",
reason: "update-heuristic",
autofill: TEST_PROFILE["cc-name"],
},
],
},
],
},
{
description: `cc-number + first and last name with autocomplete attribute`,
fixtureData: `
<form>
<input id="cc-number" autocomplete="cc-number">
<input id="given" autocomplete="given-name">
<input id="family" autocomplete="family-name">
</form>`,
profile: TEST_PROFILE,
expectedResult: [
{
fields: [
{
fieldName: "cc-number",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-number"],
},
{
fieldName: "cc-given-name",
reason: "update-heuristic",
autofill: "John",
},
{
fieldName: "cc-family-name",
reason: "update-heuristic",
autofill: "Doe",
},
],
},
],
},
{
description: `cc-number + first and last name without autocomplete attribute`,
fixtureData: `
<form>
<input id="cc-number" autocomplete="cc-number">
<input id="given" placeholder="First Name">
<input id="family" placeholder="Last Name">
</form>`,
profile: TEST_PROFILE,
expectedResult: [
{
fields: [
{
fieldName: "cc-number",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-number"],
},
{
fieldName: "cc-given-name",
reason: "update-heuristic",
autofill: "John",
},
{
fieldName: "cc-family-name",
reason: "update-heuristic",
autofill: "Doe",
},
],
},
],
},
{
description: `previous field is a credit card name field`,
fixtureData: `
<form>
<input id="cc-number" autocomplete="cc-number">
<input id="cc-name" autocomplete="cc-name">
<input id="given" autocomplete="given-name">
<input id="family" autocomplete="family-name">
<input id="address" autocomplete="street-address">
<input id="country" autocomplete="country">
</form>`,
profile: TEST_PROFILE,
expectedResult: [
{
fields: [
{
fieldName: "cc-number",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-number"],
},
{
fieldName: "cc-name",
reason: "autocomplete",
autofill: TEST_PROFILE["cc-name"],
},
],
},
{
default: {
reason: "autocomplete",
},
fields: [
{ fieldName: "given-name" },
{ fieldName: "family-name" },
{ fieldName: "street-address" },
{ fieldName: "country" },
],
},
],
},
]);

Просмотреть файл

@ -845,7 +845,7 @@ function verifySectionAutofillResult(sections, expectedSectionsInfo) {
Assert.equal(
field.element.value,
expeceted.autofill ?? "",
expeceted.autofill,
`Autofilled value for element(id=${field.element.id}, field name=${field.fieldName}) should be equal`
);
});

Просмотреть файл

@ -7,7 +7,6 @@ support-files =
[browser_autocomplete_off_on_form.js]
[browser_autocomplete_off_on_inputs.js]
[browser_basic.js]
[browser_capture_name.js]
[browser_cc_exp.js]
[browser_de_fields.js]
[browser_fr_fields.js]

Просмотреть файл

@ -1,107 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from ../head.js */
"use strict";
const TESTCASES = [
{
description: `cc-number + first name with autocomplete attribute`,
document: `<form id="form">
<input id="cc-number" autocomplete="cc-number">
<input id="name" autocomplete="given-name">
<input type="submit"/>
</form>`,
fillValues: {
"#cc-number": "4111111111111111",
"#name": "John Doe",
},
expected: "John Doe",
},
{
description: `cc-number + first and last name with autocomplete attribute`,
document: `<form id="form">
<input id="cc-number" autocomplete="cc-number">
<input id="given" autocomplete="given-name">
<input id="family" autocomplete="family-name">
<input type="submit"/>
</form>`,
fillValues: {
"#cc-number": "4111111111111111",
"#given": "John",
"#family": "Doe",
},
expected: "John Doe",
},
{
description: `cc-number + first and last name without autocomplete attribute`,
document: `<form id="form">
<input id="cc-number" autocomplete="cc-number">
<input id="given" placeholder="First Name">
<input id="family" placeholder="Last Name">
<input type="submit"/>
</form>`,
fillValues: {
"#cc-number": "4111111111111111",
"#given": "John",
"#family": "Doe",
},
expected: "John Doe",
},
{
description: `name + cc-number with autocomplete attribute`,
document: `<form id="form">
<input id="name" autocomplete="given-name">
<input id="cc-number" autocomplete="cc-number">
<input type="submit"/>
</form>`,
fillValues: {
"#cc-number": "4111111111111111",
"#name": "John Doe",
},
expected: undefined,
},
];
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.formautofill.creditCards.supported", "on"],
["extensions.formautofill.creditCards.enabled", true],
],
});
});
add_task(async function test_save_doorhanger_click_save() {
for (const TEST of TESTCASES) {
info(`Test ${TEST.description}`);
let onChanged = waitForStorageChangedEvents("add");
await BrowserTestUtils.withNewTab(EMPTY_URL, async function (browser) {
await SpecialPowers.spawn(browser, [TEST.document], doc => {
// eslint-disable-next-line no-unsanitized/property
content.document.body.innerHTML = doc;
});
await SimpleTest.promiseFocus(browser);
let onPopupShown = waitForPopupShown();
await focusUpdateSubmitForm(browser, {
focusSelector: "#cc-number",
newValues: TEST.fillValues,
});
await onPopupShown;
await clickDoorhangerButton(MAIN_BUTTON);
});
await onChanged;
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
dump(`[Dimi]${JSON.stringify(creditCards[0])}\n`);
is(creditCards[0]["cc-name"], TEST.expected, "Verify the name field");
await removeAllRecords();
}
});

Просмотреть файл

@ -393,6 +393,9 @@ export const FormAutofillHeuristics = {
return true;
},
// The old heuristics can be removed when we fully adopt fathom, so disable the
// esline complexity check for now
/* eslint-disable complexity */
/**
* Try to look for expiration date fields and revise the field names if needed.
*
@ -453,57 +456,6 @@ export const FormAutofillHeuristics = {
return false;
},
/**
* Look for cc-*-name fields when *-name field is present
*
* @param {FieldScanner} scanner
* The current parsing status for all elements
* @returns {boolean}
* Return true if there is any field can be recognized in the parser,
* otherwise false.
*/
_parseCreditCardNameFields(scanner, fieldDetail) {
const INTERESTED_FIELDS = ["given-name", "additional-name", "family-name"];
if (!INTERESTED_FIELDS.includes(fieldDetail.fieldName)) {
return false;
}
const fields = [];
for (let idx = scanner.parsingIndex; !scanner.parsingFinished; idx++) {
const detail = scanner.getFieldDetailByIndex(idx);
if (!INTERESTED_FIELDS.includes(detail?.fieldName)) {
break;
}
fields.push(detail);
}
// If the previous element is a cc-number field, these name fields is likely cc name fields
const previous = scanner.getFieldDetailByIndex(
scanner.parsingIndex - 1
)?.fieldName;
if (previous?.startsWith("cc-") && previous != "cc-name") {
// If there is only one field, assume the name field a `cc-name` field
if (fields.length == 1) {
scanner.updateFieldName(scanner.parsingIndex, `cc-name`, true);
scanner.parsingIndex += 1;
} else {
// update *-name to cc-*-name
for (const field of fields) {
scanner.updateFieldName(
scanner.parsingIndex,
`cc-${field.fieldName}`,
true
);
scanner.parsingIndex += 1;
}
}
return true;
}
return false;
},
/**
* This function should provide all field details of a form which are placed
* in the belonging section. The details contain the autocomplete info
@ -549,8 +501,7 @@ export const FormAutofillHeuristics = {
this._parsePhoneFields(scanner, fieldDetail) ||
this._parseStreetAddressFields(scanner, fieldDetail) ||
this._parseAddressFields(scanner, fieldDetail) ||
this._parseCreditCardExpiryFields(scanner, fieldDetail) ||
this._parseCreditCardNameFields(scanner, fieldDetail)
this._parseCreditCardExpiryFields(scanner, fieldDetail)
) {
continue;
}

Просмотреть файл

@ -11,8 +11,6 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AutofillTelemetry: "resource://autofill/AutofillTelemetry.sys.mjs",
CreditCard: "resource://gre/modules/CreditCard.sys.mjs",
FormAutofillNameUtils:
"resource://gre/modules/shared/FormAutofillNameUtils.sys.mjs",
LabelUtils: "resource://gre/modules/shared/LabelUtils.sys.mjs",
});
@ -371,6 +369,7 @@ export class FormAutofillSection {
// the month is less than 10, since the input is expected a zero-padded string.
// See Bug 1722941 for follow up.
const value = this.getFilledValueFromProfile(fieldDetail, profile);
if (HTMLInputElement.isInstance(element) && value) {
// For the focused input element, it will be filled with a valid value
// anyway.
@ -1179,36 +1178,6 @@ export class FormAutofillCreditCardSection extends FormAutofillSection {
}
}
/**
* Handles credit card name transformation when the name exists in
* the separate cc-given-name, cc-middle-name, and cc-family name fields
*
* @param {object} profile
* @memberof FormAutofillCreditCardSection
*/
creditCardNameTransformer(profile) {
const name = profile["cc-name"];
if (!name) {
return;
}
const given = this.getFieldDetailByName("cc-given-name");
const middle = this.getFieldDetailByName("cc-middle-name");
const family = this.getFieldDetailByName("cc-family-name");
if (given || middle || family) {
const nameParts = lazy.FormAutofillNameUtils.splitName(name);
if (given && nameParts.given) {
profile["cc-given-name"] = nameParts.given;
}
if (middle && nameParts.middle) {
profile["cc-middle-name"] = nameParts.middle;
}
if (family && nameParts.family) {
profile["cc-family-name"] = nameParts.family;
}
}
}
async _decrypt(cipherText, reauth) {
// Get the window for the form field.
let window;
@ -1244,7 +1213,6 @@ export class FormAutofillCreditCardSection extends FormAutofillSection {
// correctly when dealing with option elements.
this.creditCardExpiryDateTransformer(profile);
this.creditCardExpMonthAndYearTransformer(profile);
this.creditCardNameTransformer(profile);
this.matchSelectOptions(profile);
this.adaptFieldMaxLength(profile);
}
@ -1350,6 +1318,7 @@ export class FormAutofillCreditCardSection extends FormAutofillSection {
creditCard.record["cc-number"] = lazy.CreditCard.normalizeCardNumber(
creditCard.record["cc-number"]
);
// Normalize cc-exp-month and cc-exp-year
let { month, year } = lazy.CreditCard.normalizeExpiration({
expirationString: creditCard.record["cc-exp"],