summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_submitevent_on_form.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/events/test/test_submitevent_on_form.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/test/test_submitevent_on_form.html')
-rw-r--r--dom/events/test/test_submitevent_on_form.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/dom/events/test/test_submitevent_on_form.html b/dom/events/test/test_submitevent_on_form.html
new file mode 100644
index 0000000000..3bd13942a1
--- /dev/null
+++ b/dom/events/test/test_submitevent_on_form.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test submit event on form</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+ <form action="javascript:doDefault()" id="form">
+ <input type="submit" value="Do Default Action">
+ </form>
+ <pre id="test">
+ <script type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(runTests);
+
+var doDefaultAction = false;
+
+function doDefault()
+{
+ doDefaultAction = true;
+}
+
+async function runTests()
+{
+ await SpecialPowers.pushPrefEnv({
+ set: [["dom.forms.submit.trusted_event_only", true]],
+ });
+
+ let form = document.getElementById("form");
+ form.dispatchEvent(new Event('submit'));
+ setTimeout(() => {
+ ok(!doDefaultAction, "untrusted submit event shouldn't trigger form default action");
+ SimpleTest.finish();
+ });
+}
+ </script>
+ </pre>
+</body>
+</html>