tor-browser

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

LinkStyle.html (4616B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title>HTML Test: Styling</title>
      6    <link rel="author" title="Intel" href="http://www.intel.com/">
      7    <link rel="help" href="https://html.spec.whatwg.org/multipage/#styling">
      8    <link id="style1" rel="text" title="Intel" href="./support/unmatch.css">
      9    <link id="style2" rel="alternate stylesheet" type="text/css" title="" href="./support/emptytitle.css">
     10    <link id="style3" rel="alternate stylesheet" type="text/css" href="./support/notitle.css">
     11    <link id="style5" rel="stylesheet" type="text/css" href="./support/normal.css">
     12    <link id="style6" rel="alternate stylesheet" type="text/css" href="./support/normal.css" title="./support/alternate.css">
     13    <script src="/resources/testharness.js"></script>
     14    <script src="/resources/testharnessreport.js"></script>
     15    <style id="style4" type="text/html">
     16      #test {
     17        height: 100px;
     18        width: 100px;
     19      }
     20    </style>
     21    <style id="style7" type="text/css" media="all" title="./support/alternate.css">
     22      #test {
     23        background-color: green;
     24      }
     25    </style>
     26  </head>
     27  <body>
     28    <div id="log"></div>
     29    <div id="test" style="display:none">STYLING TEST</div>
     30 
     31    <script>
     32      /**
     33       * Browsers may incorrectly issue requests for these resources and defer
     34       * definition of the `sheet` attribute until after loading is complete.
     35       * In such cases, synchronous assertions regarding the absence of
     36       * attributes will spuriously pass.
     37       *
     38       * In order to account for this incorrect behavior (exhibited at the time
     39       * of this writing most notably by the Chromium browser), defer the
     40       * assertions until the "load" event has been triggered.
     41       */
     42      async_test(function(t) {
     43        window.addEventListener("load", t.step_func(function() {
     44          var style = null,
     45              i;
     46          for (i = 1; i < 5; i++) {
     47            style = document.getElementById("style" + i);
     48            assert_equals(style.sheet, null, "The sheet attribute of style" + i + " should be null.");
     49            assert_false(style.disabled, "The disabled attribute of style" + i + " should be false.");
     50          }
     51          t.done();
     52        }));
     53      }, "The LinkStyle interface's sheet attribute must return null; the disabled attribute must be false");
     54 
     55      test(function() {
     56        var style = document.createElement("style"),
     57            link = document.createElement("link");
     58        assert_equals(style.sheet, null, "The sheet attribute of the style element not in a document should be null.");
     59        assert_equals(link.sheet, null, "The sheet attribute of the link element not in a document should be null.");
     60      }, "The LinkStyle interface's sheet attribute must return null if the corresponding element is not in a Document");
     61 
     62      async_test(function(t) {
     63        window.addEventListener("load", t.step_func(function() {
     64          var style = null,
     65              i;
     66          for (i = 5; i < 8; i++) {
     67            style = document.getElementById("style" + i);
     68            assert_true(style.sheet instanceof StyleSheet, "The sheet attribute of style" + i + " should be a StyleSheet object.");
     69            assert_equals(style.disabled, style.sheet.disabled, "The disabled attribute of style" + i + " should equal to the same attribute of StyleSheet.");
     70          }
     71          t.done();
     72        }));
     73      }, "The LinkStyle interface's sheet attribute must return StyleSheet object; the disabled attribute must be same as the StyleSheet's disabled attribute");
     74 
     75      test(function() {
     76        assert_equals(document.getElementById("style2").title, "", "The title attribute of style2 is incorrect.");
     77        assert_equals(document.getElementById("style5").title, "", "The title attribute of style5 is incorrect.");
     78        assert_equals(document.getElementById("style6").title, "./support/alternate.css", "The title attribute of style6 is incorrect.");
     79        assert_equals(document.getElementById("style7").title, "./support/alternate.css", "The title attribute of style7 is incorrect.");
     80      }, "The title must be the same as the value of the element's title content attribute");
     81 
     82      test(function() {
     83        assert_equals(document.getElementById("style5").media, "", "The media attribute of style5 is incorrect.");
     84        assert_equals(document.getElementById("style7").media, "all", "The media attribute of style7 is incorrect.");
     85      }, "The media must be the same as the value of the element's media content attribute, or the empty string if it is omitted");
     86    </script>
     87  </body>
     88 </html>