зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1658027 - Separate visual interactions on Credit Card Autofill for A/B testing. r=abr
Differential Revision: https://phabricator.services.mozilla.com/D86445
This commit is contained in:
Родитель
b144e9c01e
Коммит
59fb3f227d
|
@ -1849,6 +1849,9 @@ pref("extensions.formautofill.creditCards.available", true);
|
|||
pref("extensions.formautofill.addresses.enabled", true);
|
||||
pref("extensions.formautofill.addresses.capture.enabled", false);
|
||||
pref("extensions.formautofill.creditCards.enabled", true);
|
||||
// Temporary preference to control displaying the UI elements for
|
||||
// credit card autofill used for the duration of the A/B test.
|
||||
pref("extensions.formautofill.creditCards.hideui", false);
|
||||
// Enable the checkbox in sync options for credit card data sync service
|
||||
pref("services.sync.engine.creditcards.available", true);
|
||||
// Pref for shield/heartbeat to recognize users who have used Credit Card
|
||||
|
|
|
@ -27,6 +27,8 @@ const ENABLED_AUTOFILL_CREDITCARDS_PREF =
|
|||
"extensions.formautofill.creditCards.enabled";
|
||||
const ENABLED_AUTOFILL_CREDITCARDS_REAUTH_PREF =
|
||||
"extensions.formautofill.reauth.enabled";
|
||||
const AUTOFILL_CREDITCARDS_HIDE_UI_PREF =
|
||||
"extensions.formautofill.creditCards.hideui";
|
||||
const SUPPORTED_COUNTRIES_PREF = "extensions.formautofill.supportedCountries";
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
|
@ -113,6 +115,11 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
"_isAutofillCreditCardsEnabled",
|
||||
ENABLED_AUTOFILL_CREDITCARDS_PREF
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
FormAutofill,
|
||||
"isAutofillCreditCardsHideUI",
|
||||
AUTOFILL_CREDITCARDS_HIDE_UI_PREF
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
FormAutofill,
|
||||
"isAutofillAddressesFirstTimeUse",
|
||||
|
|
|
@ -183,9 +183,13 @@ AutofillProfileAutoCompleteSearch.prototype = {
|
|||
let isInputAutofilled = activeFieldDetail.state == FIELD_STATES.AUTO_FILLED;
|
||||
let allFieldNames = activeSection.allFieldNames;
|
||||
let filledRecordGUID = activeSection.filledRecordGUID;
|
||||
|
||||
let creditCardsEnabledAndVisible =
|
||||
FormAutofill.isAutofillCreditCardsEnabled &&
|
||||
!FormAutofill.isAutofillCreditCardsHideUI;
|
||||
let searchPermitted = isAddressField
|
||||
? FormAutofill.isAutofillAddressesEnabled
|
||||
: FormAutofill.isAutofillCreditCardsEnabled;
|
||||
: creditCardsEnabledAndVisible;
|
||||
let AutocompleteResult = isAddressField ? AddressResult : CreditCardResult;
|
||||
let isFormAutofillSearch = true;
|
||||
let pendingSearchResult = null;
|
||||
|
|
|
@ -581,6 +581,10 @@ class FormAutofillParent extends JSWindowActorParent {
|
|||
}
|
||||
|
||||
async _onCreditCardSubmit(creditCard, browser, timeStartedFillingMS) {
|
||||
if (FormAutofill.isAutofillCreditCardsHideUI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Updates the used status for shield/heartbeat to recognize users who have
|
||||
// used Credit Card Autofill.
|
||||
let setUsedStatus = status => {
|
||||
|
|
|
@ -176,7 +176,10 @@ FormAutofillPreferences.prototype = {
|
|||
savedAddressesBtn,
|
||||
};
|
||||
|
||||
if (FormAutofill.isAutofillCreditCardsAvailable) {
|
||||
if (
|
||||
FormAutofill.isAutofillCreditCardsAvailable &&
|
||||
!FormAutofill.isAutofillCreditCardsHideUI
|
||||
) {
|
||||
let creditCardAutofill = document.createXULElement("hbox");
|
||||
let creditCardAutofillCheckboxGroup = document.createXULElement("hbox");
|
||||
let creditCardAutofillCheckbox = document.createXULElement("checkbox");
|
||||
|
|
|
@ -591,3 +591,92 @@ add_task(async function test_histogram() {
|
|||
|
||||
assertHistogram(CC_NUM_USES_HISTOGRAM, {});
|
||||
});
|
||||
|
||||
add_task(async function test_submit_creditCard_new_with_hidden_ui() {
|
||||
const AUTOFILL_CREDITCARDS_HIDE_UI_PREF =
|
||||
"extensions.formautofill.creditCards.hideui";
|
||||
|
||||
Services.telemetry.clearEvents();
|
||||
Services.telemetry.clearScalars();
|
||||
Services.telemetry.getHistogramById(CC_NUM_USES_HISTOGRAM).clear();
|
||||
Services.telemetry.setEventRecordingEnabled("creditcard", true);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[CREDITCARDS_USED_STATUS_PREF, 0],
|
||||
[AUTOFILL_CREDITCARDS_HIDE_UI_PREF, true],
|
||||
],
|
||||
});
|
||||
|
||||
await saveCreditCard(TEST_CREDIT_CARD_1);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: CREDITCARD_FORM_URL },
|
||||
async function(browser) {
|
||||
await openPopupOn(browser, "form #cc-number").then(
|
||||
() => {
|
||||
return Promise.reject("Popup should not be displayed");
|
||||
},
|
||||
() => {
|
||||
ok(true, "Popup has not been displayed");
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], async function() {
|
||||
let form = content.document.getElementById("form");
|
||||
let name = form.querySelector("#cc-name");
|
||||
|
||||
name.focus();
|
||||
name.setUserInput("User 1");
|
||||
|
||||
form.querySelector("#cc-number").setUserInput("5038146897157463");
|
||||
form.querySelector("#cc-exp-month").setUserInput("12");
|
||||
form.querySelector("#cc-exp-year").setUserInput("2017");
|
||||
form.querySelector("#cc-type").value = "mastercard";
|
||||
|
||||
// Wait 1000ms before submission to make sure the input value applied
|
||||
await new Promise(resolve => content.setTimeout(resolve, 1000));
|
||||
form.querySelector("input[type=submit]").click();
|
||||
});
|
||||
|
||||
await sleep(1000);
|
||||
is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden");
|
||||
}
|
||||
);
|
||||
|
||||
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
|
||||
SpecialPowers.clearUserPref(ENABLED_AUTOFILL_CREDITCARDS_PREF);
|
||||
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_HIDE_UI_PREF);
|
||||
|
||||
assertHistogram(CC_NUM_USES_HISTOGRAM, { 0: 1 });
|
||||
|
||||
let expected_content = [
|
||||
["creditcard", "detected", "cc_form"],
|
||||
[
|
||||
"creditcard",
|
||||
"submitted",
|
||||
"cc_form",
|
||||
undefined,
|
||||
{
|
||||
fields_not_auto: "3",
|
||||
fields_auto: "5",
|
||||
fields_modified: "5",
|
||||
},
|
||||
],
|
||||
];
|
||||
await assertTelemetry(expected_content, []);
|
||||
await removeAllRecords();
|
||||
|
||||
TelemetryTestUtils.assertScalar(
|
||||
TelemetryTestUtils.getProcessScalars("content"),
|
||||
"formautofill.creditCards.detected_sections_count",
|
||||
1,
|
||||
"There should be 1 sections detected."
|
||||
);
|
||||
TelemetryTestUtils.assertScalar(
|
||||
TelemetryTestUtils.getProcessScalars("content"),
|
||||
"formautofill.creditCards.submitted_sections_count",
|
||||
1,
|
||||
"There should be 1 section submitted."
|
||||
);
|
||||
});
|
||||
|
|
|
@ -214,6 +214,37 @@ add_task(async function test_creditCardNotAvailable() {
|
|||
);
|
||||
});
|
||||
|
||||
add_task(async function test_creditCardHiddenUI() {
|
||||
const AUTOFILL_CREDITCARDS_HIDE_UI_PREF =
|
||||
"extensions.formautofill.creditCards.hideui";
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[AUTOFILL_CREDITCARDS_HIDE_UI_PREF, true]],
|
||||
});
|
||||
let finalPrefPaneLoaded = TestUtils.topicObserved(
|
||||
"sync-pane-loaded",
|
||||
() => true
|
||||
);
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: PAGE_PRIVACY },
|
||||
async function(browser) {
|
||||
await finalPrefPaneLoaded;
|
||||
await SpecialPowers.spawn(browser, [SELECTORS], selectors => {
|
||||
is(
|
||||
content.document.querySelector(selectors.group).hidden,
|
||||
false,
|
||||
"Form Autofill group should be visible"
|
||||
);
|
||||
ok(
|
||||
!content.document.querySelector(selectors.creditCardAutofillCheckbox),
|
||||
"Autofill credit cards checkbox should not exist"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
SpecialPowers.clearUserPref(AUTOFILL_CREDITCARDS_HIDE_UI_PREF);
|
||||
});
|
||||
|
||||
add_task(async function test_reauth() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, true]],
|
||||
|
|
Загрузка…
Ссылка в новой задаче