summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_nested_event_loop_spin_and_idle_tasks.html
blob: 940e22527cf999b7695634b0d02a57690605f5fe (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Nested event loop spinning and idle task handling</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <script>
    if (!location.search.includes("newpage")) {
      SimpleTest.waitForExplicitFinish();
      var win = window.open(this.location + "?newpage");
      win.onload = function() {
        var xhr = new XMLHttpRequest();
        // Spin the event loop using a synchronous XMLHttpRequest.
        xhr.open("GET", "slow.sjs", false);
        xhr.send();
        ok(win.didRunIdleCallback, "Should have run an idle callback.");
        win.close();
        SimpleTest.finish();
      }
    } else {
      var didRunIdleCallback = false;
      requestIdleCallback(function() {
        didRunIdleCallback = true;
      });
    }
  </script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>