summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_input_vsync_alignment_input_while_vsync.html
blob: 6d1ac469febef1aa8f80d497232d54fa7999502a (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>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body >
<input />
<script type="text/javascript">
  SimpleTest.waitForExplicitFinish();

  function triggerKey() {
    SpecialPowers.loadChromeScript(() => {
      /* eslint-env mozilla/chrome-script */
      var win = Services.wm.getMostRecentBrowserWindow();
      for (let i = 0; i < 200; ++i) {
        EventUtils.synthesizeKey("a", {}, win);
      }
    });
  }

  function runTest() {
    const input = document.querySelector("input");
    input.focus();

    let didInputRun = false;

    input.addEventListener("input", function() {
      if (!didInputRun) {
        didInputRun = true;
        window.requestAnimationFrame(() => {
          var xhr = new XMLHttpRequest();
          xhr.open("GET", "slow.sjs", false);
          xhr.send();
          ok(true, "Didn't crash!");
          SimpleTest.finish();
        });
      }
    });

    triggerKey();
  }
  runTest();
</script>
</body>
</html>