summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html
blob: e2240474c8ed740c03e1202c561445489eff2aec (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
65
66
67
68
69
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test basic autofill</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="formautofill_common.js"></script>
  <script type="text/javascript" src="satchel_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
Form autofill test: autocomplete on an autofocus form

<script>
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */

"use strict";

let MOCK_STORAGE = [{
  organization: "Sesame Street",
  "street-address": "123 Sesame Street.",
  tel: "1-345-345-3456",
}, {
  organization: "Mozilla",
  "street-address": "331 E. Evelyn Avenue",
  tel: "1-650-903-0800",
}];

initPopupListener();

async function setupAddressStorage() {
  await addAddress(MOCK_STORAGE[0]);
  await addAddress(MOCK_STORAGE[1]);
}

add_task(async function check_autocomplete_on_autofocus_field() {
  await setupAddressStorage();
  synthesizeKey("KEY_ArrowDown");
  await expectPopup();
  checkMenuEntries(MOCK_STORAGE.map(address =>
    JSON.stringify({primary: address.organization, secondary: address["street-address"]})
  ));
});

</script>

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

<div id="content">

  <form id="form1">
    <p>This is a basic form.</p>
    <p><label>organization: <input id="organization" name="organization" autocomplete="organization" type="text"></label></p>
    <script>
      "use strict";
      // Focuses the input before DOMContentLoaded
      document.getElementById("organization").focus();
    </script>
    <p><label>streetAddress: <input id="street-address" name="street-address" autocomplete="street-address" type="text"></label></p>
    <p><label>tel: <input id="tel" name="tel" autocomplete="tel" type="text"></label></p>
    <p><label>country: <input id="country" name="country" autocomplete="country" type="text"></label></p>
  </form>

</div>

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