зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1550131) for browser-chrome failures at browser/components/aboutlogins/tests/browser/browser_masterPassword.js
Backed out changeset 95918413069f (bug 1550131) Backed out changeset 8e7d6a1c30fa (bug 1550131) Backed out changeset 97eabc062946 (bug 1550131) Backed out changeset 32ff6a0b8436 (bug 1550131) Backed out changeset b562886d574d (bug 1550131) --HG-- extra : rebase_source : 542ffadbb47cbd1bfc90e7053af59c1e5ee385d7
This commit is contained in:
Родитель
98daf2fb95
Коммит
c86f7ac7c3
|
@ -9,8 +9,6 @@ var EXPORTED_SYMBOLS = ["AboutLoginsParent"];
|
|||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Localization",
|
||||
"resource://gre/modules/Localization.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "LoginHelper",
|
||||
"resource://gre/modules/LoginHelper.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Services",
|
||||
|
@ -21,7 +19,6 @@ XPCOMUtils.defineLazyGetter(this, "log", () => {
|
|||
});
|
||||
|
||||
const ABOUT_LOGINS_ORIGIN = "about:logins";
|
||||
const MASTER_PASSWORD_NOTIFICATION_ID = "master-password-login-required";
|
||||
|
||||
const PRIVILEGED_PROCESS_PREF =
|
||||
"browser.tabs.remote.separatePrivilegedContentProcess";
|
||||
|
@ -48,7 +45,6 @@ const convertSubjectToLogin = subject => {
|
|||
};
|
||||
|
||||
var AboutLoginsParent = {
|
||||
_l10n: null,
|
||||
_subscribers: new WeakSet(),
|
||||
|
||||
// Listeners are added in BrowserGlue.jsm
|
||||
|
@ -78,8 +74,6 @@ var AboutLoginsParent = {
|
|||
}
|
||||
case "AboutLogins:Subscribe": {
|
||||
if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) {
|
||||
Services.obs.addObserver(this, "passwordmgr-crypto-login");
|
||||
Services.obs.addObserver(this, "passwordmgr-crypto-loginCanceled");
|
||||
Services.obs.addObserver(this, "passwordmgr-storage-changed");
|
||||
}
|
||||
this._subscribers.add(message.target);
|
||||
|
@ -112,23 +106,10 @@ var AboutLoginsParent = {
|
|||
|
||||
observe(subject, topic, type) {
|
||||
if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) {
|
||||
Services.obs.removeObserver(this, "passwordmgr-crypto-login");
|
||||
Services.obs.removeObserver(this, "passwordmgr-crypto-loginCanceled");
|
||||
Services.obs.removeObserver(this, "passwordmgr-storage-changed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (topic == "passwordmgr-crypto-login") {
|
||||
this.removeMasterPasswordLoginNotifications();
|
||||
this.messageSubscribers("AboutLogins:AllLogins", this.getAllLogins());
|
||||
return;
|
||||
}
|
||||
|
||||
if (topic == "passwordmgr-crypto-loginCanceled") {
|
||||
this.showMasterPasswordLoginNotifications();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "addLogin": {
|
||||
const login = convertSubjectToLogin(subject);
|
||||
|
@ -160,54 +141,7 @@ var AboutLoginsParent = {
|
|||
}
|
||||
},
|
||||
|
||||
async showMasterPasswordLoginNotifications() {
|
||||
if (!this._l10n) {
|
||||
this._l10n = new Localization(["browser/aboutLogins.ftl"]);
|
||||
}
|
||||
|
||||
let messageString = await this._l10n.formatValue("master-password-notification-message");
|
||||
for (let subscriber of this._subscriberIterator()) {
|
||||
// If there's already an existing notification bar, don't do anything.
|
||||
let {gBrowser} = subscriber.ownerGlobal;
|
||||
let browser = subscriber;
|
||||
let notificationBox = gBrowser.getNotificationBox(browser);
|
||||
let notification = notificationBox.getNotificationWithValue(MASTER_PASSWORD_NOTIFICATION_ID);
|
||||
if (notification) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Configure the notification bar
|
||||
let priority = notificationBox.PRIORITY_WARNING_MEDIUM;
|
||||
let iconURL = "chrome://browser/skin/login.svg";
|
||||
let reloadLabel = await this._l10n.formatValue("master-password-reload-button-label");
|
||||
let reloadKey = await this._l10n.formatValue("master-password-reload-button-accesskey");
|
||||
|
||||
let buttons = [{
|
||||
label: reloadLabel,
|
||||
accessKey: reloadKey,
|
||||
popup: null,
|
||||
callback() { browser.reload(); },
|
||||
}];
|
||||
|
||||
notification = notificationBox.appendNotification(messageString, MASTER_PASSWORD_NOTIFICATION_ID,
|
||||
iconURL, priority, buttons);
|
||||
}
|
||||
},
|
||||
|
||||
removeMasterPasswordLoginNotifications() {
|
||||
for (let subscriber of this._subscriberIterator()) {
|
||||
let {gBrowser} = subscriber.ownerGlobal;
|
||||
let browser = subscriber;
|
||||
let notificationBox = gBrowser.getNotificationBox(browser);
|
||||
let notification = notificationBox.getNotificationWithValue(MASTER_PASSWORD_NOTIFICATION_ID);
|
||||
if (!notification) {
|
||||
continue;
|
||||
}
|
||||
notificationBox.removeNotification(notification);
|
||||
}
|
||||
},
|
||||
|
||||
* _subscriberIterator() {
|
||||
messageSubscribers(name, details) {
|
||||
let subscribers = ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers);
|
||||
for (let subscriber of subscribers) {
|
||||
if (subscriber.remoteType != EXPECTED_ABOUTLOGINS_REMOTE_TYPE ||
|
||||
|
@ -216,12 +150,6 @@ var AboutLoginsParent = {
|
|||
this._subscribers.delete(subscriber);
|
||||
continue;
|
||||
}
|
||||
yield subscriber;
|
||||
}
|
||||
},
|
||||
|
||||
messageSubscribers(name, details) {
|
||||
for (let subscriber of this._subscriberIterator()) {
|
||||
try {
|
||||
subscriber.messageManager.sendAsyncMessage(name, details);
|
||||
} catch (ex) {}
|
||||
|
|
|
@ -40,9 +40,3 @@ login-item =
|
|||
.time-changed = Last changed: { DATETIME($timeChanged, day: "numeric", month: "long", year: "numeric") }
|
||||
.time-used = Last used: { DATETIME($timeUsed, day: "numeric", month: "long", year: "numeric") }
|
||||
.username-label = Username
|
||||
|
||||
master-password-notification-message = Please enter your master password to view saved logins & passwords
|
||||
# TODO: Not sure how to use formatValue with these as attributes on a single ID
|
||||
master-password-reload-button-label = Log in
|
||||
# TODO: Not sure how to use formatValue with these as attributes on a single ID
|
||||
master-password-reload-button-accesskey = L
|
||||
|
|
|
@ -5,6 +5,5 @@ prefs =
|
|||
[browser_copyToClipboardButton.js]
|
||||
[browser_deleteLogin.js]
|
||||
[browser_loginListChanges.js]
|
||||
[browser_masterPassword.js]
|
||||
[browser_openSite.js]
|
||||
[browser_updateLogin.js]
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
ChromeUtils.import("resource://testing-common/LoginTestUtils.jsm", this);
|
||||
|
||||
/**
|
||||
* Waits for the master password prompt and performs an action.
|
||||
* @param {string} action Set to "authenticate" to log in or "cancel" to
|
||||
* close the dialog without logging in.
|
||||
*/
|
||||
function waitForMPDialog(action) {
|
||||
let dialogShown = TestUtils.topicObserved("common-dialog-loaded");
|
||||
return dialogShown.then(function([subject]) {
|
||||
let dialog = subject.Dialog;
|
||||
is(dialog.args.title, "Password Required");
|
||||
if (action == "authenticate") {
|
||||
SpecialPowers.wrap(dialog.ui.password1Textbox)
|
||||
.setUserInput(LoginTestUtils.masterPassword.masterPassword);
|
||||
dialog.ui.button0.click();
|
||||
} else if (action == "cancel") {
|
||||
dialog.ui.button1.click();
|
||||
}
|
||||
return BrowserTestUtils.waitForEvent(window, "DOMModalDialogClosed");
|
||||
});
|
||||
}
|
||||
|
||||
function getNumberOfLoginsDisplayed(browser) {
|
||||
return ContentTask.spawn(browser, null, async () => {
|
||||
let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
|
||||
return loginList._logins.length;
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test() {
|
||||
let login = LoginTestUtils.testData.formLogin({
|
||||
hostname: "https://example.com",
|
||||
formSubmitURL: "https://example.com",
|
||||
username: "username",
|
||||
password: "password",
|
||||
});
|
||||
|
||||
Services.logins.addLogin(login);
|
||||
LoginTestUtils.masterPassword.enable();
|
||||
|
||||
let mpDialogShown = waitForMPDialog("cancel");
|
||||
await BrowserTestUtils.openNewForegroundTab({gBrowser, url: "about:logins"});
|
||||
await mpDialogShown;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
LoginTestUtils.masterPassword.disable();
|
||||
Services.logins.removeAllLogins();
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
let logins = await getNumberOfLoginsDisplayed(browser);
|
||||
is(logins, 0, "No logins should be displayed when MP is set and unauthenticated");
|
||||
|
||||
let notificationBox = gBrowser.getNotificationBox(browser);
|
||||
let notification = notificationBox.currentNotification;
|
||||
|
||||
ok(notification, "Notification should be visible");
|
||||
is(notification.getAttribute("value"), "master-password-login-required",
|
||||
"Should be showing the right notification");
|
||||
|
||||
let buttons = notification.querySelectorAll(".notification-button");
|
||||
is(buttons.length, 1, "Should have one button.");
|
||||
|
||||
let refreshPromise = BrowserTestUtils.browserLoaded(browser);
|
||||
// Sign in with the Master Password this time the dialog is shown
|
||||
mpDialogShown = waitForMPDialog("authenticate");
|
||||
// Click the button to reload the page.
|
||||
buttons[0].click();
|
||||
await refreshPromise;
|
||||
info("Page reloaded");
|
||||
|
||||
await mpDialogShown;
|
||||
info("Master Password dialog shown and authenticated");
|
||||
|
||||
logins = await getNumberOfLoginsDisplayed(browser);
|
||||
is(logins, 1, "Logins should be displayed when MP is set and authenticated");
|
||||
});
|
Загрузка…
Ссылка в новой задаче