tor-browser

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

viewport-units-after-font-load.html (2062B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSS Values: Viewport units are computed correctly after font load.</title>
      4 <link rel="author"  title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      5 <link rel="author"  title="Mozilla" href="https://mozilla.org">
      6 <link rel="help" href="https://www.w3.org/TR/css-values-3/#viewport-relative-lengths">
      7 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1620359">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <iframe width=300 height=300 scrolling=no srcdoc=""></iframe>
     11 <script>
     12 let t = async_test("Viewport units are correctly updated after resize even if a font load has happened before");
     13 let iframe = document.querySelector("iframe");
     14 onload = t.step_func(function() {
     15  let doc = iframe.contentDocument;
     16  let win = iframe.contentWindow;
     17  doc.body.innerHTML = `
     18    <div style="width: 100vw; height: 100vh; background: green"></div>
     19  `;
     20  let div = doc.querySelector("div");
     21  let oldWidth = win.getComputedStyle(div).width;
     22  let oldHeight = win.getComputedStyle(div).height;
     23  assert_equals(oldWidth, win.innerWidth + "px", "Should fill the viewport");
     24  assert_equals(oldHeight, win.innerHeight + "px", "Should fill the viewport");
     25  let link = doc.createElement("link");
     26  link.rel = "stylesheet";
     27  link.href = "/fonts/ahem.css";
     28  link.onload = t.step_func(function() {
     29    iframe.width = 400;
     30    win.requestAnimationFrame(t.step_func(function() {
     31      win.requestAnimationFrame(t.step_func_done(function() {
     32        let newWidth = win.getComputedStyle(div).width;
     33        let newHeight = win.getComputedStyle(div).height;
     34        assert_equals(newWidth, win.innerWidth + "px", "Should fill the viewport");
     35        assert_equals(newHeight, win.innerHeight + "px", "Should fill the viewport");
     36        assert_equals(newHeight, oldHeight, "Height shouldn't have changed");
     37        assert_not_equals(newWidth, oldWidth, "Width should have changed");
     38      }));
     39    }));
     40  });
     41  doc.body.appendChild(link);
     42 });
     43 </script>