tor-browser

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

container-units-media-queries.html (1691B)


      1 <!DOCTYPE html>
      2 <title>Container-relative units in @media</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="support/cq-testcommon.js"></script>
      7 
      8 <style>
      9  iframe {
     10    width: 200px;
     11    height: 100px;
     12  }
     13 </style>
     14 
     15 <iframe id=iframe></iframe>
     16 
     17 <script>
     18 setup(() => assert_implements_size_container_queries());
     19 
     20 const doc = iframe.contentDocument;
     21 const win = iframe.contentWindow;
     22 
     23 function test_media_query(feature, result, description) {
     24  test((t) => {
     25    t.add_cleanup(() => { doc.body.innerHTML = ''; })
     26    doc.body.innerHTML = `
     27      <style>
     28        body {
     29          color: red;
     30        }
     31        @media (${feature}) {
     32          body {
     33            color: green;
     34          }
     35        }
     36      </style>
     37      `;
     38    assert_equals(win.getComputedStyle(doc.body).color, result);
     39  }, description);
     40 }
     41 
     42 function test_media_query_applies(feature) {
     43  test_media_query(feature, 'rgb(0, 128, 0)', `@media(${feature}) applies`);
     44 }
     45 
     46 function test_media_query_does_not_apply(feature) {
     47  test_media_query(feature, 'rgb(255, 0, 0)', `@media(${feature}) does not apply`);
     48 }
     49 
     50 // Container-relative units resolve against the "small viewport size" for
     51 // media queries.
     52 test_media_query_applies('width:100cqw');
     53 test_media_query_applies('width:100cqi');
     54 test_media_query_applies('width:100cqmax');
     55 test_media_query_applies('height:100cqh');
     56 test_media_query_applies('height:100cqb');
     57 test_media_query_applies('height:100cqmin');
     58 test_media_query_does_not_apply('width:90cqw');
     59 test_media_query_does_not_apply('height:90cqh');
     60 
     61 </script>