tor-browser

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

test_root_node_display.html (2922B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=969460
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 969460</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script type="text/javascript" src="property_database.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=969460">Mozilla Bug 969460</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17  <div id="float" style="float: left"></div>
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 
     22 /**
     23 * Test for Bug 969460: Test that "display" on the root node is computed
     24 * using the same conversion that we use for display on floated elements.
     25 */
     26 
     27 function test_display_value(val)
     28 {
     29  var floatElem = document.getElementById("float");
     30  floatElem.style.display = val;
     31  var floatConversion = window.getComputedStyle(floatElem).display;
     32  floatElem.style.display = "";
     33 
     34  var rootNode = document.documentElement;
     35  rootNode.style.display = val;
     36  rootNode.offsetHeight; // (Flush layout, to be sure layout can handle 'val')
     37  var rootConversion = window.getComputedStyle(rootNode).display;
     38  rootNode.style.display = "";
     39 
     40  // Special case: "display:list-item" does not get modified by 'float',
     41  // but the spec allows us to convert it to 'block' on the root node
     42  // (and we do convert it, so that we don't have to support documents whose
     43  // root node is a list-item).
     44  if (val == "list-item") {
     45    is(floatConversion, val, "'float' shouldn't affect 'display:list-item'");
     46    is(rootConversion, "block",
     47       "We traditionally convert '" + val + "' on the root node to " +
     48       "'display:block' (though if that changes, it's not technically a bug, " +
     49       "as long as we support it properly).");
     50 } else if (val == "inline list-item" ||
     51           val == "inline flow-root list-item") {
     52    is(floatConversion, "list-item", "'float' should blockify '" + val + "'");
     53    is(rootConversion, "block",
     54       "We traditionally convert '" + val + "' on the root node to " +
     55       "'display:block' (though if that changes, it's not technically a bug, " +
     56       "as long as we support it properly).");
     57  } else if (val == "contents") {
     58    is(floatConversion, val, "'float' shouldn't affect 'display:contents'");
     59    is(rootConversion, "block",
     60       "'display:contents' on the root node computes to block-level per" +
     61       "http://dev.w3.org/csswg/css-display/#transformations");
     62  } else {
     63    is(rootConversion, floatConversion,
     64       "root node should make 'display:" + val + "' compute to the same " +
     65       "value that it computes to on a floated element");
     66  }
     67 }
     68 
     69 var displayInfo = gCSSProperties.display;
     70 displayInfo.initial_values.forEach(test_display_value);
     71 displayInfo.other_values.forEach(test_display_value);
     72 
     73 </script>
     74 </pre>
     75 </body>
     76 </html>