summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_autofill_hasBeenTypePassword.html
blob: 2139d30e61ce987dce3f1f292b415d2a7c9f6366 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test no autofill into a password field that is no longer type=password</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="pwmgr_common.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
Login Manager test: Test no autofill into a password field that is no longer type=password

<script>
let DEFAULT_ORIGIN = window.location.origin;

/** Test for Login Manager: Test no autofill into a password field that is no longer type=password **/

add_setup(async () => {
  await setStoredLoginsAsync(
    [DEFAULT_ORIGIN, "https://autofill", null, "user1", "pass1"]
  );
});


// As a control, test that autofill is working on this page.
add_task(async function test_autofill_control() {
  let win = window.open("about:blank");
  SimpleTest.registerCleanupFunction(() => win.close());
  await loadFormIntoWindow(DEFAULT_ORIGIN, `
    <form id="form1" action="https://autofill">
      <p>This is form 1.</p>
      <input id="username-1" type="text"       name="uname">
      <input id="password-1" type="password"   name="pword">

      <button type="submit">Submit</button>
    </form>`, win);
  await checkLoginFormInFrame(win, "username-1", "user1", "password-1", "pass1");
});

add_task(async function test_no_autofill() {
  let win = window.open("about:blank");
  SimpleTest.registerCleanupFunction(() => win.close());
  // Synchronously change the password field type to text before the fill happens.
  await loadFormIntoWindow(DEFAULT_ORIGIN, `
    <form id="form1" action="https://autofill">
      <p>This is form 1.</p>
      <input id="username-1" type="text"       name="uname">
      <input id="password-1" type="password"   name="pword">

      <button type="submit">Submit</button>
    </form>`, win, 1, () => {
      this.content.document.getElementById("password-1").type = "text";
    });
  await checkLoginFormInFrame(win, "username-1", "", "password-1", "");
});
</script>

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

<div id="content"></div>

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