Bug 1726621 - ensure form validation popup always hides on tabswitches, navigations, etc., r=NeilDeakin

Differential Revision: https://phabricator.services.mozilla.com/D124268
This commit is contained in:
Gijs Kruitbosch 2021-09-22 10:12:24 +00:00
Родитель 63398f93a9
Коммит 73d64dd98b
6 изменённых файлов: 12 добавлений и 47 удалений

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

@ -15,7 +15,6 @@ class FormValidationParent extends JSWindowActorParent {
super();
this._panel = null;
this._anchor = null;
}
/*
@ -24,7 +23,6 @@ class FormValidationParent extends JSWindowActorParent {
uninit() {
this._panel = null;
this._anchor = null;
}
hidePopup() {
@ -86,8 +84,6 @@ class FormValidationParent extends JSWindowActorParent {
tabBrowser.selectedBrowser.removeEventListener("TextZoomChange", this);
this._panel = null;
this._anchor.hidden = true;
this._anchor = null;
}
/*
@ -109,8 +105,6 @@ class FormValidationParent extends JSWindowActorParent {
let window = browser.ownerGlobal;
let tabBrowser = window.gBrowser;
this._anchor = tabBrowser.selectedBrowser.popupAnchor;
this._anchor.hidden = false;
// Display the panel if it isn't already visible.
if (!previouslyShown) {
@ -141,9 +135,7 @@ class FormValidationParent extends JSWindowActorParent {
* above if visible.
*/
_hidePopup() {
if (this._panel) {
this._panel.hidePopup();
}
this._panel?.hidePopup();
}
_getAndMaybeCreatePanel() {

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

@ -5418,7 +5418,7 @@ var XULBrowserWindow = {
let closeOpenPanels = selector => {
for (let panel of document.querySelectorAll(selector)) {
if (panel.state == "open") {
if (panel.state != "closed") {
panel.hidePopup();
}
}

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

@ -161,7 +161,7 @@
<html:template id="invalidFormTemplate">
<!-- for invalid form error message -->
<panel id="invalid-form-popup" type="arrow" orient="vertical" noautofocus="true" level="parent">
<panel id="invalid-form-popup" type="arrow" orient="vertical" noautofocus="true" level="parent" locationspecific="true">
<description/>
</panel>
</html:template>

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

@ -490,7 +490,8 @@ add_task(async function test_changeUPLoginOnUPForm_remove() {
Services.logins.addLogin(login1);
await testSubmittingLoginForm("subtst_notifications_8.html", async function(
fieldValues
fieldValues,
browser
) {
is(fieldValues.username, "notifyu1", "Checking submitted username");
is(fieldValues.password, "pass2", "Checking submitted password");
@ -501,17 +502,13 @@ add_task(async function test_changeUPLoginOnUPForm_remove() {
await checkDoorhangerUsernamePassword("notifyu1", "pass2");
clickDoorhangerButton(notif, REMOVE_LOGIN_MENUITEM);
});
// Let the hint hide itself
const forceClosePopup = false;
// Make sure confirmation hint was shown
info("waiting for verifyConfirmationHint");
await verifyConfirmationHint(
gBrowser.selectedBrowser,
forceClosePopup,
"identity-icon"
);
// Let the hint hide itself
const forceClosePopup = false;
// Make sure confirmation hint was shown
info("waiting for verifyConfirmationHint");
await verifyConfirmationHint(browser, forceClosePopup, "identity-icon");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 0, "Should have 0 logins");

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

@ -246,7 +246,7 @@ function testSubmittingLoginForm(
);
ok(true, "form submission loaded");
if (aTaskFn) {
await aTaskFn(fieldValues);
await aTaskFn(fieldValues, browser);
}
return fieldValues;
}

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

@ -395,30 +395,6 @@
return document.getElementById(this.getAttribute("datetimepicker"));
}
/**
* Provides a node to hang popups (such as the datetimepicker) from.
* If this <browser> isn't the descendant of a <stack>, null is returned
* instead and popup code must handle this case.
*/
get popupAnchor() {
let stack = this.closest("stack");
if (!stack) {
return null;
}
let popupAnchor = stack.querySelector(".popup-anchor");
if (popupAnchor) {
return popupAnchor;
}
// Create an anchor for the popup
popupAnchor = document.createElement("div");
popupAnchor.className = "popup-anchor";
popupAnchor.hidden = true;
stack.appendChild(popupAnchor);
return popupAnchor;
}
set suspendMediaWhenInactive(val) {
this.browsingContext.suspendMediaWhenInactive = val;
}