tor-browser

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

loaf-user-callback.html (2278B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Long Animation Frame Timing: basic</title>
      4 <meta name="timeout" content="long">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 <h1>Long Animation Frame: user callbacks</h1>
     11 <div id="log"></div>
     12 <script>
     13 
     14 test_self_user_callback((t, busy_wait) =>
     15    t.step_timeout(() => busy_wait()), "TimerHandler:setTimeout");
     16 
     17 test_self_user_callback((t, busy_wait) => {
     18    const interval = setInterval(() => {
     19        busy_wait();
     20        clearInterval(interval);
     21    }, 10);
     22 }, "TimerHandler:setInterval");
     23 test_self_user_callback((t, busy_wait) =>
     24    requestAnimationFrame(() => busy_wait()), "FrameRequestCallback");
     25 
     26 test_self_user_callback((t, busy_wait) => {
     27    const element = document.createElement("div");
     28        document.body.appendChild(element);
     29        t.add_cleanup(() => element.remove());
     30        new ResizeObserver((entries, observer) => {
     31            busy_wait(very_long_frame_duration);
     32            observer.disconnect();
     33        }).observe(element);
     34 }, "ResizeObserverCallback");
     35 
     36 test_self_user_callback((t, busy_wait) => {
     37    const element = document.createElement("div");
     38    element.innerText = "123";
     39    t.add_cleanup(() => element.remove());
     40    new IntersectionObserver((entries, observer) => {
     41        busy_wait(very_long_frame_duration);
     42        observer.disconnect();
     43    }).observe(element);
     44    document.body.appendChild(element);
     45 }, "IntersectionObserverCallback");
     46 
     47 test_self_user_callback((t, busy_wait) =>
     48    scheduler.postTask(() => busy_wait()), "SchedulerPostTaskCallback");
     49 
     50  test_self_user_callback((t, busy_wait) => {
     51    new PerformanceObserver(() => busy_wait()).observe(
     52      {type: "navigation", buffered: true});
     53 }, "PerformanceObserverCallback");
     54 
     55 test_self_user_callback((t, busy_wait) =>
     56    requestIdleCallback(() => busy_wait()), "IdleRequestCallback");
     57 
     58 test_self_user_callback((t, busy_wait) => {
     59    requestIdleCallback(() => busy_wait(), {timeout: 10});
     60    t.step_timeout(() => {
     61        const deadline = performance.now() + 15;
     62        while (performance.now() < deadline) {}
     63    });
     64 }, "IdleRequestCallback",
     65    "requestIdleCallback with timeout");
     66 </script>
     67 </body>