Bug 1850295 - Fix two more mochitests that were relying on previous behavior.

The browser test actually needs keyboard input + blur. The mochitest is
trickier due to the select popup unfocusing the window.

MANUAL PUSH: orange fix-ups CLOSED TREE
This commit is contained in:
Emilio Cobos Álvarez 2024-01-16 15:14:33 +01:00
parent 2623897dbc
commit 1217633cd1
2 changed files with 10 additions and 2 deletions

View file

@ -767,13 +767,16 @@ add_task(async function test_combined_name_fields_error() {
let doc = win.document;
let givenNameField = doc.querySelector("#given-name");
info("mark the given name field as invalid");
givenNameField.value = "";
givenNameField.focus();
EventUtils.synthesizeKey("X", {}, win);
givenNameField.value = "";
givenNameField.blur();
ok(
givenNameField.matches(":user-invalid"),
"Check field is visually invalid"
);
givenNameField.focus();
let givenNameLabel = doc.querySelector("#given-name-container .label-text");
// Override pointer-events so that we can use elementFromPoint to know if
// the label text is visible.

View file

@ -32,7 +32,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605125
function checkPseudoClass(aElement, aExpected)
{
is(aElement.matches(":user-valid"), aExpected,
"matches(':user-valid') should return " + aExpected + " for " + aElement);
"matches(':user-valid') should return " + aExpected + " for " + aElement.outerHTML);
}
function checkElement(aElement)
@ -96,6 +96,11 @@ function checkSelectElement(aElement)
{
checkPseudoClass(aElement, false);
if (!aElement.multiple && navigator.platform.startsWith("Mac")) {
// Arrow key on macOS opens the popup.
return;
}
// Focusing while :user-valid doesn't apply,
// the pseudo-class should not apply while changing selection.
aElement.focus();