summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/test_autocomplete_with_composition_on_input.html
blob: d906a96b49b4282cc25a3d027bfc61bea2eea467 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>autocomplete with composition tests on HTML input element</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="file_autocomplete_with_composition.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>

<div id="content">
  <iframe id="formTarget" name="formTarget"></iframe>
  <form action="data:text/html," target="formTarget">
    <input name="test" id="input"><input type="submit">
  </form>
</div>

<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();

function runTests() {
  var formFillController =
    SpecialPowers.getFormFillController()
                 .QueryInterface(Ci.nsIAutoCompleteInput);
  var originalFormFillTimeout = formFillController.timeout;

  SpecialPowers.attachFormFillControllerTo(window);
  var target = document.getElementById("input");

  // Register a word to the form history.
  let chromeScript = SpecialPowers.loadChromeScript(function addEntry() {
    /* eslint-env mozilla/chrome-script */
    let {FormHistory} = ChromeUtils.import("resource://gre/modules/FormHistory.jsm");
    FormHistory.update({ op: "add", fieldname: "test", value: "Mozilla" });
  });
  chromeScript.destroy();
  target.focus();

  new nsDoTestsForAutoCompleteWithComposition(
    "Testing on HTML input (asynchronously search)",
    window, target, formFillController.controller, is,
    function() { return target.value; },
    function() {
      target.setAttribute("timeout", 0);
      new nsDoTestsForAutoCompleteWithComposition(
        "Testing on HTML input (synchronously search)",
        window, target, formFillController.controller, is,
        function() { return target.value; },
        function() {
          formFillController.timeout = originalFormFillTimeout;
          SpecialPowers.detachFormFillControllerFrom(window);
          SimpleTest.finish();
        });
    });
}

SimpleTest.waitForFocus(runTests);

</script>
</pre>
</body>
</html>