зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1399382 - Add a pref to hide credit card autofill feature, r=lchang
MozReview-Commit-ID: 2GIOrLBmFKR --HG-- extra : rebase_source : e4341ca3956f8b040c2dce37557b7f5a9cd52921
This commit is contained in:
Родитель
f3bff41d59
Коммит
5e500229a1
|
@ -1700,6 +1700,11 @@ pref("extensions.formautofill.available", "staged-rollout");
|
|||
pref("extensions.formautofill.available", "detect");
|
||||
#endif
|
||||
pref("extensions.formautofill.addresses.enabled", true);
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("extensions.formautofill.creditCards.available", true);
|
||||
#else
|
||||
pref("extensions.formautofill.creditCards.available", false);
|
||||
#endif
|
||||
pref("extensions.formautofill.creditCards.enabled", true);
|
||||
pref("extensions.formautofill.firstTimeUse", true);
|
||||
pref("extensions.formautofill.heuristics.enabled", true);
|
||||
|
|
|
@ -88,17 +88,21 @@ FormAutofillParent.prototype = {
|
|||
Services.ppmm.addMessageListener("FormAutofill:InitStorage", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:GetRecords", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:SaveAddress", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:SaveCreditCard", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:RemoveAddresses", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:RemoveCreditCards", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:OpenPreferences", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:GetDecryptedString", this);
|
||||
Services.mm.addMessageListener("FormAutofill:OnFormSubmit", this);
|
||||
|
||||
// Observing the pref and storage changes
|
||||
Services.prefs.addObserver(ENABLED_AUTOFILL_ADDRESSES_PREF, this);
|
||||
Services.prefs.addObserver(ENABLED_AUTOFILL_CREDITCARDS_PREF, this);
|
||||
Services.obs.addObserver(this, "formautofill-storage-changed");
|
||||
|
||||
// Only listen to credit card related messages if it is available
|
||||
if (FormAutofillUtils.isAutofillCreditCardsAvailable) {
|
||||
Services.ppmm.addMessageListener("FormAutofill:SaveCreditCard", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:RemoveCreditCards", this);
|
||||
Services.ppmm.addMessageListener("FormAutofill:GetDecryptedString", this);
|
||||
Services.prefs.addObserver(ENABLED_AUTOFILL_CREDITCARDS_PREF, this);
|
||||
}
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
|
@ -248,12 +252,16 @@ FormAutofillParent.prototype = {
|
|||
Services.ppmm.removeMessageListener("FormAutofill:InitStorage", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:GetRecords", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:SaveAddress", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:SaveCreditCard", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:RemoveAddresses", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:RemoveCreditCards", this);
|
||||
Services.obs.removeObserver(this, "sync-pane-loaded");
|
||||
Services.prefs.removeObserver(ENABLED_AUTOFILL_ADDRESSES_PREF, this);
|
||||
Services.prefs.removeObserver(ENABLED_AUTOFILL_CREDITCARDS_PREF, this);
|
||||
|
||||
if (FormAutofillUtils.isAutofillCreditCardsAvailable) {
|
||||
Services.ppmm.removeMessageListener("FormAutofill:SaveCreditCard", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:RemoveCreditCards", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:GetDecryptedString", this);
|
||||
Services.prefs.removeObserver(ENABLED_AUTOFILL_CREDITCARDS_PREF, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,69 +61,79 @@ FormAutofillPreferences.prototype = {
|
|||
* @param {XULDocument} document
|
||||
*/
|
||||
createPreferenceGroup(document) {
|
||||
let learnMoreURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "autofill-card-address";
|
||||
let formAutofillGroup = document.createElementNS(XUL_NS, "vbox");
|
||||
let addressAutofill = document.createElementNS(XUL_NS, "hbox");
|
||||
let addressAutofillCheckboxGroup = document.createElementNS(XUL_NS, "description");
|
||||
let addressAutofillCheckbox = document.createElementNS(XUL_NS, "checkbox");
|
||||
let addressAutofillLearnMore = document.createElementNS(XUL_NS, "label");
|
||||
let savedAddressesBtn = document.createElementNS(XUL_NS, "button");
|
||||
let creditCardAutofill = document.createElementNS(XUL_NS, "hbox");
|
||||
let creditCardAutofillCheckboxGroup = document.createElementNS(XUL_NS, "description");
|
||||
let creditCardAutofillCheckbox = document.createElementNS(XUL_NS, "checkbox");
|
||||
let creditCardAutofillLearnMore = document.createElementNS(XUL_NS, "label");
|
||||
let savedCreditCardsBtn = document.createElementNS(XUL_NS, "button");
|
||||
|
||||
savedAddressesBtn.className = "accessory-button";
|
||||
savedCreditCardsBtn.className = "accessory-button";
|
||||
addressAutofillLearnMore.className = "learnMore text-link";
|
||||
creditCardAutofillLearnMore.className = "learnMore text-link";
|
||||
|
||||
this.refs = {
|
||||
formAutofillGroup,
|
||||
addressAutofillCheckbox,
|
||||
savedAddressesBtn,
|
||||
creditCardAutofillCheckbox,
|
||||
savedCreditCardsBtn,
|
||||
};
|
||||
|
||||
formAutofillGroup.id = "formAutofillGroup";
|
||||
addressAutofill.id = "addressAutofill";
|
||||
addressAutofillLearnMore.id = "addressAutofillLearnMore";
|
||||
creditCardAutofill.id = "creditCardAutofill";
|
||||
creditCardAutofillLearnMore.id = "creditCardAutofillLearnMore";
|
||||
|
||||
addressAutofillLearnMore.setAttribute("value", this.bundle.GetStringFromName("learnMore"));
|
||||
addressAutofillCheckbox.setAttribute("label", this.bundle.GetStringFromName("enableAddressAutofill"));
|
||||
savedAddressesBtn.setAttribute("label", this.bundle.GetStringFromName("savedAddresses"));
|
||||
creditCardAutofillLearnMore.setAttribute("value", this.bundle.GetStringFromName("learnMore"));
|
||||
creditCardAutofillCheckbox.setAttribute("label", this.bundle.GetStringFromName("enableCreditCardAutofill"));
|
||||
savedCreditCardsBtn.setAttribute("label", this.bundle.GetStringFromName("savedCreditCards"));
|
||||
|
||||
let learnMoreURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "autofill-card-address";
|
||||
addressAutofillLearnMore.setAttribute("href", learnMoreURL);
|
||||
creditCardAutofillLearnMore.setAttribute("href", learnMoreURL);
|
||||
|
||||
// Manually set the checked state
|
||||
if (FormAutofillUtils.isAutofillAddressesEnabled) {
|
||||
addressAutofillCheckbox.setAttribute("checked", true);
|
||||
}
|
||||
if (FormAutofillUtils.isAutofillCreditCardsEnabled) {
|
||||
creditCardAutofillCheckbox.setAttribute("checked", true);
|
||||
}
|
||||
|
||||
addressAutofillCheckboxGroup.flex = 1;
|
||||
creditCardAutofillCheckboxGroup.flex = 1;
|
||||
|
||||
formAutofillGroup.appendChild(addressAutofill);
|
||||
addressAutofill.appendChild(addressAutofillCheckboxGroup);
|
||||
addressAutofillCheckboxGroup.appendChild(addressAutofillCheckbox);
|
||||
addressAutofillCheckboxGroup.appendChild(addressAutofillLearnMore);
|
||||
addressAutofill.appendChild(savedAddressesBtn);
|
||||
formAutofillGroup.appendChild(creditCardAutofill);
|
||||
creditCardAutofill.appendChild(creditCardAutofillCheckboxGroup);
|
||||
creditCardAutofillCheckboxGroup.appendChild(creditCardAutofillCheckbox);
|
||||
creditCardAutofillCheckboxGroup.appendChild(creditCardAutofillLearnMore);
|
||||
creditCardAutofill.appendChild(savedCreditCardsBtn);
|
||||
|
||||
this.refs = {
|
||||
formAutofillGroup,
|
||||
addressAutofillCheckbox,
|
||||
savedAddressesBtn,
|
||||
};
|
||||
|
||||
if (FormAutofillUtils.isAutofillCreditCardsAvailable) {
|
||||
let creditCardAutofill = document.createElementNS(XUL_NS, "hbox");
|
||||
let creditCardAutofillCheckboxGroup = document.createElementNS(XUL_NS, "description");
|
||||
let creditCardAutofillCheckbox = document.createElementNS(XUL_NS, "checkbox");
|
||||
let creditCardAutofillLearnMore = document.createElementNS(XUL_NS, "label");
|
||||
let savedCreditCardsBtn = document.createElementNS(XUL_NS, "button");
|
||||
savedCreditCardsBtn.className = "accessory-button";
|
||||
creditCardAutofillLearnMore.className = "learnMore text-link";
|
||||
|
||||
creditCardAutofill.id = "creditCardAutofill";
|
||||
creditCardAutofillLearnMore.id = "creditCardAutofillLearnMore";
|
||||
|
||||
creditCardAutofillLearnMore.setAttribute("value", this.bundle.GetStringFromName("learnMore"));
|
||||
creditCardAutofillCheckbox.setAttribute("label", this.bundle.GetStringFromName("enableCreditCardAutofill"));
|
||||
savedCreditCardsBtn.setAttribute("label", this.bundle.GetStringFromName("savedCreditCards"));
|
||||
|
||||
creditCardAutofillLearnMore.setAttribute("href", learnMoreURL);
|
||||
|
||||
// Manually set the checked state
|
||||
if (FormAutofillUtils.isAutofillCreditCardsEnabled) {
|
||||
creditCardAutofillCheckbox.setAttribute("checked", true);
|
||||
}
|
||||
|
||||
creditCardAutofillCheckboxGroup.flex = 1;
|
||||
|
||||
formAutofillGroup.appendChild(creditCardAutofill);
|
||||
creditCardAutofill.appendChild(creditCardAutofillCheckboxGroup);
|
||||
creditCardAutofillCheckboxGroup.appendChild(creditCardAutofillCheckbox);
|
||||
creditCardAutofillCheckboxGroup.appendChild(creditCardAutofillLearnMore);
|
||||
creditCardAutofill.appendChild(savedCreditCardsBtn);
|
||||
|
||||
this.refs.creditCardAutofillCheckbox = creditCardAutofillCheckbox;
|
||||
this.refs.savedCreditCardsBtn = savedCreditCardsBtn;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ const ALTERNATIVE_COUNTRY_NAMES = {
|
|||
const ADDRESSES_COLLECTION_NAME = "addresses";
|
||||
const CREDITCARDS_COLLECTION_NAME = "creditCards";
|
||||
const ENABLED_AUTOFILL_ADDRESSES_PREF = "extensions.formautofill.addresses.enabled";
|
||||
const AUTOFILL_CREDITCARDS_AVAILABLE_PREF = "extensions.formautofill.creditCards.available";
|
||||
const ENABLED_AUTOFILL_CREDITCARDS_PREF = "extensions.formautofill.creditCards.enabled";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
@ -27,6 +28,7 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
this.FormAutofillUtils = {
|
||||
get AUTOFILL_FIELDS_THRESHOLD() { return 3; },
|
||||
get isAutofillEnabled() { return this.isAutofillAddressesEnabled || this.isAutofillCreditCardsEnabled; },
|
||||
get isAutofillCreditCardsEnabled() { return this.isAutofillCreditCardsAvailable && this._isAutofillCreditCardsEnabled; },
|
||||
|
||||
ADDRESSES_COLLECTION_NAME,
|
||||
CREDITCARDS_COLLECTION_NAME,
|
||||
|
@ -526,4 +528,6 @@ XPCOMUtils.defineLazyGetter(FormAutofillUtils, "stringBundle", function() {
|
|||
XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
||||
"isAutofillAddressesEnabled", ENABLED_AUTOFILL_ADDRESSES_PREF);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
||||
"isAutofillCreditCardsEnabled", ENABLED_AUTOFILL_CREDITCARDS_PREF);
|
||||
"isAutofillCreditCardsAvailable", AUTOFILL_CREDITCARDS_AVAILABLE_PREF);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
||||
"_isAutofillCreditCardsEnabled", ENABLED_AUTOFILL_CREDITCARDS_PREF);
|
||||
|
|
|
@ -83,3 +83,17 @@ add_task(async function test_autofillDisabledCheckbox() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_creditCardNotAvailable() {
|
||||
SpecialPowers.pushPrefEnv({set: [[AUTOFILL_CREDITCARDS_AVAILABLE_PREF, false]]});
|
||||
let finalPrefPaneLoaded = TestUtils.topicObserved("sync-pane-loaded", () => true);
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: PAGE_PRIVACY}, async function(browser) {
|
||||
await finalPrefPaneLoaded;
|
||||
await ContentTask.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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* exported MANAGE_ADDRESSES_DIALOG_URL, MANAGE_CREDIT_CARDS_DIALOG_URL, EDIT_ADDRESS_DIALOG_URL, EDIT_CREDIT_CARD_DIALOG_URL,
|
||||
BASE_URL, TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3, TEST_ADDRESS_4, TEST_ADDRESS_5,
|
||||
TEST_CREDIT_CARD_1, TEST_CREDIT_CARD_2, TEST_CREDIT_CARD_3, FORM_URL, CREDITCARD_FORM_URL,
|
||||
FTU_PREF, ENABLED_AUTOFILL_ADDRESSES_PREF, ENABLED_AUTOFILL_CREDITCARDS_PREF, SYNC_USERNAME_PREF, SYNC_ADDRESSES_PREF,
|
||||
FTU_PREF, ENABLED_AUTOFILL_ADDRESSES_PREF, AUTOFILL_CREDITCARDS_AVAILABLE_PREF, ENABLED_AUTOFILL_CREDITCARDS_PREF,
|
||||
SYNC_USERNAME_PREF, SYNC_ADDRESSES_PREF,
|
||||
sleep, expectPopupOpen, openPopupOn, expectPopupClose, closePopup, clickDoorhangerButton,
|
||||
getAddresses, saveAddress, removeAddresses, saveCreditCard,
|
||||
getDisplayedPopupItems, getDoorhangerCheckbox, waitForMasterPasswordDialog */
|
||||
|
@ -18,6 +19,7 @@ const CREDITCARD_FORM_URL =
|
|||
"http://mochi.test:8888/browser/browser/extensions/formautofill/test/browser/autocomplete_creditcard_basic.html";
|
||||
const FTU_PREF = "extensions.formautofill.firstTimeUse";
|
||||
const ENABLED_AUTOFILL_ADDRESSES_PREF = "extensions.formautofill.addresses.enabled";
|
||||
const AUTOFILL_CREDITCARDS_AVAILABLE_PREF = "extensions.formautofill.creditCards.available";
|
||||
const ENABLED_AUTOFILL_CREDITCARDS_PREF = "extensions.formautofill.creditCards.enabled";
|
||||
const SYNC_USERNAME_PREF = "services.sync.username";
|
||||
const SYNC_ADDRESSES_PREF = "services.sync.engine.addresses";
|
||||
|
|
Загрузка…
Ссылка в новой задаче