summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_form_action_javascript.html
blob: 3bb52ef8df052a79cf0a701f17e52764f4f1ac61 (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
42
43
44
45
46
47
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test forms with a JS submit action</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="pwmgr_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
Login Manager test: form with JS submit action
<script>
runChecksAfterCommonInit(() => startTest());

const origin = window.location.origin;

/** Test for Login Manager: JS action URL **/

async function startTest() {
  await addLoginsInParent(
    [origin, "javascript:", null, "jsuser", "jspass123", "uname", "pword"]
  );
  const win = window.open("about:blank");
  SimpleTest.registerCleanupFunction(() => win.close());
  await loadFormIntoWindow(origin, `
    <form id='form1' action='javascript:alert("never shows")'> 1
      <input name="uname">
      <input name="pword" type="password">

      <button type='submit'>Submit</button>
      <button type='reset'> Reset </button>
    </form>`, win);

  await checkLoginFormInFrameWithElementValues(win, 1, "jsuser", "jspass123");

  SimpleTest.finish();
}
</script>

<p id="display"></p>

<div id="content" style="display: none">
</div>

<pre id="test"></pre>
</body>
</html>