summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_submitevent_on_form.html
blob: 3bd13942a167bcdd34a49627c82e09c0185e2a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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>