Bug 1395123 - Unhide credit cards sync engine by default. r=lchang,markh

MozReview-Commit-ID: 4WzzW327PTe

--HG--
extra : rebase_source : 6313ebe75131aba4de7a168c20ee3841a173f402
This commit is contained in:
steveck-chung 2017-09-11 11:55:05 +08:00
Родитель 20ad958852
Коммит 009db8012b
2 изменённых файлов: 15 добавлений и 39 удалений

14
browser/extensions/formautofill/bootstrap.js поставляемый
Просмотреть файл

@ -18,6 +18,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonManagerPrivate",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillParent",
"resource://formautofill/FormAutofillParent.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillUtils",
"resource://formautofill/FormAutofillUtils.jsm");
function insertStyleSheet(domWindow, url) {
let doc = domWindow.document;
@ -68,6 +70,7 @@ function startup(data) {
// reset the sync related prefs incase the feature was previously available
// but isn't now.
Services.prefs.clearUserPref("services.sync.engine.addresses.available");
Services.prefs.clearUserPref("services.sync.engine.creditcards.available");
Services.telemetry.scalarSet("formautofill.availability", false);
return;
}
@ -92,10 +95,15 @@ function startup(data) {
Services.prefs.setBoolPref("dom.forms.autocomplete.formautofill", true);
Services.telemetry.scalarSet("formautofill.availability", true);
// This pref determines whether the "addresses" sync engine is available
// (ie, whether it is shown in any UI etc) - it *does not* determine whether
// the engine is actually enabled or not.
// This pref determines whether the "addresses"/"creditcards" sync engine is
// available (ie, whether it is shown in any UI etc) - it *does not* determine
// whether the engine is actually enabled or not.
Services.prefs.setBoolPref("services.sync.engine.addresses.available", true);
if (FormAutofillUtils.isAutofillCreditCardsAvailable) {
Services.prefs.setBoolPref("services.sync.engine.creditcards.available", true);
} else {
Services.prefs.clearUserPref("services.sync.engine.creditcards.available");
}
// Listen for the autocomplete popup message to lazily append our stylesheet related to the popup.
Services.mm.addMessageListener("FormAutoComplete:MaybeOpenPopup", onMaybeOpenPopup);

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

@ -20,6 +20,10 @@ add_task(async function test_submit_creditCard_cancel_saving() {
form.querySelector("input[type=submit]").click();
});
ok(!SpecialPowers.Services.prefs.prefHasUserValue(SYNC_USERNAME_PREF),
"Sync account should not exist by default");
let cb = getDoorhangerCheckbox();
ok(cb.hidden, "Sync checkbox should be hidden");
await promiseShown;
await clickDoorhangerButton(SECONDARY_BUTTON);
}
@ -163,42 +167,6 @@ add_task(async function test_submit_creditCard_saved_with_mp_enabled_but_cancele
LoginTestUtils.masterPassword.disable();
});
add_task(async function test_submit_creditCard_unavailable_with_sync_account() {
await SpecialPowers.pushPrefEnv({
"set": [
[SYNC_USERNAME_PREF, "foo@bar.com"],
],
});
await BrowserTestUtils.withNewTab({gBrowser, url: CREDITCARD_FORM_URL},
async function(browser) {
let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel,
"popupshown");
is(SpecialPowers.getBoolPref(SYNC_CREDITCARDS_AVAILABLE_PREF), false,
"creditCards sync should be unavailable by default");
await ContentTask.spawn(browser, null, async function() {
let form = content.document.getElementById("form");
let name = form.querySelector("#cc-name");
name.focus();
name.setUserInput("User 2");
let number = form.querySelector("#cc-number");
number.setUserInput("1234123412341234");
// Wait 500ms before submission to make sure the input value applied
await new Promise(resolve => setTimeout(resolve, 500));
form.querySelector("input[type=submit]").click();
});
await promiseShown;
let cb = getDoorhangerCheckbox();
ok(cb.hidden, "Sync checkbox should be hidden");
await clickDoorhangerButton(SECONDARY_BUTTON);
}
);
});
add_task(async function test_submit_creditCard_with_sync_account() {
await SpecialPowers.pushPrefEnv({
"set": [