summaryrefslogtreecommitdiffstats
path: root/dom/base/test/browser_form_validity_popup_submit.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/base/test/browser_form_validity_popup_submit.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/browser_form_validity_popup_submit.js')
-rw-r--r--dom/base/test/browser_form_validity_popup_submit.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/dom/base/test/browser_form_validity_popup_submit.js b/dom/base/test/browser_form_validity_popup_submit.js
new file mode 100644
index 0000000000..2cefbf9d98
--- /dev/null
+++ b/dom/base/test/browser_form_validity_popup_submit.js
@@ -0,0 +1,55 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+"use strict";
+
+async function promiseValidityPopupShown() {
+ await BrowserTestUtils.waitForEvent(
+ window,
+ "popupshown",
+ /* capture = */ false,
+ event => event.target.id == "invalid-form-popup"
+ );
+ return document.getElementById("invalid-form-popup");
+}
+
+const HTML = `
+ <form action="">
+ <input name="text" type="text" placeholder="type here" autofocus required>
+ <input id="submit" type="submit">
+ </form>
+`;
+
+add_task(async function bug_1790128() {
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: `data:text/html,${encodeURI(HTML)}`,
+ },
+ async function (aBrowser) {
+ let promisePopupShown = promiseValidityPopupShown();
+ await BrowserTestUtils.synthesizeMouseAtCenter("#submit", {}, aBrowser);
+ let popup = await promisePopupShown;
+ is(popup.state, "open", "Should be open");
+
+ let promisePopupHidden = BrowserTestUtils.waitForEvent(
+ popup,
+ "popuphidden"
+ );
+ promisePopupShown = promiseValidityPopupShown();
+
+ // This is written in a rather odd style because depending on whether
+ // panel animations are enabled we might be able to show the popup again
+ // after the first click or not. The point is that after one click the
+ // popup should've hid at least once, and after two the popup should've
+ // open again at least once.
+ await BrowserTestUtils.synthesizeMouseAtCenter("#submit", {}, aBrowser);
+ await promisePopupHidden;
+ await BrowserTestUtils.synthesizeMouseAtCenter("#submit", {}, aBrowser);
+ await promisePopupShown;
+ ok(true, "Should've shown the popup again");
+ }
+ );
+});