tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

callback-timeout.html (1342B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>requestIdleCallback timeout callback must be called with didTimeout equal to true</title>
      4 <meta name="timeout" content="long">
      5 <script src=/resources/testharness.js></script>
      6 <script src=/resources/testharnessreport.js></script>
      7 <div id="log"></div>
      8 <script>
      9  async_test(function (t) {
     10    assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
     11    var counter = 0;
     12 
     13    function g(deadline) {
     14      assert_true(deadline.didTimeout)
     15      t.done();
     16    }
     17 
     18    function f(deadline) {
     19      assert_false(deadline.didTimeout);
     20      window.requestIdleCallback(t.step_func(g), {timeout:300});
     21 
     22      var d = Date.now() + 500;
     23      while (Date.now() < d) {
     24 
     25      }
     26    }
     27    window.requestIdleCallback(t.step_func(f));
     28  }, "requestIdleCallback callback should time out");
     29 
     30  async_test(function (t) {
     31    assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
     32    function g(deadline) {
     33      assert_false(deadline.didTimeout)
     34      t.done();
     35    }
     36 
     37    function f(deadline) {
     38      assert_false(deadline.didTimeout);
     39      window.requestIdleCallback(t.step_func(g), {timeout:100000});
     40    }
     41    window.requestIdleCallback(t.step_func(f));
     42  }, "requestIdleCallback callback should not time out");
     43 
     44 </script>