tor-browser

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

mq-dynamic-empty-children.html (1460B)


      1 <!doctype html>
      2 <title>Dynamic evaluation of media queries works fine in presence of empty media rule</title>
      3 <link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
      4 <link rel="author" href="https://mozilla.org" title="Mozilla">
      5 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1669600">
      6 <link rel="help" href="https://drafts.csswg.org/mediaqueries-4/">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <iframe width=500 height=300 frameborder=0></iframe>
     10 <script>
     11 let iframe = document.querySelector("iframe");
     12 promise_test(async function (t) {
     13  await new Promise(resolve => {
     14    window.addEventListener("load", resolve);
     15  });
     16  let frameLoaded = new Promise(resolve => {
     17    iframe.addEventListener("load", resolve);
     18  });
     19  iframe.srcdoc = `
     20    <style>
     21      :root { background-color: red; }
     22      /* This one should never apply */
     23      @media (min-width: 1500px) {}
     24      /* This one should change and start matching */
     25      @media (max-width: 400px) {
     26        :root { background-color: lime; }
     27      }
     28    </style>
     29  `;
     30  await frameLoaded;
     31 
     32  function getColor() {
     33    return iframe.contentWindow.getComputedStyle(iframe.contentDocument.documentElement).backgroundColor;
     34  }
     35 
     36  assert_equals(getColor(), "rgb(255, 0, 0)", "Should start red");
     37  iframe.width = 400;
     38  assert_equals(getColor(), "rgb(0, 255, 0)", "Should turn green");
     39 });
     40 </script>