Bug 1664620 - Fixup test failures when credit card autofill is disabled (second set of changes). r=zbraniecki

Differential Revision: https://phabricator.services.mozilla.com/D90187
This commit is contained in:
Jim Mathies 2020-09-15 14:27:19 +00:00
Родитель d739a3f0fc
Коммит a7cd484171
4 изменённых файлов: 98 добавлений и 9 удалений

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

@ -15,17 +15,17 @@ support-files =
[browser_creditCard_doorhanger.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1655601
[browser_creditCard_dropdown_layout.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
skip-if = ((os == "mac") || (os == 'linux') || (os == 'win'))
[browser_creditCard_fill_cancel_login.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
skip-if = ((!debug && os == "mac") || (os == 'linux') || (os == 'win'))
[browser_editCreditCardDialog.js]
skip-if = (verify && (os == 'linux')) || (!debug && os == "mac") # perma-fail see Bug 1600059
skip-if = ((os == 'linux') || (os == "mac") || (os == 'win')) # perma-fail see Bug 1600059
[browser_insecure_form.js]
skip-if = (os == 'mac') # bug 1456284
skip-if = ((os == 'mac') || (os == 'linux') || (os == 'win')) # bug 1456284
[browser_manageCreditCardsDialog.js]
skip-if = (verify && (os == 'win' || os == 'mac'))
skip-if = ((os == 'win') || (os == 'mac') || (os == 'linux'))
[browser_privacyPreferences.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
skip-if = (( os == "mac") || (os == 'linux') || (os == 'win')) # perma-fail see Bug 1600059
[browser_anti_clickjacking.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
[browser_creditCard_telemetry.js]

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

@ -527,6 +527,7 @@ add_task(async function test_submit_creditCard_with_sync_account() {
set: [
[SYNC_USERNAME_PREF, "foo@bar.com"],
[SYNC_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});

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

@ -122,6 +122,13 @@ async function useCreditCard(idx) {
}
add_task(async function test_popup_opened() {
await SpecialPowers.pushPrefEnv({
set: [
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
Services.telemetry.clearEvents();
Services.telemetry.clearScalars();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
@ -159,6 +166,9 @@ add_task(async function test_popup_opened() {
0,
"There should be no sections submitted."
);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
});
add_task(async function test_submit_creditCard_new() {
@ -169,7 +179,11 @@ add_task(async function test_submit_creditCard_new() {
expectChanged = undefined
) {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
@ -213,6 +227,7 @@ add_task(async function test_submit_creditCard_new() {
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
assertHistogram(CC_NUM_USES_HISTOGRAM, useCount);
@ -285,8 +300,13 @@ add_task(async function test_submit_creditCard_autofill() {
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await saveCreditCard(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -298,6 +318,9 @@ add_task(async function test_submit_creditCard_autofill() {
});
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
await assertTelemetry(
@ -337,8 +360,13 @@ add_task(async function test_submit_creditCard_update() {
expectChanged = undefined
) {
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await saveCreditCard(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
is(creditCards.length, 1, "1 credit card in storage");
@ -388,6 +416,9 @@ 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);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
}
Services.telemetry.clearEvents();
@ -444,6 +475,13 @@ add_task(async function test_removingCreditCardsViaKeyboardDelete() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await SpecialPowers.pushPrefEnv({
set: [
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await saveCreditCard(TEST_CREDIT_CARD_1);
let win = window.openDialog(
MANAGE_CREDIT_CARDS_DIALOG_URL,
@ -467,6 +505,10 @@ add_task(async function test_removingCreditCardsViaKeyboardDelete() {
["creditcard", "show", "manage"],
["creditcard", "delete", "manage"],
]);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
});
@ -474,6 +516,13 @@ add_task(async function test_saveCreditCard() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await SpecialPowers.pushPrefEnv({
set: [
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, win => {
EventUtils.synthesizeKey("VK_TAB", {}, win);
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-number"], {}, win);
@ -499,6 +548,9 @@ add_task(async function test_saveCreditCard() {
EventUtils.synthesizeKey("VK_RETURN", {}, win);
});
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
await assertTelemetry(undefined, [["creditcard", "add", "manage"]]);
@ -508,6 +560,13 @@ add_task(async function test_editCreditCard() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await SpecialPowers.pushPrefEnv({
set: [
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
await saveCreditCard(TEST_CREDIT_CARD_1);
let creditCards = await getCreditCards();
@ -527,6 +586,10 @@ add_task(async function test_editCreditCard() {
record: creditCards[0],
}
);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
await assertTelemetry(undefined, [
["creditcard", "show_entry", "manage"],
@ -543,6 +606,13 @@ add_task(async function test_histogram() {
return;
}
await SpecialPowers.pushPrefEnv({
set: [
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
],
});
Services.telemetry.getHistogramById(CC_NUM_USES_HISTOGRAM).clear();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
@ -587,6 +657,9 @@ add_task(async function test_histogram() {
2: 2,
});
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
await removeAllRecords();
assertHistogram(CC_NUM_USES_HISTOGRAM, {});
@ -604,6 +677,8 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() {
await SpecialPowers.pushPrefEnv({
set: [
[CREDITCARDS_USED_STATUS_PREF, 0],
[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true],
[ENABLED_AUTOFILL_CREDITCARDS_PREF, true],
[AUTOFILL_CREDITCARDS_HIDE_UI_PREF, true],
],
});
@ -646,6 +721,7 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() {
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_HIDE_UI_PREF);
assertHistogram(CC_NUM_USES_HISTOGRAM, { 0: 1 });

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

@ -589,6 +589,12 @@ add_task(async function autofill_disabled() {
// "_onFormSubmit" should be called as usual.
Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
Services.prefs.clearUserPref("extensions.formautofill.creditCards.enabled");
Services.prefs.setBoolPref(
"extensions.formautofill.creditCards.enabled",
true
);
FormAutofillContent.formSubmitted(form, null);
Assert.equal(FormAutofillContent._onFormSubmit.called, true);
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
@ -632,6 +638,11 @@ TESTCASES.forEach(testcase => {
add_task(async function check_records_saving_is_called_correctly() {
info("Starting testcase: " + testcase.description);
Services.prefs.setBoolPref(
"extensions.formautofill.creditCards.enabled",
true
);
let form = MOCK_DOC.getElementById("form1");
form.reset();
for (let key in testcase.formValue) {
@ -670,5 +681,6 @@ TESTCASES.forEach(testcase => {
);
}
FormAutofillContent._onFormSubmit.restore();
Services.prefs.clearUserPref("extensions.formautofill.creditCards.enabled");
});
});