Backed out changeset 610592f70d74 (bug 1575091) for failing in test_autocomplete_new_password.html

This commit is contained in:
Noemi Erli 2019-08-24 03:55:48 +03:00
parent dfe58e6580
commit b8540ff399
5 changed files with 11 additions and 123 deletions

View File

@ -622,8 +622,6 @@ const listeners = {
"update-error": ["UpdateListener"],
"gmp-plugin-crash": ["PluginManager"],
"plugin-crashed": ["PluginManager"],
"passwordmgr-storage-changed": ["LoginManagerParent"],
"passwordmgr-autosaved-login-merged": ["LoginManagerParent"],
},
ppmm: {

View File

@ -202,33 +202,6 @@ this.LoginManagerParent = {
return undefined;
},
// Observers are added in BrowserGlue.jsm on desktop
observe(subject, topic, data) {
if (topic == "passwordmgr-autosaved-login-merged") {
// in the case where an autosaved login is merged into an existing login,
// remove the generated-password cache entry entirely
let { origin } = subject;
if (this._generatedPasswordsByPrincipalOrigin.has(origin)) {
log("Removing generated-password cache entry for origin:", origin);
this._generatedPasswordsByPrincipalOrigin.delete(origin);
}
} else if (
topic == "passwordmgr-storage-changed" &&
data == "removeLogin"
) {
// in the case where an autosaved login is deleted, remove storageGUID for that entry
let { origin } = subject;
let generatedPW = this._generatedPasswordsByPrincipalOrigin.get(origin);
if (generatedPW) {
log(
"Removing storageGUID for generated-password cache entry on origin:",
origin
);
generatedPW.storageGUID = null;
}
}
},
/**
* Trigger a login form fill and send relevant data (e.g. logins and recipes)
* to the child process (LoginManagerContent).

View File

@ -1209,13 +1209,6 @@ LoginManagerPrompter.prototype = {
} else {
this.log("persistData: Update matched login", loginToUpdate.guid);
this._updateLogin(loginToUpdate, login);
// notify that this auto-saved login been merged
if (loginToRemove && loginToRemove.guid == autoSavedLoginGuid) {
Services.obs.notifyObservers(
loginToRemove,
"passwordmgr-autosaved-login-merged"
);
}
}
if (loginToRemove) {

View File

@ -1024,7 +1024,7 @@ add_task(async function autosaved_login_updated_to_existing_login() {
info("storage-change promises resolved");
// Check the auto-saved login was removed and the original login updated
verifyLogins([
let savedLogins = verifyLogins([
{
username: "user1",
password: autoSavedLogin.password,
@ -1042,12 +1042,15 @@ add_task(async function autosaved_login_updated_to_existing_login() {
"No notifications"
);
// make sure the cache entry was removed with the removal of the auto-saved login
ok(
!LoginManagerParent._generatedPasswordsByPrincipalOrigin.has(
"https://example.com"
),
"Generated password cache entry has been removed"
// make sure the cache entry is up to date:
let updatedLogin = savedLogins[0];
passwordCacheEntry = LoginManagerParent._generatedPasswordsByPrincipalOrigin.get(
"https://example.com"
);
todo_is(
passwordCacheEntry.storageGUID,
updatedLogin.guid,
"Generated password cache entry points at the correct login"
);
}
);

View File

@ -211,7 +211,7 @@ add_task(async function test_autofillAutocompletePassword_withGeneration() {
LOGIN_FIELD_UTILS.checkPasswordMasked(pword, true, "Before first fill of generated pw");
synthesizeKey("KEY_Enter");
info("waiting for the password field to be filled with the generated password");
info("waiting for the password field to be filled with the generatedpassword");
await SimpleTest.promiseWaitForCondition(() => !!pword.value, "Check generated pw filled");
LOGIN_FIELD_UTILS.checkPasswordMasked(pword, false, "After first fill of generated pw");
info("Wait for generated password to be added to storage");
@ -361,85 +361,6 @@ add_task(async function test_autofillAutocompletePassword_saveLoginDisabled() {
await LoginManager.setLoginSavingEnabled("https://example.com", true);
});
add_task(async function test_deleteAndReselectGeneratedPassword() {
info("Removing all logins to test auto-saving of generated passwords");
await LoginManager.removeAllLogins();
// form should not be filled
checkForm(2, "", "");
let pword = $_(2, "pword");
let uname = $_(2, "uname");
async function showAndSelectACPopupItem(index) {
pword.focus();
if (pword.value) {
pword.select();
synthesizeKey("KEY_Backspace");
}
shownPromise = promiseACShown();
synthesizeKey("KEY_ArrowDown");
let results = await shownPromise;
if (index < 0) {
index = results.length + index;
}
for (let i=0; i<=index; i++) {
synthesizeKey("KEY_ArrowDown");
}
await TestUtils.waitForTick();
return results[index];
}
let storagePromise, shownPromise, menuLabel, itemIndex, savedLogins;
// fill the password field with the generated password via auto-complete menu
storagePromise = promiseStorageChanged(["addLogin"]);
// select last-but-2 item - the one before the footer
menuLabel = await showAndSelectACPopupItem(-2);
is(menuLabel, "Use a Securely Generated Password", "Check item label");
synthesizeKey("KEY_Enter");
info("waiting for the password field to be filled with the generated password");
await SimpleTest.promiseWaitForCondition(() => !!pword.value, "Check generated pw filled");
info("Wait for generated password to be added to storage");
await storagePromise;
uname.focus();
await TestUtils.waitForTick();
is(pword.value.length, LoginTestUtils.generation.LENGTH, "Check password looks generated");
const GENERATED_PASSWORD = pword.value;
savedLogins = await LoginManager.getAllLogins();
is(savedLogins.length, 1, "Check saved logins count");
info("clear the password field and delete the saved login using the AC menu")
storagePromise = promiseStorageChanged(["removeLogin"]);
itemIndex = 0;
menuLabel = await showAndSelectACPopupItem(itemIndex);
ok(menuLabel.includes("No username"), "Check first item is the auto-saved login");
// Send delete to remove the auto-saved login from storage
synthesizeKey("KEY_Delete");
await storagePromise;
uname.focus();
await TestUtils.waitForTick();
savedLogins = await LoginManager.getAllLogins();
is(savedLogins.length, 0, "Check saved logins count");
info("Re-fill with the generated password");
// select last-but-2 item - the one before the footer
menuLabel = await showAndSelectACPopupItem(-2);
is(menuLabel, "Use a Securely Generated Password", "Check item label");
synthesizeKey("KEY_Enter");
info("waiting for the password field to be filled with the generated password");
await SimpleTest.promiseWaitForCondition(() => !!pword.value, "Check generated pw filled");
uname.focus();
await TestUtils.waitForTick();
is(pword.value, GENERATED_PASSWORD, "Generated password has not changed");
recreateTree(document.getElementById("form2"));});
</script>
</pre>
</body>