tor-browser

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

update-the-rendering-resize-autofocus.html (1301B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <link rel="help" href="https://html.spec.whatwg.org/#event-loop-processing-model">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 let t = async_test("resize steps happen after autofocus, but before animation callbacks");
      8 let resized = false;
      9 let resizedOnRAF = false;
     10 
     11 let runTest = t.step_func(function() {
     12  requestAnimationFrame(t.step_func(function() {
     13    resizedOnRAF = resized;
     14    requestAnimationFrame(t.step_func_done(function() {
     15      assert_true(!resized || resizedOnRAF, "If resize happened, it happened before animation callbacks");
     16    }));
     17  }));
     18 
     19  // Resize the frame. The callback should happen before the next RAF.
     20  let frame = document.getElementById("frame");
     21  frame.contentDocument.documentElement.getBoundingClientRect();
     22  frame.contentWindow.stop(); // Prevent async about:blank load.
     23  frame.contentWindow.addEventListener("resize", t.step_func(function() {
     24    resized = true;
     25  }), { once: true });
     26  frame.style.width = "600px";
     27  frame.contentDocument.documentElement.getBoundingClientRect();
     28  assert_false(resized, "Resize event shouldn't fire sync");
     29 });
     30 </script>
     31 <iframe id="frame" width="300" height="300"></iframe>
     32 <input autofocus onfocus="runTest()">