mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Backed out changeset 7b46f9754641 (bug 1587653) for bc failures browser_protections_lockwise.js.
This commit is contained in:
parent
a35dac29ec
commit
5839aca91c
@ -150,7 +150,6 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
*
|
||||
* @return {{
|
||||
* numLogins: Number,
|
||||
* potentiallyBreachedLogins: Number,
|
||||
* mobileDeviceConnected: Boolean }}
|
||||
*/
|
||||
async getLoginData() {
|
||||
@ -170,16 +169,6 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
Services.logins.countLogins("", "", "") -
|
||||
Services.logins.countLogins(FXA_PWDMGR_HOST, null, FXA_PWDMGR_REALM);
|
||||
|
||||
let potentiallyBreachedLogins = null;
|
||||
// Get the stats for number of potentially breached Lockwise passwords
|
||||
// if the Primary Password isn't locked.
|
||||
if (userFacingLogins && Services.logins.isLoggedIn) {
|
||||
const logins = await LoginHelper.getAllUserFacingLogins();
|
||||
potentiallyBreachedLogins = await LoginBreaches.getPotentialBreachesByLoginGUID(
|
||||
logins
|
||||
);
|
||||
}
|
||||
|
||||
let mobileDeviceConnected =
|
||||
fxAccounts.device.recentDeviceList &&
|
||||
fxAccounts.device.recentDeviceList.filter(
|
||||
@ -188,9 +177,6 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
|
||||
return {
|
||||
numLogins: userFacingLogins,
|
||||
potentiallyBreachedLogins: potentiallyBreachedLogins
|
||||
? potentiallyBreachedLogins.size
|
||||
: 0,
|
||||
mobileDeviceConnected,
|
||||
};
|
||||
}
|
||||
@ -202,6 +188,7 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
* numBreaches: Number,
|
||||
* passwords: Number,
|
||||
* userEmail: String|null,
|
||||
* potentiallyBreachedLogins: Number,
|
||||
* error: Boolean }}
|
||||
* Monitor data.
|
||||
*/
|
||||
@ -215,6 +202,7 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
}
|
||||
|
||||
let monitorData = {};
|
||||
let potentiallyBreachedLogins = null;
|
||||
let userEmail = null;
|
||||
let token = await this.getMonitorScopedOAuthToken();
|
||||
|
||||
@ -222,6 +210,14 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
if (token) {
|
||||
monitorData = await this.fetchUserBreachStats(token);
|
||||
|
||||
// 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 LoginBreaches.getPotentialBreachesByLoginGUID(
|
||||
logins
|
||||
);
|
||||
}
|
||||
// Send back user's email so the protections report can direct them to the proper
|
||||
// OAuth flow on Monitor.
|
||||
const { email } = await fxAccounts.getSignedInUser();
|
||||
@ -261,6 +257,9 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
return {
|
||||
...monitorData,
|
||||
userEmail,
|
||||
potentiallyBreachedLogins: potentiallyBreachedLogins
|
||||
? potentiallyBreachedLogins.size
|
||||
: 0,
|
||||
error: !!monitorData.errorMessage,
|
||||
};
|
||||
}
|
||||
@ -370,7 +369,9 @@ class AboutProtectionsParent extends JSWindowActorParent {
|
||||
return this.getMonitorData();
|
||||
|
||||
case "FetchUserLoginsData":
|
||||
return this.getLoginData();
|
||||
let { potentiallyBreachedLogins } = await this.getMonitorData();
|
||||
let loginsData = await this.getLoginData();
|
||||
return { ...loginsData, potentiallyBreachedLogins };
|
||||
|
||||
case "ClearMonitorCache":
|
||||
monitorResponse = null;
|
||||
|
@ -9,6 +9,11 @@ const { AboutProtectionsParent } = ChromeUtils.import(
|
||||
);
|
||||
const ABOUT_LOGINS_URL = "about:logins";
|
||||
|
||||
let mockMonitorData = {
|
||||
numBreaches: 2,
|
||||
numBreachesResolved: 0,
|
||||
};
|
||||
|
||||
add_task(async function testNoLoginsLockwiseCardUI() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
url: "about:protections",
|
||||
@ -226,9 +231,8 @@ add_task(async function testLockwiseCardUIWithBreachedLogins() {
|
||||
Services.logins.addLogin(TEST_LOGIN1);
|
||||
|
||||
info("Mock monitor data with a breached login to test the Lockwise UI");
|
||||
AboutProtectionsParent.setTestOverride(
|
||||
mockGetLoginDataWithSyncedDevices(false, 1)
|
||||
);
|
||||
mockMonitorData.potentiallyBreachedLogins = 1;
|
||||
AboutProtectionsParent.setTestOverride(mockGetMonitorData(mockMonitorData));
|
||||
await reloadTab(tab);
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
|
||||
@ -250,9 +254,8 @@ add_task(async function testLockwiseCardUIWithBreachedLogins() {
|
||||
info(
|
||||
"Mock monitor data with more than one breached logins to test the Lockwise UI"
|
||||
);
|
||||
AboutProtectionsParent.setTestOverride(
|
||||
mockGetLoginDataWithSyncedDevices(false, 2)
|
||||
);
|
||||
mockMonitorData.potentiallyBreachedLogins = 2;
|
||||
AboutProtectionsParent.setTestOverride(mockGetMonitorData(mockMonitorData));
|
||||
await reloadTab(tab);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
|
||||
const lockwiseScannedText = content.document.querySelector(
|
||||
|
@ -13,6 +13,7 @@ const monitorErrorData = {
|
||||
};
|
||||
|
||||
const mockMonitorData = {
|
||||
potentiallyBreachedLogins: 8,
|
||||
numBreaches: 11,
|
||||
numBreachesResolved: 0,
|
||||
};
|
||||
|
@ -217,7 +217,11 @@ add_task(async function checkTelemetryClickEvents() {
|
||||
|
||||
// Add breached logins.
|
||||
AboutProtectionsParent.setTestOverride(
|
||||
mockGetLoginDataWithSyncedDevices(false, 4)
|
||||
mockGetMonitorData({
|
||||
potentiallyBreachedLogins: 4,
|
||||
numBreaches: 5,
|
||||
numBreachesResolved: 0,
|
||||
})
|
||||
);
|
||||
await reloadTab(tab);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
|
||||
|
@ -39,15 +39,11 @@ async function reloadTab(tab) {
|
||||
}
|
||||
|
||||
// Used to replace AboutProtectionsHandler.getLoginData in front-end tests.
|
||||
const mockGetLoginDataWithSyncedDevices = (
|
||||
mobileDeviceConnected = false,
|
||||
potentiallyBreachedLogins = 0
|
||||
) => {
|
||||
const mockGetLoginDataWithSyncedDevices = (mobileDeviceConnected = false) => {
|
||||
return {
|
||||
getLoginData: () => {
|
||||
return {
|
||||
numLogins: Services.logins.countLogins("", "", ""),
|
||||
potentiallyBreachedLogins,
|
||||
mobileDeviceConnected,
|
||||
};
|
||||
},
|
||||
@ -66,6 +62,7 @@ const mockGetMonitorData = data => {
|
||||
monitoredEmails: 1,
|
||||
numBreaches: data.numBreaches,
|
||||
passwords: 8,
|
||||
potentiallyBreachedLogins: data.potentiallyBreachedLogins,
|
||||
numBreachesResolved: data.numBreachesResolved,
|
||||
passwordsResolved: 1,
|
||||
error: false,
|
||||
|
Loading…
Reference in New Issue
Block a user