Bug 1568226 - Hide Lockwise data in Monitor card if a master password is set. r=ewright

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Micah Tigley 2019-07-25 16:05:01 +00:00
Родитель f7dd1ffde1
Коммит 17c2f506fd
5 изменённых файлов: 62 добавлений и 18 удалений

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

@ -182,7 +182,7 @@ var AboutProtectionsHandler = {
*/
async getMonitorData() {
let monitorData = {};
let potentiallyBreachedLogins = 0;
let potentiallyBreachedLogins = null;
const hasFxa = await fxAccounts.accountStatus();
if (hasFxa) {
@ -214,11 +214,14 @@ var AboutProtectionsHandler = {
}
}
// Get the stats for number of potentially breached Lockwise passwords
const logins = await LoginHelper.getAllUserFacingLogins();
potentiallyBreachedLogins = await LoginHelper.getBreachesForLogins(
logins
);
// Get the stats for number of potentially breached Lockwise passwords if no master
// password is set.
if (!LoginHelper.isMasterPasswordSet()) {
const logins = await LoginHelper.getAllUserFacingLogins();
potentiallyBreachedLogins = await LoginHelper.getBreachesForLogins(
logins
);
}
} else {
// If no account exists, then the user is not logged in with an fxAccount.
monitorData = {
@ -228,7 +231,9 @@ var AboutProtectionsHandler = {
return {
...monitorData,
potentiallyBreachedLogins: potentiallyBreachedLogins.size,
potentiallyBreachedLogins: potentiallyBreachedLogins
? potentiallyBreachedLogins.size
: 0,
error: !!monitorData.errorMessage,
};
},

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

@ -77,14 +77,24 @@ export default class MonitorClass {
const exposedPasswords = this.doc.querySelector(
"span[data-type='exposed-passwords']"
);
const exposedLockwisePasswords = this.doc.querySelector(
"span[data-type='breached-lockwise-passwords']"
);
storedEmail.textContent = monitorData.monitoredEmails;
knownBreaches.textContent = monitorData.numBreaches;
exposedPasswords.textContent = monitorData.passwords;
exposedLockwisePasswords.textContent =
monitorData.potentiallyBreachedLogins;
// Display Lockwise section if there are any potential breached logins to report.
if (monitorData.potentiallyBreachedLogins > 0) {
const lockwiseSection = this.doc.querySelector(
".monitor-breached-passwords"
);
const exposedLockwisePasswords = this.doc.querySelector(
"span[data-type='breached-lockwise-passwords']"
);
exposedLockwisePasswords.textContent =
monitorData.potentiallyBreachedLogins;
lockwiseSection.classList.remove("hidden");
}
}
}

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

@ -77,7 +77,8 @@ a.hidden,
.monitor-card.no-logins .card-body,
.monitor-card.no-logins #monitor-header-content a,
.monitor-card.no-logins .inline-text-icon.monitor-scanned-text,
.monitor-card.has-logins #sign-up-for-monitor-button {
.monitor-card.has-logins #sign-up-for-monitor-button,
#monitor-body-content .monitor-breached-passwords.hidden {
display: none;
}

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

@ -137,7 +137,7 @@
<span>View full report on</span>
<a href="">Firefox Monitor</a>
</div>
<div class="monitor-breached-passwords">
<div class="monitor-breached-passwords hidden">
<span data-type="breached-lockwise-passwords" class="number-of-breaches block">
<!-- Display number of exposed stored passwords here. -->
</span>

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

@ -7,7 +7,6 @@
const { AboutProtectionsHandler } = ChromeUtils.import(
"resource:///modules/aboutpages/AboutProtectionsHandler.jsm"
);
const nsLoginInfo = new Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo,
@ -40,8 +39,8 @@ let fakeDataWithError = {
error: true,
};
// Modify AboutProtectionsHandler's getMonitorData method to fake returning a specified
// number of devices.
// Modify AboutProtectionsHandler's getMonitorData method to fake returning data from the
// Monitor endpoint.
const mockGetMonitorData = data => async () => data;
// Modify AboutProtectionsHandler's getLoginData method to fake being logged in with Fxa.
@ -122,6 +121,35 @@ add_task(async function() {
);
});
info("Make sure Lockwise section is hidden if no passwords are returned.");
const noBreachedLoginsData = {
...fakeDataWithNoError,
potentiallyBreachedLogins: 0,
};
AboutProtectionsHandler.getMonitorData = mockGetMonitorData(
noBreachedLoginsData
);
await reloadTab(tab);
await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
await ContentTaskUtils.waitForCondition(() => {
const noLogins = content.document.querySelector(
".monitor-card.has-logins"
);
return ContentTaskUtils.is_visible(noLogins);
}, "Monitor card for user with stored logins is shown.");
const lockwiseSection = content.document.querySelector(
".monitor-breached-passwords"
);
ok(
ContentTaskUtils.is_hidden(lockwiseSection),
"Lockwise section is hidden."
);
});
info(
"Check that correct content is displayed when monitor data contains an error message."
);
@ -146,7 +174,7 @@ add_task(async function() {
}, "Monitor card is not enabled.");
const monitorCard = content.document.querySelector(".monitor-card");
ok(ContentTaskUtils.is_hidden(monitorCard), "Lockwise card is hidden.");
ok(ContentTaskUtils.is_hidden(monitorCard), "Monitor card is hidden.");
});
// set the pref back to displaying the card.