forked from mirrors/gecko-dev
Bug 1657998 - Add 'IgnorePasswordEdit' notification for tests. r=dimi
Instead of waiting for nothing to happen in some of the test cases in browser_doorhanger_form_password_edit, we now send a "IgnorePasswordEdit" notification so tests can react accordingly. This new 'IgnorePasswordEdit' message is only used for the previously mentioned test. Differential Revision: https://phabricator.services.mozilla.com/D126137
This commit is contained in:
parent
79f93e7a8b
commit
ec0e3ea35a
4 changed files with 39 additions and 24 deletions
|
|
@ -256,6 +256,11 @@ const observer = {
|
||||||
);
|
);
|
||||||
if (!docState.fieldModificationsByRootElement.get(formLikeRoot)) {
|
if (!docState.fieldModificationsByRootElement.get(formLikeRoot)) {
|
||||||
log("Ignoring change event on form that hasn't been user-modified");
|
log("Ignoring change event on form that hasn't been user-modified");
|
||||||
|
if (aEvent.composedTarget.hasBeenTypePassword) {
|
||||||
|
// Send notification that the password field has not been changed.
|
||||||
|
// This is used only for testing.
|
||||||
|
LoginManagerChild.forWindow(window)._ignorePasswordEdit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,6 +289,10 @@ const observer = {
|
||||||
triggeredByFillingGenerated,
|
triggeredByFillingGenerated,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// Send a notification that we are not saving the edit to the password field.
|
||||||
|
// This is used only for testing.
|
||||||
|
LoginManagerChild.forWindow(window)._ignorePasswordEdit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -2225,6 +2234,16 @@ this.LoginManagerChild = class LoginManagerChild extends JSWindowActorChild {
|
||||||
this._fillConfirmFieldWithGeneratedPassword(passwordField);
|
this._fillConfirmFieldWithGeneratedPassword(passwordField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the parent that we are ignoring the password edit
|
||||||
|
* so that tests can listen for this as opposed to waiting for
|
||||||
|
* nothing to happen.
|
||||||
|
*/
|
||||||
|
_ignorePasswordEdit() {
|
||||||
|
if (Cu.isInAutomation) {
|
||||||
|
this.sendAsyncMessage("PasswordManager:onIgnorePasswordEdit", {});
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Notify the parent that a generated password was filled into a field or
|
* Notify the parent that a generated password was filled into a field or
|
||||||
* edited so that it can potentially be saved.
|
* edited so that it can potentially be saved.
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,15 @@ class LoginManagerParent extends JSWindowActorParent {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "PasswordManager:onIgnorePasswordEdit": {
|
||||||
|
log("Received PasswordManager:onIgnorePasswordEdit");
|
||||||
|
if (gListenerForTests) {
|
||||||
|
log("calling gListenerForTests");
|
||||||
|
gListenerForTests("PasswordIgnoreEdit", {});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "PasswordManager:autoCompleteLogins": {
|
case "PasswordManager:autoCompleteLogins": {
|
||||||
return this.doAutocompleteSearch(context.origin, data);
|
return this.doAutocompleteSearch(context.origin, data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,6 @@ support-files =
|
||||||
[browser_doorhanger_dismissed_for_ccnumber.js]
|
[browser_doorhanger_dismissed_for_ccnumber.js]
|
||||||
[browser_doorhanger_empty_password.js]
|
[browser_doorhanger_empty_password.js]
|
||||||
[browser_doorhanger_form_password_edit.js]
|
[browser_doorhanger_form_password_edit.js]
|
||||||
skip-if =
|
|
||||||
fission && os == "mac" && !debug # Bug 1713910 - new Fission platform triage
|
|
||||||
[browser_doorhanger_generated_password.js]
|
[browser_doorhanger_generated_password.js]
|
||||||
support-files =
|
support-files =
|
||||||
form_basic_with_confirm_field.html
|
form_basic_with_confirm_field.html
|
||||||
|
|
|
||||||
|
|
@ -377,17 +377,6 @@ for (let testData of testCases) {
|
||||||
add_task(tmp[testData.name]);
|
add_task(tmp[testData.name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForPromise(promise, timeoutMs = 5000) {
|
|
||||||
let timedOut = new Promise((resolve, reject) => {
|
|
||||||
/* eslint-disable-next-line mozilla/no-arbitrary-setTimeout */
|
|
||||||
let timerId = setTimeout(() => {
|
|
||||||
clearTimeout(timerId);
|
|
||||||
reject(`Timed out in ${timeoutMs} ms.`);
|
|
||||||
}, timeoutMs);
|
|
||||||
});
|
|
||||||
await Promise.race([promise, timedOut]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testPasswordChange(
|
async function testPasswordChange(
|
||||||
{
|
{
|
||||||
logins = [],
|
logins = [],
|
||||||
|
|
@ -427,23 +416,23 @@ async function testPasswordChange(
|
||||||
await checkForm(browser, expected.initialForm);
|
await checkForm(browser, expected.initialForm);
|
||||||
info("form checked");
|
info("form checked");
|
||||||
|
|
||||||
let passwordEditedMessage = listenForTestNotification(
|
// A message is still sent to the parent process when Primary Password is enabled
|
||||||
"PasswordEditedOrGenerated"
|
let notificationMessage =
|
||||||
|
expected.doorhanger || !isLoggedIn
|
||||||
|
? "PasswordEditedOrGenerated"
|
||||||
|
: "PasswordIgnoreEdit";
|
||||||
|
let passwordTestNotification = listenForTestNotification(
|
||||||
|
notificationMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
await changeContentFormValues(browser, formChanges, shouldBlur);
|
await changeContentFormValues(browser, formChanges, shouldBlur);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"form edited, waiting for test notification of PasswordEditedOrGenerated"
|
`form edited, waiting for test notification of ${notificationMessage}`
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
await passwordTestNotification;
|
||||||
await waitForPromise(passwordEditedMessage, 5000);
|
info("Resolved passwordTestNotification promise");
|
||||||
// A message is still sent to the parent process when Primary Password is enabled
|
|
||||||
ok(expected.doorhanger || !isLoggedIn, "Message sent");
|
|
||||||
} catch (ex) {
|
|
||||||
ok(!expected.doorhanger, "No message sent");
|
|
||||||
}
|
|
||||||
info("Resolved listenForTestNotification promise");
|
|
||||||
|
|
||||||
if (!expected.doorhanger) {
|
if (!expected.doorhanger) {
|
||||||
let notif;
|
let notif;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue