layout/style/test/test_root_node_display.html
author Byron Campen <docfaraday@gmail.com>
Mon, 20 Sep 2021 16:45:53 +0000
changeset 592504 20b482455364fc14118bd32de96ae52cc81c7f3a
parent 487950 bc6ca73b757eb8fe29e700629213be2908944079
permissions -rw-r--r--
Bug 1651268: Make sure the pre-run code for FindExpirationTime waits for timers to fire on all threads. r=xpcom-reviewers,nika Differential Revision: https://phabricator.services.mozilla.com/D125603

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=969460
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 969460</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="property_database.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=969460">Mozilla Bug 969460</a>
<p id="display"></p>
<div id="content" style="display: none">
  <div id="float" style="float: left"></div>
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 969460: Test that "display" on the root node is computed
    using the same conversion that we use for display on floated elements **/

function test_display_value(val)
{
  var floatElem = document.getElementById("float");
  floatElem.style.display = val;
  var floatConversion = window.getComputedStyle(floatElem).display;
  floatElem.style.display = "";

  var rootNode = document.documentElement;
  rootNode.style.display = val;
  rootNode.offsetHeight; // (Flush layout, to be sure layout can handle 'val')
  var rootConversion = window.getComputedStyle(rootNode).display;
  rootNode.style.display = "";

  // Special case: "display:list-item" does not get modified by 'float',
  // but the spec allows us to convert it to 'block' on the root node
  // (and we do convert it, so that we don't have to support documents whose
  // root node is a list-item).
  if (val == "list-item") {
    is(floatConversion, val, "'float' shouldn't affect 'display:list-item'");
    is(rootConversion, "block",
       "We traditionally convert '" + val + "' on the root node to " +
       "'display:block' (though if that changes, it's not technically a bug, " +
       "as long as we support it properly).");
} else if (val == "inline list-item" ||
           val == "inline flow-root list-item") {
    is(floatConversion, "list-item", "'float' should blockify '" + val + "'");
    is(rootConversion, "block",
       "We traditionally convert '" + val + "' on the root node to " +
       "'display:block' (though if that changes, it's not technically a bug, " +
       "as long as we support it properly).");
  } else if (val == "contents") {
    is(floatConversion, val, "'float' shouldn't affect 'display:contents'");
    is(rootConversion, "block",
       "'display:contents' on the root node computes to block-level per" +
       "http://dev.w3.org/csswg/css-display/#transformations");
  } else {
    is(rootConversion, floatConversion,
       "root node should make 'display:" + val + "' compute to the same " +
       "value that it computes to on a floated element");
  }
}

var displayInfo = gCSSProperties.display;
displayInfo.initial_values.forEach(test_display_value);
displayInfo.other_values.forEach(test_display_value);

</script>
</pre>
</body>
</html>