mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Backed out changeset abbd6756776d (bug 1873440) for causing bc failures at browser_remoteiframe.js on a CLOSED TREE
This commit is contained in:
parent
84238863a4
commit
744949ca4f
@ -19,8 +19,6 @@ support-files = [
|
||||
|
||||
["browser_address_doorhanger_invalid_fields.js"]
|
||||
|
||||
["browser_address_doorhanger_non_mergeable_fields.js"]
|
||||
|
||||
["browser_address_doorhanger_not_shown.js"]
|
||||
|
||||
["browser_address_doorhanger_state.js"]
|
||||
|
@ -1,92 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
async function expectSavedAddresses(expectedCount) {
|
||||
const addresses = await getAddresses();
|
||||
is(
|
||||
addresses.length,
|
||||
expectedCount,
|
||||
`${addresses.length} address in the storage`
|
||||
);
|
||||
return addresses;
|
||||
}
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.formautofill.addresses.capture.v2.enabled", true],
|
||||
["extensions.formautofill.addresses.supported", "on"],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Submit a form with both mergeable and non-mergeable fields, we should only
|
||||
* update address fields that are mergeable
|
||||
*/
|
||||
add_task(async function test_do_not_update_non_mergeable_fields() {
|
||||
const TEST_ADDRESS = {
|
||||
"address-level1": "New York",
|
||||
"address-level2": "New York City",
|
||||
"street-address": "32 Vassar Street 3F",
|
||||
email: "john.doe@mozilla.com",
|
||||
"postal-code": "12345-1234",
|
||||
organization: "MOZILLA",
|
||||
};
|
||||
await setStorage(TEST_ADDRESS);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: ADDRESS_FORM_URL },
|
||||
async browser => {
|
||||
const onUpdatePopupShown = waitForPopupShown();
|
||||
await focusUpdateSubmitForm(browser, {
|
||||
focusSelector: "#given-name",
|
||||
newValues: {
|
||||
"#given-name": "John",
|
||||
"#family-name": "Doe",
|
||||
"#address-level1": "NY", // NY == New York
|
||||
"#address-level2": "New York", // non-mergeable
|
||||
"#street-address": "32 Vassar Street", // non-mergeable
|
||||
"#email": "", // non-mergeable
|
||||
"#postal-code": "12345", // non-mergeable
|
||||
"#organization": TEST_ADDRESS.organization.toLowerCase(),
|
||||
},
|
||||
});
|
||||
await onUpdatePopupShown;
|
||||
|
||||
await clickAddressDoorhangerButton(MAIN_BUTTON);
|
||||
}
|
||||
);
|
||||
|
||||
const addresses = await expectSavedAddresses(1);
|
||||
|
||||
Assert.equal(addresses[0]["given-name"], "John", `given-name is added`);
|
||||
Assert.equal(addresses[0]["family-name"], "Doe", `family-name is added`);
|
||||
Assert.equal(
|
||||
addresses[0]["street-address"],
|
||||
TEST_ADDRESS["street-address"],
|
||||
`street-address is not updated`
|
||||
);
|
||||
Assert.equal(
|
||||
addresses[0]["address-level1"],
|
||||
TEST_ADDRESS["address-level1"],
|
||||
`address-level1 is not updated`
|
||||
);
|
||||
Assert.equal(
|
||||
addresses[0]["address-level2"],
|
||||
TEST_ADDRESS["address-level2"],
|
||||
`address-level2 is not updated`
|
||||
);
|
||||
Assert.equal(addresses[0].email, TEST_ADDRESS.email, `email is not update`);
|
||||
Assert.equal(
|
||||
addresses[0]["postal-code"],
|
||||
"12345-1234",
|
||||
`postal-code not is update`
|
||||
);
|
||||
Assert.equal(
|
||||
addresses[0].organization,
|
||||
TEST_ADDRESS.organization.toLowerCase(),
|
||||
`organization is update`
|
||||
);
|
||||
|
||||
await removeAllRecords();
|
||||
});
|
@ -524,8 +524,8 @@ export class FormAutofillParent extends JSWindowActorParent {
|
||||
{ ignoreInvalid: true }
|
||||
);
|
||||
|
||||
let newRecord = newAddress.record;
|
||||
let oldRecord = {};
|
||||
let mergeableFields = [];
|
||||
|
||||
// Exams all stored record to determine whether to show the prompt or not.
|
||||
for (const record of await storage.getAll()) {
|
||||
@ -556,33 +556,14 @@ export class FormAutofillParent extends JSWindowActorParent {
|
||||
lazy.log.debug(
|
||||
"A mergeable address record is found, show the update prompt"
|
||||
);
|
||||
const mergeableFields = Object.entries(result)
|
||||
// If we find multiple mergeable records, choose the record with fewest mergeable fields.
|
||||
// TODO: Bug 1830841. Add a testcase
|
||||
let fields = Object.entries(result)
|
||||
.filter(v => ["superset", "similar"].includes(v[1]))
|
||||
.map(v => v[0]);
|
||||
|
||||
// If one record has fewer mergeable fields compared to another, it suggests greater similarity
|
||||
// // to the merged record. In such cases, we opt for the record with the fewest mergeable fields.
|
||||
// TODO: Bug 1830841. Add a testcase
|
||||
if (Object.keys(newRecord).length > mergeableFields.length) {
|
||||
// TODO: This is only temporarily, should be removed after Bug 1836438 is fixed
|
||||
if (mergeableFields.includes("name")) {
|
||||
mergeableFields.push(
|
||||
"given-name",
|
||||
"additional-name",
|
||||
"family-name"
|
||||
);
|
||||
}
|
||||
|
||||
if (!mergeableFields.length || mergeableFields.length > fields.length) {
|
||||
oldRecord = record;
|
||||
|
||||
// New record should only contains fields that can be merged with the old record.
|
||||
newRecord = mergeableFields.reduce(
|
||||
(result, fieldName) => ({
|
||||
...result,
|
||||
[fieldName]: newAddress.record[fieldName],
|
||||
}),
|
||||
{}
|
||||
);
|
||||
mergeableFields = fields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -612,7 +593,7 @@ export class FormAutofillParent extends JSWindowActorParent {
|
||||
browser,
|
||||
storage,
|
||||
address.flowId,
|
||||
{ oldRecord, newRecord }
|
||||
{ oldRecord, newRecord: newAddress.record }
|
||||
);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user