Backed out changeset 6f3b93e9f07c (bug 1538460) for browser-chrome failures at toolkit/components/passwordmgr/test/browser/browser_hidden_document_autofill.js on a CLOSED TREE

This commit is contained in:
Coroiu Cristina 2019-04-11 02:55:32 +03:00
Родитель 1535d36477
Коммит 619127a72d
3 изменённых файлов: 28 добавлений и 27 удалений

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

@ -87,14 +87,11 @@ LoginManager.prototype = {
Services.obs.addObserver(this._observer, "gather-telemetry");
},
_initStorage() {
this._storage = Cc["@mozilla.org/login-manager/storage/default;1"]
.createInstance(Ci.nsILoginManagerStorage);
this.initializationPromise = this._storage.initialize();
this.initializationPromise.then(() => {
log.debug("initializationPromise is resolved, updating isMasterPasswordSet in sharedData");
Services.ppmm.sharedData.set("isMasterPasswordSet", LoginHelper.isMasterPasswordSet());
});
},

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

@ -445,15 +445,8 @@ var LoginManagerContent = {
if (!event.isTrusted) {
return;
}
let isMasterPasswordSet = Services.cpmm.sharedData.get("isMasterPasswordSet");
let document = event.target.ownerDocument;
// don't attempt to defer handling when a master password is set
// Showing the MP modal as soon as possible minimizes its interference with tab interactions
// See bug 1539091 and bug 1538460.
log("onDOMFormHasPassword, visibilityState:", document.visibilityState,
"isMasterPasswordSet:", isMasterPasswordSet);
if (document.visibilityState == "visible" || isMasterPasswordSet) {
if (document.visibilityState == "visible") {
this._processDOMFormHasPasswordEvent(event);
} else {
// wait until the document becomes visible before handling this event
@ -484,14 +477,7 @@ var LoginManagerContent = {
}
let document = pwField.ownerDocument;
let isMasterPasswordSet = Services.cpmm.sharedData.get("isMasterPasswordSet");
log("onDOMInputPasswordAdded, visibilityState:", document.visibilityState,
"isMasterPasswordSet:", isMasterPasswordSet);
// don't attempt to defer handling when a master password is set
// Showing the MP modal as soon as possible minimizes its interference with tab interactions
// See bug 1539091 and bug 1538460.
if (document.visibilityState == "visible" || isMasterPasswordSet) {
if (document.visibilityState == "visible") {
this._processDOMInputPasswordAddedEvent(event, topWindow);
} else {
// wait until the document becomes visible before handling this event

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

@ -129,37 +129,55 @@ testUrls.forEach(testUrl => {
});
});
add_task(async function test_immediate_autofill_with_masterpassword() {
add_task(async function test_defer_autofill_with_masterpassword() {
// Set master password prompt timeout to 3s.
// If this test goes intermittent, you likely have to increase this value.
await SpecialPowers.pushPrefEnv({set: [["signon.masterPasswordReprompt.timeout_ms", 3000]]});
LoginTestUtils.masterPassword.enable();
await LoginTestUtils.reloadData();
info(`Have enabled masterPassword, now isLoggedIn? ${Services.logins.isLoggedIn}`);
registerCleanupFunction(function() {
LoginTestUtils.masterPassword.disable();
});
let result, tab1Visibility, dialogObserved;
// open 2 tabs
const tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, INITIAL_URL);
const tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, INITIAL_URL);
info("sanity check by first loading a form into the visible tab");
is(await getDocumentVisibilityState(tab2.linkedBrowser),
"visible", "The second tab should be visible");
result = { wasShown: false };
dialogObserved = observeMasterPasswordDialog(tab2.ownerGlobal, result);
await BrowserTestUtils.loadURI(tab2.linkedBrowser, FORM_URL);
await dialogObserved;
ok(result.wasShown, "Dialog should be shown when form is loaded into a visible document");
info("load a background login form tab with a matching saved login " +
"and wait to see if the master password dialog is shown");
// confirm document is hidden
tab1Visibility = await getDocumentVisibilityState(tab1.linkedBrowser);
is(tab1Visibility, "hidden", "The first tab should be backgrounded");
result = { wasShown: false };
dialogObserved = observeMasterPasswordDialog(tab1.ownerGlobal, result);
await BrowserTestUtils.loadURI(tab1.linkedBrowser, FORM_URL);
await dialogObserved;
ok(!result.wasShown, "Dialog should not be shown when form is loaded into a hidden document");
ok(result && result.wasShown, "MP Dialog should be shown when form is loaded into a hidden document");
info("switch to the form tab " +
"and confirm the master password dialog is then shown");
tab1Visibility = await getDocumentVisibilityState(tab1.linkedBrowser);
is(tab1Visibility, "hidden", "The first tab should be backgrounded");
result = { wasShown: false };
dialogObserved = observeMasterPasswordDialog(tab1.ownerGlobal, result);
await BrowserTestUtils.switchTab(gBrowser, tab1);
await dialogObserved;
tab1Visibility = await getDocumentVisibilityState(tab1.linkedBrowser);
is(tab1Visibility, "visible", "The first tab should be foreground");
ok(result.wasShown, "Dialog should be shown when input's document becomes visible");
gBrowser.removeTab(tab1);
gBrowser.removeTab(tab2);