Bug 1571425 - Add a 'Don't ask again' button to the Sync Options notification bar in about:logins. r=sfoster,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D49471

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jared Wein 2019-10-23 20:03:42 +00:00
Родитель 73f16d759b
Коммит e129164357
4 изменённых файлов: 75 добавлений и 27 удалений

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

@ -1805,8 +1805,8 @@ pref("signon.management.page.mobileAndroidURL", "https://app.adjust.com/6tteyjo?
pref("signon.management.page.mobileAppleURL", "https://app.adjust.com/6tteyjo?redirect=https%3A%2F%2Fitunes.apple.com%2Fapp%2Fid1314000270%3Fmt%3D8&utm_campaign=Desktop&utm_adgroup=InProduct&utm_creative=");
pref("signon.management.page.breachAlertUrl",
"https://monitor.firefox.com/breach-details/");
pref("signon.management.page.hideMobileFooter", false);
pref("signon.management.page.showPasswordSyncNotification", true);
// Enable the "Simplify Page" feature in Print Preview. This feature
// is disabled by default in toolkit.

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

@ -42,6 +42,8 @@ const MASTER_PASSWORD_NOTIFICATION_ID = "master-password-login-required";
const PASSWORD_SYNC_NOTIFICATION_ID = "enable-password-sync";
const HIDE_MOBILE_FOOTER_PREF = "signon.management.page.hideMobileFooter";
const SHOW_PASSWORD_SYNC_NOTIFICATION_PREF =
"signon.management.page.showPasswordSyncNotification";
// about:logins will always use the privileged content process,
// even if it is disabled for other consumers such as about:newtab.
@ -598,24 +600,43 @@ var AboutLoginsParent = {
priority: "PRIORITY_WARNING_MEDIUM",
iconURL: "chrome://browser/skin/login.svg",
messageId: "master-password-notification-message",
buttonId: "master-password-reload-button",
onClick(browser) {
browser.reload();
},
buttonIds: ["master-password-reload-button"],
onClicks: [
function onReloadClick(browser) {
browser.reload();
},
],
});
this.messageSubscribers("AboutLogins:MasterPasswordAuthRequired");
},
showPasswordSyncNotifications() {
if (
!Services.prefs.getBoolPref(SHOW_PASSWORD_SYNC_NOTIFICATION_PREF, true)
) {
return;
}
this.showNotifications({
id: PASSWORD_SYNC_NOTIFICATION_ID,
priority: "PRIORITY_INFO_MEDIUM",
iconURL: "chrome://browser/skin/login.svg",
messageId: "enable-password-sync-notification-message",
buttonId: "enable-password-sync-preferences-button",
onClick(browser) {
browser.ownerGlobal.gSync.openPrefs("password-manager");
},
buttonIds: [
"enable-password-sync-preferences-button",
"about-logins-enable-password-sync-dont-ask-again-button",
],
onClicks: [
function onSyncPreferencesClick(browser) {
browser.ownerGlobal.gSync.openPrefs("password-manager");
},
function onDontAskAgainClick(browser) {
Services.prefs.setBoolPref(
SHOW_PASSWORD_SYNC_NOTIFICATION_PREF,
false
);
},
],
extraFtl: ["branding/brand.ftl", "browser/branding/sync-brand.ftl"],
});
},
@ -625,8 +646,8 @@ var AboutLoginsParent = {
priority,
iconURL,
messageId,
buttonId,
onClick,
buttonIds,
onClicks,
extraFtl = [],
} = {}) {
for (let subscriber of this._subscriberIterator()) {
@ -652,15 +673,16 @@ var AboutLoginsParent = {
doc.l10n.setAttributes(message, messageId);
messageFragment.appendChild(message);
let buttons = [
{
"l10n-id": buttonId,
let buttons = [];
for (let i = 0; i < buttonIds.length; i++) {
buttons[i] = {
"l10n-id": buttonIds[i],
popup: null,
callback: () => {
onClick(browser);
onClicks[i](browser);
},
},
];
};
}
notification = notificationBox.appendNotification(
messageFragment,
@ -793,6 +815,7 @@ var AboutLoginsParent = {
},
onPasswordSyncEnabledPreferenceChange(data, previous, latest) {
Services.prefs.clearUserPref(SHOW_PASSWORD_SYNC_NOTIFICATION_PREF);
this.updatePasswordSyncNotificationState(this.getSyncState(), latest);
},
};

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

@ -52,6 +52,11 @@ add_task(async function test_login_syncing_disabled() {
set: [["services.sync.engine.passwords", false]],
});
Services.obs.notifyObservers(null, UIState.ON_UPDATE);
registerCleanupFunction(() => {
Services.prefs.clearUserPref(
"signon.management.page.showPasswordSyncNotification"
);
});
let browser = gBrowser.selectedBrowser;
await ContentTask.spawn(browser, null, async () => {
@ -77,13 +82,26 @@ add_task(async function test_login_syncing_disabled() {
ok(notification, "enable-password-sync notification should be visible");
let buttons = notification.querySelectorAll(".notification-button");
is(buttons.length, 1, "Should have one button.");
is(buttons.length, 2, "Should have two buttons.");
// Clicking the button requires an actual signed in account, not a faked
// Clicking the Sync options button requires an actual signed in account, not a faked
// one as we have done here since a unique URL is generated. Therefore,
// this test skips clicking the button.
// this test skips clicking the Sync options button.
await SpecialPowers.popPrefEnv();
let neverAskAgainButton = buttons[1];
ok(
Services.prefs.getBoolPref(
"signon.management.page.showPasswordSyncNotification"
),
"the pref to show the notification should be set to true"
);
neverAskAgainButton.click();
ok(
!Services.prefs.getBoolPref(
"signon.management.page.showPasswordSyncNotification"
),
"the pref to show the notification should be set to false after clicking the 'never ask' button"
);
await BrowserTestUtils.waitForCondition(
() =>
@ -92,7 +110,9 @@ add_task(async function test_login_syncing_disabled() {
.getNotificationWithValue("enable-password-sync"),
"waiting for enable-password-sync notification to get dismissed"
);
ok(true, "notification is dismissed after the pref is reverted");
ok(true, "notification is dismissed after the 'never ask' button is clicked");
await SpecialPowers.popPrefEnv();
});
add_task(async function test_login_syncing_enabled() {

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

@ -106,11 +106,7 @@ master-password-reload-button =
.label = Log in
.accesskey = L
## Dialogs
confirmation-dialog-cancel-button = Cancel
confirmation-dialog-dismiss-button =
.title = Cancel
## Password Sync notification
enable-password-sync-notification-message =
{ PLATFORM() ->
@ -124,6 +120,15 @@ enable-password-sync-preferences-button =
*[other] Visit { -sync-brand-short-name } Preferences
}
.accesskey = V
about-logins-enable-password-sync-dont-ask-again-button =
.label = Dont ask me again
.accesskey = D
## Dialogs
confirmation-dialog-cancel-button = Cancel
confirmation-dialog-dismiss-button =
.title = Cancel
confirm-delete-dialog-title = Delete this login?
confirm-delete-dialog-message = This action cannot be undone.