tor-browser

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

medialist-interfaces-004.html (2323B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <title>CSS Test: CSSOM MediaList Interfaces</title>
      5  <link rel="author" title="Chapman Shoop" href="mailto:chapman.shoop@gmail.com">
      6  <link rel="help" href="http://www.w3.org/TR/cssom-1/#the-medialist-interface">
      7  <meta name="flags" content="dom">
      8  <meta name="assert" content="MediaList object has appendMedium method and it functions properly.">
      9  <script src="/resources/testharness.js" type="text/javascript"></script>
     10  <script src="/resources/testharnessreport.js" type="text/javascript"></script>
     11 </head>
     12 
     13 <body>
     14  <noscript>Test not run - javascript required.</noscript>
     15  <div id="log"></div>
     16 
     17  <script type="text/javascript">
     18    function setup() {
     19      // Clean out any old style element
     20      var old_style_el = document.getElementById('test_style');
     21      if (old_style_el) {
     22        document.head.removeChild(old_style_el);
     23      }
     24 
     25      // Create a fresh style element and return its media attribute
     26      var style_el = document.createElement('style');
     27      style_el.setAttribute('id', 'test_style');
     28      document.head.appendChild(style_el);
     29      return style_el.sheet.media;
     30    }
     31  </script>
     32 
     33  <script type="text/javascript">
     34 
     35    // MediaList.appendMedium correctly adds medium to empty MediaList.
     36    test(function() {
     37      media_list = setup();
     38 
     39      media_list.appendMedium("all");
     40 
     41      assert_equals(media_list.length, 1);
     42      assert_equals(media_list.item(0), "all");
     43      assert_equals(media_list.mediaText, "all");
     44    }, "appendMedium_correctly_appends_medium_to_empty_MediaList");
     45 
     46    // MediaList.appendMedium correctly adds medium to a MediaList that already has a medium.
     47    test(function() {
     48      media_list = setup();
     49 
     50      media_list.appendMedium("screen");
     51      media_list.appendMedium("all");
     52 
     53      // The ordering of array items should be different from that of the mediaText element.
     54      // "all" should be appended after "screen" in the array, but "mediaText" should be
     55      // "all, screen" due to lexicographical sorting.
     56      assert_equals(media_list.length, 2);
     57      assert_equals(media_list.item(0), "screen");
     58      assert_equals(media_list.item(1), "all");
     59      assert_equals(media_list.mediaText, "screen, all");
     60    }, "appendMedium_correctly_appends_medium_to_nonempty_MediaList");
     61 
     62  </script>
     63 </body>
     64 </html>