tor-browser

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

style_media_change.html (1397B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title>Dynamically changing HTMLStyleElement.media should change the rendering accordingly</title>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element">
      9    <style>
     10      span {
     11       color: red;
     12      }
     13    </style>
     14    <style id="text-style" media="none">
     15      span {
     16       color: green;
     17      }
     18    </style>
     19    <style id="body-style" media="aural">
     20      body {
     21       color: green;
     22      }
     23    </style>
     24  </head>
     25  <body>
     26    <span>text</span>
     27    <script>
     28      test(function() {
     29        var element = document.querySelector("span");
     30        assert_equals(getComputedStyle(element).color, "rgb(255, 0, 0)");
     31        document.getElementById("text-style").media = 'all';
     32        assert_equals(getComputedStyle(element).color, "rgb(0, 128, 0)");
     33      }, "change media value dynamically");
     34 
     35      test(function() {
     36        var style = document.getElementById("body-style");
     37        assert_not_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
     38        style.removeAttribute("media");
     39        assert_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
     40      }, "removing media attribute");
     41    </script>
     42  </body>
     43 </html>