зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1611914, bug 1605494) for causing browser chrome failures at browser/components/aboutlogins/tests/browser/browser_osAuthDialog.js
CLOSED TREE Backed out changeset b0ef46ae3853 (bug 1611914) Backed out changeset f93685e544c5 (bug 1605494) --HG-- extra : amend_source : 0e196a48b4b196268ddae92af2fa00067bb6dc0b
This commit is contained in:
Родитель
f4ff3c2181
Коммит
2eded7e7be
|
@ -701,7 +701,6 @@ const listeners = {
|
|||
"AboutLogins:Subscribe": ["AboutLoginsParent"],
|
||||
"AboutLogins:SyncEnable": ["AboutLoginsParent"],
|
||||
"AboutLogins:SyncOptions": ["AboutLoginsParent"],
|
||||
"AboutLogins:TestOnlyResetOSAuth": ["AboutLoginsParent"],
|
||||
"AboutLogins:UpdateLogin": ["AboutLoginsParent"],
|
||||
ContentSearch: ["ContentSearch"],
|
||||
"Reader:FaviconRequest": ["ReaderParent"],
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// _AboutLogins is only exported for testing
|
||||
var EXPORTED_SYMBOLS = ["AboutLoginsParent", "_AboutLogins"];
|
||||
var EXPORTED_SYMBOLS = ["AboutLoginsParent"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
|
@ -322,18 +321,12 @@ class AboutLoginsParent extends JSWindowActorParent {
|
|||
);
|
||||
}
|
||||
|
||||
if (Date.now() < AboutLogins._authExpirationTime) {
|
||||
this.sendAsyncMessage("AboutLogins:MasterPasswordResponse", true);
|
||||
return;
|
||||
}
|
||||
|
||||
// This does no harm if master password isn't set.
|
||||
let tokendb = Cc["@mozilla.org/security/pk11tokendb;1"].createInstance(
|
||||
Ci.nsIPK11TokenDB
|
||||
);
|
||||
let token = tokendb.getInternalKeyToken();
|
||||
|
||||
let loggedIn = false;
|
||||
// Use the OS auth dialog if there is no master password
|
||||
if (token.checkPassword("")) {
|
||||
if (AppConstants.platform == "macosx") {
|
||||
|
@ -351,41 +344,40 @@ class AboutLoginsParent extends JSWindowActorParent {
|
|||
},
|
||||
]
|
||||
);
|
||||
loggedIn = await OSKeyStore.ensureLoggedIn(
|
||||
let loggedIn = await OSKeyStore.ensureLoggedIn(
|
||||
messageText.value,
|
||||
captionText.value,
|
||||
ownerGlobal,
|
||||
false
|
||||
);
|
||||
} else {
|
||||
// If a master password prompt is already open, just exit early and return false.
|
||||
// The user can re-trigger it after responding to the already open dialog.
|
||||
if (Services.logins.uiBusy) {
|
||||
this.sendAsyncMessage("AboutLogins:MasterPasswordResponse", false);
|
||||
return;
|
||||
}
|
||||
|
||||
// So there's a master password. But since checkPassword didn't succeed, we're logged out (per nsIPK11Token.idl).
|
||||
try {
|
||||
// Relogin and ask for the master password.
|
||||
token.login(true); // 'true' means always prompt for token password. User will be prompted until
|
||||
// clicking 'Cancel' or entering the correct password.
|
||||
} catch (e) {
|
||||
// An exception will be thrown if the user cancels the login prompt dialog.
|
||||
// User is also logged out of Software Security Device.
|
||||
}
|
||||
loggedIn = token.isLoggedIn();
|
||||
this.sendAsyncMessage("AboutLogins:MasterPasswordResponse", loggedIn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (loggedIn) {
|
||||
const AUTH_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
|
||||
AboutLogins._authExpirationTime = Date.now() + AUTH_TIMEOUT_MS;
|
||||
// If a master password prompt is already open, just exit early and return false.
|
||||
// The user can re-trigger it after responding to the already open dialog.
|
||||
if (Services.logins.uiBusy) {
|
||||
this.sendAsyncMessage("AboutLogins:MasterPasswordResponse", false);
|
||||
return;
|
||||
}
|
||||
this.sendAsyncMessage("AboutLogins:MasterPasswordResponse", loggedIn);
|
||||
|
||||
// So there's a master password. But since checkPassword didn't succeed, we're logged out (per nsIPK11Token.idl).
|
||||
try {
|
||||
// Relogin and ask for the master password.
|
||||
token.login(true); // 'true' means always prompt for token password. User will be prompted until
|
||||
// clicking 'Cancel' or entering the correct password.
|
||||
} catch (e) {
|
||||
// An exception will be thrown if the user cancels the login prompt dialog.
|
||||
// User is also logged out of Software Security Device.
|
||||
}
|
||||
|
||||
this.sendAsyncMessage(
|
||||
"AboutLogins:MasterPasswordResponse",
|
||||
token.isLoggedIn()
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "AboutLogins:Subscribe": {
|
||||
AboutLogins._authExpirationTime = Number.NEGATIVE_INFINITY;
|
||||
if (!AboutLogins._observersAdded) {
|
||||
Services.obs.addObserver(AboutLogins, "passwordmgr-crypto-login");
|
||||
Services.obs.addObserver(
|
||||
|
@ -505,7 +497,6 @@ class AboutLoginsParent extends JSWindowActorParent {
|
|||
var AboutLogins = {
|
||||
_subscribers: new WeakSet(),
|
||||
_observersAdded: false,
|
||||
_authExpirationTime: Number.NEGATIVE_INFINITY,
|
||||
|
||||
async observe(subject, topic, type) {
|
||||
if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) {
|
||||
|
@ -839,7 +830,6 @@ var AboutLogins = {
|
|||
this.updatePasswordSyncNotificationState(this.getSyncState(), latest);
|
||||
},
|
||||
};
|
||||
var _AboutLogins = AboutLogins;
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
|
|
|
@ -3,9 +3,9 @@ support-files =
|
|||
head.js
|
||||
|
||||
# Run first so content events from previous tests won't trickle in.
|
||||
# Skip ASAN and debug since waiting for content events is already slow.
|
||||
# Skip ASAN since waiting for content events is already slow.
|
||||
[browser_aaa_eventTelemetry_run_first.js]
|
||||
skip-if = asan || debug
|
||||
skip-if = asan || (os == 'linux') # bug 1605494 is more prevalent on linux
|
||||
[browser_breachAlertDismissals.js]
|
||||
skip-if = asan || debug || verify # bug 1574023
|
||||
[browser_breachAlertShowingForAddedLogin.js]
|
||||
|
@ -30,9 +30,11 @@ skip-if = (os != "win" && os != "mac") # import is only available on Windows and
|
|||
[browser_openPreferences.js]
|
||||
[browser_openPreferencesExternal.js]
|
||||
[browser_openSite.js]
|
||||
skip-if = !debug # test relies on edit mode which is only testable in debug builds
|
||||
[browser_osAuthDialog.js]
|
||||
skip-if = (os == 'linux') # bug 1527745
|
||||
skip-if = ((os == 'linux') || !debug) # bug 1527745
|
||||
[browser_sessionRestore.js]
|
||||
skip-if = debug # Bug 1576876
|
||||
[browser_tabKeyNav.js]
|
||||
[browser_updateLogin.js]
|
||||
skip-if = !debug # test relies on edit mode which is only testable in debug builds
|
||||
|
|
|
@ -94,9 +94,7 @@ add_task(async function test_telemetry_events() {
|
|||
|
||||
// Show the password
|
||||
if (OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
let reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
|
@ -117,9 +115,7 @@ add_task(async function test_telemetry_events() {
|
|||
});
|
||||
await LoginTestUtils.telemetry.waitForEventCount(nextTelemetryEventCount++);
|
||||
|
||||
reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
ChromeUtils.import("resource://testing-common/OSKeyStoreTestUtils.jsm", this);
|
||||
let { OSKeyStoreTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/OSKeyStoreTestUtils.jsm"
|
||||
);
|
||||
|
||||
add_task(async function setup() {
|
||||
TEST_LOGIN1 = await addLogin(TEST_LOGIN1);
|
||||
|
|
|
@ -199,9 +199,7 @@ add_task(async function test_create_login() {
|
|||
continue;
|
||||
}
|
||||
|
||||
let reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(browser, [originTuple], async aOriginTuple => {
|
||||
let loginItem = Cu.waiveXrays(
|
||||
content.document.querySelector("login-item")
|
||||
|
|
|
@ -138,7 +138,7 @@ add_task(async function test_login_item() {
|
|||
|
||||
let onDeletePromise;
|
||||
if (OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
// Can only test Edit mode in official builds
|
||||
// Can only test Edit mode in debug builds
|
||||
onDeletePromise = waitForDelete();
|
||||
await deleteFirstLoginAfterEdit();
|
||||
await onDeletePromise;
|
||||
|
|
|
@ -25,16 +25,16 @@ add_task(async function test_showLoginItemErrors() {
|
|||
);
|
||||
LOGIN_TO_UPDATE = Services.logins.addLogin(LOGIN_TO_UPDATE);
|
||||
EXPECTED_ERROR_MESSAGE = "This login already exists.";
|
||||
const LOGIN_UPDATES = {
|
||||
origin: "https://example.com",
|
||||
password: "my1GoodPassword",
|
||||
username: "user1",
|
||||
};
|
||||
|
||||
await SpecialPowers.spawn(
|
||||
browser,
|
||||
[[LoginHelper.loginToVanillaObject(LOGIN_TO_UPDATE), LOGIN_UPDATES]],
|
||||
async ([loginToUpdate, loginUpdates]) => {
|
||||
[
|
||||
[
|
||||
LoginHelper.loginToVanillaObject(LOGIN_TO_UPDATE),
|
||||
OSKeyStoreTestUtils.canTestOSKeyStoreLogin(),
|
||||
],
|
||||
],
|
||||
async ([loginToUpdate, canTestOSKeyStoreLogin]) => {
|
||||
const loginItem = Cu.waiveXrays(
|
||||
content.document.querySelector("login-item")
|
||||
);
|
||||
|
@ -48,6 +48,12 @@ add_task(async function test_showLoginItemErrors() {
|
|||
const createButton = loginList._createLoginButton;
|
||||
createButton.click();
|
||||
|
||||
const loginUpdates = {
|
||||
origin: "https://example.com",
|
||||
password: "my1GoodPassword",
|
||||
username: "user1",
|
||||
};
|
||||
|
||||
const event = Cu.cloneInto(
|
||||
{
|
||||
bubbles: true,
|
||||
|
@ -102,20 +108,12 @@ add_task(async function test_showLoginItemErrors() {
|
|||
loginItemErrorMessage.hidden,
|
||||
"The error message should no longer be visible."
|
||||
);
|
||||
}
|
||||
);
|
||||
if (!OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
// The rest of the test uses Edit mode which causes an OS prompt in official builds.
|
||||
return;
|
||||
}
|
||||
let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(
|
||||
browser,
|
||||
[[LoginHelper.loginToVanillaObject(LOGIN_TO_UPDATE), LOGIN_UPDATES]],
|
||||
async ([loginToUpdate, loginUpdates]) => {
|
||||
const loginItem = Cu.waiveXrays(
|
||||
content.document.querySelector("login-item")
|
||||
);
|
||||
|
||||
if (!canTestOSKeyStoreLogin) {
|
||||
// The rest of the test uses Edit mode which causes an OS prompt in opt builds.
|
||||
return;
|
||||
}
|
||||
|
||||
const editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
editButton.click();
|
||||
|
||||
|
@ -132,9 +130,6 @@ add_task(async function test_showLoginItemErrors() {
|
|||
new content.CustomEvent("AboutLoginsUpdateLogin", updateEvent)
|
||||
);
|
||||
|
||||
const loginItemErrorMessage = Cu.waiveXrays(
|
||||
loginItem.shadowRoot.querySelector(".error-message")
|
||||
);
|
||||
const loginAlreadyExistsErrorShownAfterUpdate = await ContentTaskUtils.waitForCondition(
|
||||
() => {
|
||||
return !loginItemErrorMessage.hidden;
|
||||
|
@ -147,8 +142,5 @@ add_task(async function test_showLoginItemErrors() {
|
|||
);
|
||||
}
|
||||
);
|
||||
info("making sure os auth dialog is shown");
|
||||
await reauthObserved;
|
||||
info("saw os auth dialog");
|
||||
EXPECTED_ERROR_MESSAGE = null;
|
||||
});
|
||||
|
|
|
@ -25,8 +25,8 @@ add_task(async function test_sort_order_persisted() {
|
|||
async function(browser) {
|
||||
await ContentTask.spawn(
|
||||
browser,
|
||||
[TEST_LOGIN1.guid, TEST_LOGIN2.guid],
|
||||
async function([testLogin1Guid, testLogin2Guid]) {
|
||||
[TEST_LOGIN1, TEST_LOGIN2],
|
||||
async function([testLogin1, testLogin2]) {
|
||||
let loginList = Cu.waiveXrays(
|
||||
content.document.querySelector("login-list")
|
||||
);
|
||||
|
@ -39,7 +39,7 @@ add_task(async function test_sort_order_persisted() {
|
|||
loginList._list.querySelector(
|
||||
".login-list-item[data-guid]:not([hidden])"
|
||||
).dataset.guid,
|
||||
testLogin2Guid,
|
||||
testLogin2.guid,
|
||||
"the first login should be TEST_LOGIN2 since they are sorted by origin"
|
||||
);
|
||||
|
||||
|
@ -51,7 +51,7 @@ add_task(async function test_sort_order_persisted() {
|
|||
loginList._list.querySelector(
|
||||
".login-list-item[data-guid]:not([hidden])"
|
||||
).dataset.guid,
|
||||
testLogin1Guid,
|
||||
testLogin1.guid,
|
||||
"the first login should be TEST_LOGIN1 since it has the most recent timePasswordChanged value"
|
||||
);
|
||||
}
|
||||
|
@ -65,9 +65,7 @@ add_task(async function test_sort_order_persisted() {
|
|||
url: "about:logins",
|
||||
},
|
||||
async function(browser) {
|
||||
await ContentTask.spawn(browser, TEST_LOGIN1.guid, async function(
|
||||
testLogin1Guid
|
||||
) {
|
||||
await ContentTask.spawn(browser, TEST_LOGIN1, async function(testLogin1) {
|
||||
let loginList = Cu.waiveXrays(
|
||||
content.document.querySelector("login-list")
|
||||
);
|
||||
|
@ -80,7 +78,7 @@ add_task(async function test_sort_order_persisted() {
|
|||
loginList._list.querySelector(
|
||||
".login-list-item[data-guid]:not([hidden])"
|
||||
).dataset.guid,
|
||||
testLogin1Guid,
|
||||
testLogin1.guid,
|
||||
"the first login should still be TEST_LOGIN1 since it has the most recent timePasswordChanged value"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2,6 +2,33 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
ChromeUtils.import("resource://testing-common/LoginTestUtils.jsm", this);
|
||||
const BRAND_BUNDLE = Services.strings.createBundle(
|
||||
"chrome://branding/locale/brand.properties"
|
||||
);
|
||||
const BRAND_FULL_NAME = BRAND_BUNDLE.GetStringFromName("brandFullName");
|
||||
|
||||
/**
|
||||
* 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;
|
||||
let expected = "Password Required - " + BRAND_FULL_NAME;
|
||||
is(dialog.args.title, expected, "Dialog is the Master Password dialog");
|
||||
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 waitForLoginCountToReach(browser, loginCount) {
|
||||
return SpecialPowers.spawn(
|
||||
|
@ -35,7 +62,7 @@ add_task(async function test() {
|
|||
TEST_LOGIN1 = await addLogin(TEST_LOGIN1);
|
||||
LoginTestUtils.masterPassword.enable();
|
||||
|
||||
let mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("cancel");
|
||||
let mpDialogShown = waitForMPDialog("cancel");
|
||||
await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "about:logins",
|
||||
|
@ -74,7 +101,7 @@ add_task(async function test() {
|
|||
|
||||
let refreshPromise = BrowserTestUtils.browserLoaded(browser);
|
||||
// Sign in with the Master Password this time the dialog is shown
|
||||
mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("authenticate");
|
||||
mpDialogShown = waitForMPDialog("authenticate");
|
||||
// Click the button to reload the page.
|
||||
buttons[0].click();
|
||||
await refreshPromise;
|
||||
|
@ -87,7 +114,7 @@ add_task(async function test() {
|
|||
is(logins, 1, "Logins should be displayed when MP is set and authenticated");
|
||||
|
||||
// Show MP dialog when Copy Password button clicked
|
||||
mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("cancel");
|
||||
mpDialogShown = waitForMPDialog("cancel");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let copyButton = loginItem.shadowRoot.querySelector(
|
||||
|
@ -97,7 +124,7 @@ add_task(async function test() {
|
|||
});
|
||||
await mpDialogShown;
|
||||
info("Master Password dialog shown and canceled");
|
||||
mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("authenticate");
|
||||
mpDialogShown = waitForMPDialog("authenticate");
|
||||
info("Clicking copy password button again");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
|
@ -120,7 +147,7 @@ add_task(async function test() {
|
|||
});
|
||||
|
||||
// Show MP dialog when Reveal Password checkbox is checked if not on a new login
|
||||
mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("cancel");
|
||||
mpDialogShown = waitForMPDialog("cancel");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
|
@ -140,7 +167,7 @@ add_task(async function test() {
|
|||
"reveal checkbox should be unchecked if MP dialog canceled"
|
||||
);
|
||||
});
|
||||
mpDialogShown = forceAuthTimeoutAndWaitForMPDialog("authenticate");
|
||||
mpDialogShown = waitForMPDialog("authenticate");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
|
|
|
@ -22,30 +22,6 @@ add_task(async function test_launch_login_item() {
|
|||
);
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
let originInput = loginItem.shadowRoot.querySelector("a[name='origin']");
|
||||
let EventUtils = ContentTaskUtils.getEventUtils(content);
|
||||
// Use synthesizeMouseAtCenter to generate an event that more closely resembles the
|
||||
// properties of the event object that will be seen when the user clicks the element
|
||||
// (.click() sets originalTarget while synthesizeMouse has originalTarget as a Restricted object).
|
||||
await EventUtils.synthesizeMouseAtCenter(originInput, {}, content);
|
||||
});
|
||||
|
||||
info("waiting for new tab to get opened");
|
||||
let newTab = await promiseNewTab;
|
||||
ok(true, "New tab opened to " + TEST_LOGIN1.origin);
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
|
||||
if (!OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
promiseNewTab = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
TEST_LOGIN1.origin + "/"
|
||||
);
|
||||
let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
|
@ -70,7 +46,7 @@ add_task(async function test_launch_login_item() {
|
|||
});
|
||||
|
||||
info("waiting for new tab to get opened");
|
||||
newTab = await promiseNewTab;
|
||||
let newTab = await promiseNewTab;
|
||||
ok(true, "New tab opened to " + TEST_LOGIN1.origin);
|
||||
|
||||
let modifiedLogin = TEST_LOGIN1.clone();
|
||||
|
|
|
@ -16,18 +16,6 @@ add_task(async function test() {
|
|||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
info(
|
||||
`updatechannel: ${UpdateUtils.getUpdateChannel(false)}; platform: ${
|
||||
AppConstants.platform
|
||||
}`
|
||||
);
|
||||
if (!OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
ok(
|
||||
true,
|
||||
`skipping test since oskeystore cannot be automated in this environment`
|
||||
);
|
||||
}
|
||||
|
||||
// Show OS auth dialog when Reveal Password checkbox is checked if not on a new login
|
||||
let osAuthDialogShown = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(false);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
|
@ -69,67 +57,4 @@ add_task(async function test() {
|
|||
"reveal checkbox should be checked if OS auth dialog authenticated"
|
||||
);
|
||||
});
|
||||
|
||||
info("'Edit' shouldn't show the prompt since the user has authenticated now");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
ok(!loginItem.dataset.editing, "Not in edit mode before clicking 'Edit'");
|
||||
let editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
editButton.click();
|
||||
|
||||
await ContentTaskUtils.waitForCondition(
|
||||
() => loginItem.dataset.editing,
|
||||
"waiting for 'edit' mode"
|
||||
);
|
||||
ok(loginItem.dataset.editing, "In edit mode");
|
||||
});
|
||||
|
||||
info("Test that the OS auth prompt is shown after about:logins is reopened");
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "about:logins",
|
||||
});
|
||||
|
||||
// Show OS auth dialog since the page has been reloaded.
|
||||
osAuthDialogShown = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(false);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
".reveal-password-checkbox"
|
||||
);
|
||||
revealCheckbox.click();
|
||||
});
|
||||
await osAuthDialogShown;
|
||||
info("OS auth dialog shown and canceled");
|
||||
|
||||
// Show OS auth dialog since the previous attempt was canceled
|
||||
osAuthDialogShown = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
".reveal-password-checkbox"
|
||||
);
|
||||
revealCheckbox.click();
|
||||
info("clicking on reveal checkbox to hide the password");
|
||||
revealCheckbox.click();
|
||||
});
|
||||
await osAuthDialogShown;
|
||||
info("OS auth dialog shown and passed");
|
||||
|
||||
// Show OS auth dialog since the timeout will have expired
|
||||
osAuthDialogShown = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
let revealCheckbox = loginItem.shadowRoot.querySelector(
|
||||
".reveal-password-checkbox"
|
||||
);
|
||||
info("clicking on reveal checkbox to reveal password");
|
||||
revealCheckbox.click();
|
||||
});
|
||||
info("waiting for os auth dialog");
|
||||
await osAuthDialogShown;
|
||||
info("OS auth dialog shown and passed after timeout expiration");
|
||||
});
|
||||
|
|
|
@ -30,10 +30,6 @@ add_task(async function test_show_logins() {
|
|||
});
|
||||
|
||||
add_task(async function test_login_item() {
|
||||
if (!OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
async function test_discard_dialog(login, exitPointSelector) {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
|
||||
|
@ -153,9 +149,7 @@ add_task(async function test_login_item() {
|
|||
[LoginHelper.loginToVanillaObject(TEST_LOGIN1), ".create-login-button"],
|
||||
test_discard_dialog
|
||||
);
|
||||
reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
let editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
|
@ -168,9 +162,7 @@ add_task(async function test_login_item() {
|
|||
[LoginHelper.loginToVanillaObject(TEST_LOGIN1), ".cancel-button"],
|
||||
test_discard_dialog
|
||||
);
|
||||
reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
let editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
|
@ -249,9 +241,7 @@ add_task(async function test_login_item() {
|
|||
);
|
||||
}
|
||||
);
|
||||
reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
|
||||
loginResult: true,
|
||||
});
|
||||
reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
|
||||
let editButton = loginItem.shadowRoot.querySelector(".edit-button");
|
||||
|
|
|
@ -7,15 +7,6 @@ let { LoginBreaches } = ChromeUtils.import(
|
|||
let { RemoteSettings } = ChromeUtils.import(
|
||||
"resource://services-settings/remote-settings.js"
|
||||
);
|
||||
let { _AboutLogins } = ChromeUtils.import(
|
||||
"resource:///actors/AboutLoginsParent.jsm"
|
||||
);
|
||||
let { OSKeyStoreTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/OSKeyStoreTestUtils.jsm"
|
||||
);
|
||||
let { LoginTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/LoginTestUtils.jsm"
|
||||
);
|
||||
|
||||
let nsLoginInfo = new Components.Constructor(
|
||||
"@mozilla.org/login-manager/loginInfo;1",
|
||||
|
@ -144,59 +135,3 @@ add_task(async function setup() {
|
|||
SpecialPowers.postConsoleSentinel();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
const BRAND_BUNDLE = Services.strings.createBundle(
|
||||
"chrome://branding/locale/brand.properties"
|
||||
);
|
||||
const BRAND_FULL_NAME = BRAND_BUNDLE.GetStringFromName("brandFullName");
|
||||
let dialogShown = TestUtils.topicObserved("common-dialog-loaded");
|
||||
return dialogShown.then(function([subject]) {
|
||||
let dialog = subject.Dialog;
|
||||
let expected = "Password Required - " + BRAND_FULL_NAME;
|
||||
is(dialog.args.title, expected, "Dialog is the Master Password dialog");
|
||||
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");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for tests to reset the MP auth expiration and
|
||||
* return a promise that will resolve after the MP dialog has
|
||||
* been presented.
|
||||
*
|
||||
* @param {string} action Set to "authenticate" to log in or "cancel" to
|
||||
* close the dialog without logging in.
|
||||
* @returns {Promise} Resolves after the MP dialog has been presented and actioned upon
|
||||
*/
|
||||
function forceAuthTimeoutAndWaitForMPDialog(action) {
|
||||
const AUTH_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes (duplicated from AboutLoginsParent.jsm)
|
||||
_AboutLogins._authExpirationTime -= AUTH_TIMEOUT_MS + 1;
|
||||
return waitForMPDialog(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for tests to reset the OS auth expiration and
|
||||
* return a promise that will resolve after the OS auth dialog has
|
||||
* been presented.
|
||||
*
|
||||
* @param {bool} loginResult True if the auth prompt should pass, otherwise false will fail
|
||||
* @returns {Promise} Resolves after the OS auth dialog has been presented
|
||||
*/
|
||||
function forceAuthTimeoutAndWaitForOSKeyStoreLogin({ loginResult }) {
|
||||
const AUTH_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes (duplicated from AboutLoginsParent.jsm)
|
||||
_AboutLogins._authExpirationTime -= AUTH_TIMEOUT_MS + 1;
|
||||
return OSKeyStoreTestUtils.waitForOSKeyStoreLogin(loginResult);
|
||||
}
|
||||
|
|
|
@ -20,11 +20,6 @@ ChromeUtils.defineModuleGetter(
|
|||
"AppConstants",
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"UpdateUtils",
|
||||
"resource://gre/modules/UpdateUtils.jsm"
|
||||
);
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"nativeOSKeyStore",
|
||||
|
@ -176,11 +171,7 @@ var OSKeyStore = {
|
|||
|
||||
let unlockPromise;
|
||||
if (typeof reauth == "string") {
|
||||
// Only allow for local builds
|
||||
if (
|
||||
UpdateUtils.getUpdateChannel(false) == "default" &&
|
||||
this._testReauth
|
||||
) {
|
||||
if (AppConstants.DEBUG && this._testReauth) {
|
||||
unlockPromise = this._reauthInTests();
|
||||
} else if (
|
||||
AppConstants.platform == "win" ||
|
||||
|
|
|
@ -9,11 +9,6 @@ ChromeUtils.import("resource:///modules/OSKeyStore.jsm", this);
|
|||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"UpdateUtils",
|
||||
"resource://gre/modules/UpdateUtils.jsm"
|
||||
);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
|
@ -44,10 +39,7 @@ var OSKeyStoreTestUtils = {
|
|||
*/
|
||||
canTestOSKeyStoreLogin() {
|
||||
// Skip on Linux due to bug 1527745.
|
||||
return (
|
||||
UpdateUtils.getUpdateChannel(false) == "default" &&
|
||||
AppConstants.platform != "linux"
|
||||
);
|
||||
return AppConstants.DEBUG && AppConstants.platform != "linux";
|
||||
},
|
||||
|
||||
// Wait for the observer message that simulates login success of failure.
|
||||
|
|
|
@ -8,6 +8,7 @@ skip-if = toolkit == 'android'
|
|||
[test_HomePage_ignore.js]
|
||||
[test_LiveBookmarkMigrator.js]
|
||||
[test_osKeyStore.js]
|
||||
skip-if = !debug # test relies on osKeyStore reauth which is only testable in debug builds
|
||||
[test_Sanitizer_interrupted.js]
|
||||
[test_SitePermissions.js]
|
||||
[test_SiteDataManager.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче