зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1595656 - Only clear user-facing passwords with the browsingData API. r=rpl
FxA/Sync stores a credential in login storage but this is no longer user-facing so users shouldn't expect it to be cleared. Users can still diconnect Sync properly from about:preferences. Differential Revision: https://phabricator.services.mozilla.com/D53834 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ebd3c33af6
Коммит
c5f5b70fa5
|
@ -6,10 +6,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { PlacesUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/PlacesUtils.jsm"
|
||||
var { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
});
|
||||
|
||||
var { ExtensionError } = ExtensionUtils;
|
||||
|
||||
const { TYPE_BOOKMARK, TYPE_FOLDER, TYPE_SEPARATOR } = PlacesUtils.bookmarks;
|
||||
|
|
|
@ -6,35 +6,19 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { PlacesUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/PlacesUtils.jsm"
|
||||
var { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Preferences",
|
||||
"resource://gre/modules/Preferences.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Sanitizer",
|
||||
"resource:///modules/Sanitizer.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Services",
|
||||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"setTimeout",
|
||||
"resource://gre/modules/Timer.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"ServiceWorkerCleanUp",
|
||||
"resource://gre/modules/ServiceWorkerCleanUp.jsm"
|
||||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
LoginHelper: "resource://gre/modules/LoginHelper.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
Preferences: "resource://gre/modules/Preferences.jsm",
|
||||
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
|
@ -231,24 +215,17 @@ const clearLocalStorage = async function(options) {
|
|||
};
|
||||
|
||||
const clearPasswords = async function(options) {
|
||||
let loginManager = Services.logins;
|
||||
let yieldCounter = 0;
|
||||
|
||||
if (options.since) {
|
||||
// Iterate through the logins and delete any updated after our cutoff.
|
||||
let logins = loginManager.getAllLogins();
|
||||
for (let login of logins) {
|
||||
login.QueryInterface(Ci.nsILoginMetaInfo);
|
||||
if (login.timePasswordChanged >= options.since) {
|
||||
loginManager.removeLogin(login);
|
||||
if (++yieldCounter % YIELD_PERIOD == 0) {
|
||||
await new Promise(resolve => setTimeout(resolve, 0)); // Don't block the main thread too long.
|
||||
}
|
||||
// Iterate through the logins and delete any updated after our cutoff.
|
||||
for (let login of await LoginHelper.getAllUserFacingLogins()) {
|
||||
login.QueryInterface(Ci.nsILoginMetaInfo);
|
||||
if (!options.since || login.timePasswordChanged >= options.since) {
|
||||
Services.logins.removeLogin(login);
|
||||
if (++yieldCounter % YIELD_PERIOD == 0) {
|
||||
await new Promise(resolve => setTimeout(resolve, 0)); // Don't block the main thread too long.
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove everything.
|
||||
loginManager.removeAllLogins();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6,15 +6,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { PlacesUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/PlacesUtils.jsm"
|
||||
var { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Services",
|
||||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
var { normalizeTime } = ExtensionCommon;
|
||||
|
||||
|
|
|
@ -12,10 +12,9 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
const REFERENCE_DATE = Date.now();
|
||||
const LOGIN_USERNAME = "username";
|
||||
const LOGIN_PASSWORD = "password";
|
||||
const LOGIN_USERNAME_FIELD = "username_field";
|
||||
const LOGIN_PASSWORD_FIELD = "password_field";
|
||||
const OLD_HOST = "http://mozilla.org";
|
||||
const NEW_HOST = "http://mozilla.com";
|
||||
const FXA_HOST = "chrome://FirefoxAccounts";
|
||||
|
||||
function checkLoginExists(host, shouldExist) {
|
||||
let logins = loginManager.findLogins(host, "", null);
|
||||
|
@ -31,15 +30,7 @@ function addLogin(host, timestamp) {
|
|||
let login = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(
|
||||
Ci.nsILoginInfo
|
||||
);
|
||||
login.init(
|
||||
host,
|
||||
"",
|
||||
null,
|
||||
LOGIN_USERNAME,
|
||||
LOGIN_PASSWORD,
|
||||
LOGIN_USERNAME_FIELD,
|
||||
LOGIN_PASSWORD_FIELD
|
||||
);
|
||||
login.init(host, "", null, LOGIN_USERNAME, LOGIN_PASSWORD);
|
||||
login.QueryInterface(Ci.nsILoginMetaInfo);
|
||||
login.timePasswordChanged = timestamp;
|
||||
loginManager.addLogin(login);
|
||||
|
@ -48,6 +39,7 @@ function addLogin(host, timestamp) {
|
|||
|
||||
async function setupPasswords() {
|
||||
loginManager.removeAllLogins();
|
||||
addLogin(FXA_HOST, REFERENCE_DATE);
|
||||
addLogin(NEW_HOST, REFERENCE_DATE);
|
||||
addLogin(OLD_HOST, REFERENCE_DATE - 10000);
|
||||
}
|
||||
|
@ -79,6 +71,7 @@ add_task(async function testPasswords() {
|
|||
|
||||
checkLoginExists(OLD_HOST, false);
|
||||
checkLoginExists(NEW_HOST, false);
|
||||
checkLoginExists(FXA_HOST, true);
|
||||
|
||||
// Clear passwords with recent since value.
|
||||
await setupPasswords();
|
||||
|
@ -87,6 +80,7 @@ add_task(async function testPasswords() {
|
|||
|
||||
checkLoginExists(OLD_HOST, true);
|
||||
checkLoginExists(NEW_HOST, false);
|
||||
checkLoginExists(FXA_HOST, true);
|
||||
|
||||
// Clear passwords with old since value.
|
||||
await setupPasswords();
|
||||
|
@ -95,6 +89,7 @@ add_task(async function testPasswords() {
|
|||
|
||||
checkLoginExists(OLD_HOST, false);
|
||||
checkLoginExists(NEW_HOST, false);
|
||||
checkLoginExists(FXA_HOST, true);
|
||||
}
|
||||
|
||||
await extension.startup();
|
||||
|
|
Загрузка…
Ссылка в новой задаче