Backed out 2 changesets (bug 1595656) for xpcshell failures on test_load_all_api_modules.js . CLOSED TREE

Backed out changeset 061c92c4b95c (bug 1595656)
Backed out changeset ef8d5090979a (bug 1595656)
This commit is contained in:
Narcis Beleuzu 2019-11-21 03:22:06 +02:00
Родитель 4305bf1a25
Коммит 2738d493c6
3 изменённых файлов: 53 добавлений и 25 удалений

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

@ -6,19 +6,35 @@
"use strict"; "use strict";
var { XPCOMUtils } = ChromeUtils.import( var { PlacesUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm" "resource://gre/modules/PlacesUtils.jsm"
); );
XPCOMUtils.defineLazyModuleGetters(this, { ChromeUtils.defineModuleGetter(
LoginHelper: "resource://gre/modules/LoginHelper.jsm", this,
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm", "Preferences",
Preferences: "resource://gre/modules/Preferences.jsm", "resource://gre/modules/Preferences.jsm"
Sanitizer: "resource:///modules/Sanitizer.jsm", );
Services: "resource://gre/modules/Services.jsm", ChromeUtils.defineModuleGetter(
setTimeout: "resource://gre/modules/Timer.jsm", this,
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm", "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.defineLazyServiceGetter( XPCOMUtils.defineLazyServiceGetter(
this, this,
@ -215,17 +231,24 @@ const clearLocalStorage = async function(options) {
}; };
const clearPasswords = async function(options) { const clearPasswords = async function(options) {
let loginManager = Services.logins;
let yieldCounter = 0; let yieldCounter = 0;
// Iterate through the logins and delete any updated after our cutoff. if (options.since) {
for (let login of await LoginHelper.getAllUserFacingLogins()) { // Iterate through the logins and delete any updated after our cutoff.
login.QueryInterface(Ci.nsILoginMetaInfo); let logins = loginManager.getAllLogins();
if (!options.since || login.timePasswordChanged >= options.since) { for (let login of logins) {
Services.logins.removeLogin(login); login.QueryInterface(Ci.nsILoginMetaInfo);
if (++yieldCounter % YIELD_PERIOD == 0) { if (login.timePasswordChanged >= options.since) {
await new Promise(resolve => setTimeout(resolve, 0)); // Don't block the main thread too long. loginManager.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();
} }
}; };

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

@ -12,9 +12,10 @@ XPCOMUtils.defineLazyServiceGetter(
const REFERENCE_DATE = Date.now(); const REFERENCE_DATE = Date.now();
const LOGIN_USERNAME = "username"; const LOGIN_USERNAME = "username";
const LOGIN_PASSWORD = "password"; const LOGIN_PASSWORD = "password";
const LOGIN_USERNAME_FIELD = "username_field";
const LOGIN_PASSWORD_FIELD = "password_field";
const OLD_HOST = "http://mozilla.org"; const OLD_HOST = "http://mozilla.org";
const NEW_HOST = "http://mozilla.com"; const NEW_HOST = "http://mozilla.com";
const FXA_HOST = "chrome://FirefoxAccounts";
function checkLoginExists(host, shouldExist) { function checkLoginExists(host, shouldExist) {
let logins = loginManager.findLogins(host, "", null); let logins = loginManager.findLogins(host, "", null);
@ -30,7 +31,15 @@ function addLogin(host, timestamp) {
let login = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance( let login = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(
Ci.nsILoginInfo Ci.nsILoginInfo
); );
login.init(host, "", null, LOGIN_USERNAME, LOGIN_PASSWORD); login.init(
host,
"",
null,
LOGIN_USERNAME,
LOGIN_PASSWORD,
LOGIN_USERNAME_FIELD,
LOGIN_PASSWORD_FIELD
);
login.QueryInterface(Ci.nsILoginMetaInfo); login.QueryInterface(Ci.nsILoginMetaInfo);
login.timePasswordChanged = timestamp; login.timePasswordChanged = timestamp;
loginManager.addLogin(login); loginManager.addLogin(login);
@ -39,7 +48,6 @@ function addLogin(host, timestamp) {
async function setupPasswords() { async function setupPasswords() {
loginManager.removeAllLogins(); loginManager.removeAllLogins();
addLogin(FXA_HOST, REFERENCE_DATE);
addLogin(NEW_HOST, REFERENCE_DATE); addLogin(NEW_HOST, REFERENCE_DATE);
addLogin(OLD_HOST, REFERENCE_DATE - 10000); addLogin(OLD_HOST, REFERENCE_DATE - 10000);
} }
@ -71,7 +79,6 @@ add_task(async function testPasswords() {
checkLoginExists(OLD_HOST, false); checkLoginExists(OLD_HOST, false);
checkLoginExists(NEW_HOST, false); checkLoginExists(NEW_HOST, false);
checkLoginExists(FXA_HOST, true);
// Clear passwords with recent since value. // Clear passwords with recent since value.
await setupPasswords(); await setupPasswords();
@ -80,7 +87,6 @@ add_task(async function testPasswords() {
checkLoginExists(OLD_HOST, true); checkLoginExists(OLD_HOST, true);
checkLoginExists(NEW_HOST, false); checkLoginExists(NEW_HOST, false);
checkLoginExists(FXA_HOST, true);
// Clear passwords with old since value. // Clear passwords with old since value.
await setupPasswords(); await setupPasswords();
@ -89,7 +95,6 @@ add_task(async function testPasswords() {
checkLoginExists(OLD_HOST, false); checkLoginExists(OLD_HOST, false);
checkLoginExists(NEW_HOST, false); checkLoginExists(NEW_HOST, false);
checkLoginExists(FXA_HOST, true);
} }
await extension.startup(); await extension.startup();

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

@ -1105,7 +1105,7 @@ this.LoginHelper = {
}, },
isUserFacingLogin(login) { isUserFacingLogin(login) {
return login.origin != "chrome://FirefoxAccounts"; // FXA_PWDMGR_HOST return !login.origin.startsWith("chrome://");
}, },
async getAllUserFacingLogins() { async getAllUserFacingLogins() {