Bug 1808303 - Remove the pref to determine whether a user has ever used credit card autofill r=sgalich

Differential Revision: https://phabricator.services.mozilla.com/D165860
This commit is contained in:
Dimi 2023-01-04 19:43:57 +00:00
Родитель 5486db87d0
Коммит afce6650ee
9 изменённых файлов: 5 добавлений и 197 удалений

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

@ -17,10 +17,6 @@ add_task(async function setup_storage() {
// Verify that form fillin works in a remote iframe, and that changing
// a field updates storage.
add_task(async function test_iframe_autocomplete() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
IFRAME_URL_PATH,
@ -105,10 +101,6 @@ add_task(async function test_iframe_autocomplete() {
// Choose preferences from the autocomplete dropdown within an iframe.
add_task(async function test_iframe_autocomplete_preferences() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
IFRAME_URL_PATH,

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

@ -5,9 +5,6 @@
that the UI won't be ready and we will get an invalid test result.
*/
add_task(async function test_submit_creditCard_cancel_saving() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function(browser) {
@ -34,19 +31,9 @@ add_task(async function test_submit_creditCard_cancel_saving() {
await sleep(1000);
let creditCards = await getCreditCards();
is(creditCards.length, 0, "No credit card saved");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
});
add_task(async function test_submit_creditCard_saved() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
let onChanged = waitForStorageChangedEvents("add");
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
@ -74,12 +61,6 @@ add_task(async function test_submit_creditCard_saved() {
is(creditCards.length, 1, "1 credit card in storage");
is(creditCards[0]["cc-name"], "User 1", "Verify the name field");
is(creditCards[0]["cc-type"], "mastercard", "Verify the cc-type field");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -92,9 +73,6 @@ add_task(async function test_submit_untouched_creditCard_form() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -126,12 +104,6 @@ add_task(async function test_submit_untouched_creditCard_form() {
creditCards = await getCreditCards();
is(creditCards.length, 1, "Still 1 credit card");
is(creditCards[0].timesUsed, 1, "timesUsed field set to 1");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
3,
"User has used autofill"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -144,9 +116,6 @@ add_task(async function test_submit_untouched_creditCard_form_iframe() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -197,19 +166,10 @@ add_task(async function test_submit_untouched_creditCard_form_iframe() {
EXPECTED_ON_USED_COUNT,
"timesUsed field set to 2"
);
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
3,
"User has used autofill"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
add_task(async function test_iframe_unload_save_card() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
let onChanged = waitForStorageChangedEvents("add");
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_IFRAME_URL },
@ -247,19 +207,10 @@ add_task(async function test_iframe_unload_save_card() {
is(creditCards.length, 1, "1 credit card in storage");
is(creditCards[0]["cc-name"], "User 1", "Verify the name field");
is(creditCards[0]["cc-type"], "visa", "Verify the cc-type field");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
add_task(async function test_submit_changed_subset_creditCard_form() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -288,19 +239,10 @@ add_task(async function test_submit_changed_subset_creditCard_form() {
creditCards = await getCreditCards();
is(creditCards.length, 1, "Still 1 credit card in storage");
is(creditCards[0]["cc-name"], "Mark Smith", "name field got updated");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
add_task(async function test_submit_duplicate_creditCard_form() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -334,12 +276,6 @@ add_task(async function test_submit_duplicate_creditCard_form() {
"Verify the name field"
);
is(creditCards[0].timesUsed, 1, "timesUsed field set to 1");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
1,
"User neither sees the doorhanger nor uses autofill but somehow has a record in the storage"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -381,9 +317,6 @@ add_task(async function test_submit_unnormailzed_creditCard_form() {
});
add_task(async function test_submit_creditCard_never_save() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function(browser) {
@ -408,12 +341,6 @@ add_task(async function test_submit_creditCard_never_save() {
);
is(creditCards.length, 0, "No credit card in storage");
is(creditCardPref, false, "Credit card is disabled");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
});
@ -534,9 +461,6 @@ add_task(async function test_submit_creditCard_with_synced_already() {
});
add_task(async function test_submit_manual_mergeable_creditCard_form() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_3);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -565,12 +489,6 @@ add_task(async function test_submit_manual_mergeable_creditCard_form() {
creditCards = await getCreditCards();
is(creditCards.length, 1, "Still 1 credit card in storage");
is(creditCards[0]["cc-name"], "User 3", "Verify the name field");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -583,9 +501,6 @@ add_task(async function test_update_autofill_form_name() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -626,12 +541,6 @@ add_task(async function test_update_autofill_form_name() {
"************1111",
"Verify the card number field"
);
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
3,
"User has used autofill"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -644,9 +553,6 @@ add_task(async function test_update_autofill_form_exp_date() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -685,12 +591,6 @@ add_task(async function test_update_autofill_form_exp_date() {
"************1111",
"Verify the card number field"
);
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
3,
"User has used autofill"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -703,9 +603,6 @@ add_task(async function test_create_new_autofill_form() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -744,12 +641,6 @@ add_task(async function test_create_new_autofill_form() {
"Original record's cc-name field is unchanged"
);
is(creditCards[1]["cc-name"], "User 1", "cc-name field in the new record");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
3,
"User has used autofill"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -762,9 +653,6 @@ add_task(async function test_update_duplicate_autofill_form() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await setStorage(
{ "cc-number": "6387060366272981" },
{ "cc-number": "5038146897157463" }
@ -800,12 +688,6 @@ add_task(async function test_update_duplicate_autofill_form() {
creditCards = await getCreditCards();
is(creditCards.length, 2, "Still 2 credit card");
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
1,
"User neither sees the doorhanger nor uses autofill but somehow has a record in the storage"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});
@ -841,7 +723,6 @@ add_task(async function test_submit_creditCard_with_invalid_network() {
"Invalid network/cc-type was not saved"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
});

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

@ -4,9 +4,6 @@
"use strict";
add_task(async function test_autodetect_credit_not_set() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
const testCard = {
"cc-name": "John Doe",
"cc-number": "4012888888881881",
@ -56,9 +53,6 @@ add_task(async function test_autodetect_credit_not_set() {
});
add_task(async function test_autodetect_credit_overwrite() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
const testCard = {
"cc-name": "John Doe",
"cc-number": "4012888888881881",

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

@ -6,9 +6,6 @@
// We want to ensure that non-normalized credit card data is normalized
// correctly as part of the save credit card flow
add_task(async function test_new_submitted_card_is_normalized() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
const testCard = {
"cc-name": "Test User",
"cc-number": "5038146897157463",
@ -60,9 +57,6 @@ add_task(async function test_new_submitted_card_is_normalized() {
});
add_task(async function test_updated_card_is_normalized() {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
const testCard = {
"cc-name": "Test User",
"cc-number": "5038146897157463",

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

@ -337,10 +337,7 @@ add_task(async function test_submit_creditCard_new() {
expectChanged = undefined
) {
await SpecialPowers.pushPrefEnv({
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
set: [[ENABLED_AUTOFILL_CREDITCARDS_PREF, true]],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
@ -445,10 +442,7 @@ add_task(async function test_submit_creditCard_autofill() {
Services.telemetry.getHistogramById(CC_NUM_USES_HISTOGRAM).clear();
await SpecialPowers.pushPrefEnv({
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
set: [[ENABLED_AUTOFILL_CREDITCARDS_PREF, true]],
});
await setStorage(TEST_CREDIT_CARD_1);
@ -461,7 +455,6 @@ add_task(async function test_submit_creditCard_autofill() {
1: 1,
});
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
await assertTelemetry(
@ -508,10 +501,7 @@ add_task(async function test_submit_creditCard_update() {
expectChanged = undefined
) {
await SpecialPowers.pushPrefEnv({
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
set: [[ENABLED_AUTOFILL_CREDITCARDS_PREF, true]],
});
await setStorage(TEST_CREDIT_CARD_1);
@ -556,7 +546,6 @@ add_task(async function test_submit_creditCard_update() {
assertHistogram("CREDITCARD_NUM_USES", useCount);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
await removeAllRecords();
@ -791,10 +780,7 @@ add_task(async function test_clear_creditCard_autofill() {
Services.telemetry.getHistogramById(CC_NUM_USES_HISTOGRAM).clear();
await SpecialPowers.pushPrefEnv({
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
set: [[ENABLED_AUTOFILL_CREDITCARDS_PREF, true]],
});
await setStorage(TEST_CREDIT_CARD_1);

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

@ -51,7 +51,6 @@ const CREDITCARD_FORM_WITHOUT_AUTOCOMPLETE_URL =
const EMPTY_URL = "https://example.org" + HTTP_TEST_PATH + "empty.html";
const FTU_PREF = "extensions.formautofill.firstTimeUse";
const CREDITCARDS_USED_STATUS_PREF = "extensions.formautofill.creditCards.used";
const ENABLED_AUTOFILL_ADDRESSES_PREF =
"extensions.formautofill.addresses.enabled";
const ENABLED_AUTOFILL_ADDRESSES_CAPTURE_PREF =

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

@ -4164,14 +4164,6 @@ pref("extensions.formautofill.creditCards.heuristics.fathom.highConfidenceThresh
// This is Only for testing! Set the confidence value (> 0 && <= 1) after a field is identified by fathom
pref("extensions.formautofill.creditCards.heuristics.fathom.testConfidence", "0");
// Pref for shield/heartbeat to recognize users who have used Credit Card
// Autofill. The valid values can be:
// 0: none
// 1: submitted a manually-filled credit card form (but didn't see the doorhanger
// because of a duplicate profile in the storage)
// 2: saw the doorhanger
// 3: submitted an autofill'ed credit card form
pref("extensions.formautofill.creditCards.used", 0);
pref("extensions.formautofill.firstTimeUse", true);
pref("extensions.formautofill.heuristics.enabled", true);
pref("extensions.formautofill.section.enabled", true);

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

@ -23,7 +23,6 @@ const AUTOFILL_ADDRESSES_AVAILABLE_PREF =
const AUTOFILL_CREDITCARDS_AVAILABLE_PREF =
"extensions.formautofill.creditCards.supported";
const BROWSER_SEARCH_REGION_PREF = "browser.search.region";
const CREDITCARDS_USED_STATUS_PREF = "extensions.formautofill.creditCards.used";
const CREDITCARDS_AUTOFILL_SUPPORTED_COUNTRIES_PREF =
"extensions.formautofill.creditCards.supportedCountries";
const ENABLED_AUTOFILL_ADDRESSES_PREF =
@ -74,7 +73,6 @@ var FormAutofill = {
ENABLED_AUTOFILL_CREDITCARDS_PREF,
ENABLED_AUTOFILL_CREDITCARDS_REAUTH_PREF,
ADDRESSES_FIRST_TIME_USE_PREF,
CREDITCARDS_USED_STATUS_PREF,
AUTOFILL_CREDITCARDS_AUTOCOMPLETE_OFF_PREF,
AUTOFILL_ADDRESSES_AUTOCOMPLETE_OFF_PREF,
@ -226,11 +224,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
"isAutofillAddressesFirstTimeUse",
ADDRESSES_FIRST_TIME_USE_PREF
);
XPCOMUtils.defineLazyPreferenceGetter(
FormAutofill,
"AutofillCreditCardsUsedStatus",
CREDITCARDS_USED_STATUS_PREF
);
XPCOMUtils.defineLazyPreferenceGetter(
FormAutofill,
"_addressAutofillSupportedCountries",

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

@ -608,28 +608,12 @@ class FormAutofillParent extends JSWindowActorParent {
}
async _onCreditCardSubmit(creditCard, browser, timeStartedFillingMS) {
// Updates the used status for shield/heartbeat to recognize users who have
// used Credit Card Autofill.
let setUsedStatus = status => {
if (FormAutofill.AutofillCreditCardsUsedStatus < status) {
Services.prefs.setIntPref(
FormAutofill.CREDITCARDS_USED_STATUS_PREF,
status
);
}
};
// Remove cc-type values
// Let's reset the credit card to empty, and then network auto-detect will
// Let's delete type from the credit card, and then network auto-detect will
// pick it up.
//creditCard.record["cc-type"] = "";
delete creditCard.record["cc-type"];
// If `guid` is present, the form has been autofilled.
if (creditCard.guid) {
// Indicate that the user has used Credit Card Autofill to fill in a form.
setUsedStatus(3);
let originalCCData = await lazy.gFormAutofillStorage.creditCards.get(
creditCard.guid
);
@ -694,19 +678,12 @@ class FormAutofillParent extends JSWindowActorParent {
}
if (recordUnchanged) {
// Indicate that the user neither sees the doorhanger nor uses Autofill
// but somehow has a duplicate record in the storage. Will be reset to 2
// if the doorhanger actually shows below.
setUsedStatus(1);
lazy.gFormAutofillStorage.creditCards.notifyUsed(creditCard.guid);
return false;
}
}
}
// Indicate that the user has seen the doorhanger.
setUsedStatus(2);
return async () => {
// Suppress the pending doorhanger from showing up if user disabled credit card in previous doorhanger.
if (!FormAutofill.isAutofillCreditCardsEnabled) {