test_position_float_display.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=1038929
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 1038929</title>
  9. <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  10. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  11. <script type="text/javascript" src="property_database.js"></script>
  12. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  13. </head>
  14. <body>
  15. <a target="_blank"
  16. href="https://bugzilla.mozilla.org/show_bug.cgi?id=1038929">Mozilla Bug 1038929</a>
  17. <p id="display"></p>
  18. <div id="content" style="display: none">
  19. <div id="float-left" style="float: left"></div>
  20. <div id="float-right" style="float: right"></div>
  21. <div id="position-absolute" style="position: absolute"></div>
  22. <div id="position-fixed" style="position: fixed"></div>
  23. </div>
  24. <pre id="test">
  25. <script type="application/javascript">
  26. /** Test for Bug 1038929: Test that "display" on a floated or absolutely/fixed
  27. position node is correctly converted to a block display as given in the table
  28. in CSS 2.1 9.7. */
  29. // Maps from display value to expected conversion when floated/positioned
  30. // This loosely follows the spec in CSS 2.1 section 9.7. Except for "other"
  31. // values which the spec says should be "same as specified." For these, we do
  32. // whatever the spec for the value itself says.
  33. var mapping = {
  34. "inline": "block",
  35. "table-row-group": "block",
  36. "table-column": "block",
  37. "table-column-group": "block",
  38. "table-header-group": "block",
  39. "table-footer-group": "block",
  40. "table-row": "block",
  41. "table-cell": "block",
  42. "table-caption": "block",
  43. "inline-block": "block",
  44. "ruby": "block",
  45. "ruby-base": "block",
  46. "ruby-base-container": "block",
  47. "ruby-text": "block",
  48. "ruby-text-container": "block",
  49. "flex": "flex",
  50. "grid": "grid",
  51. "none": "none",
  52. "table": "table",
  53. "inline-grid": "grid",
  54. "inline-flex": "flex",
  55. "inline-table": "table",
  56. "block": "block",
  57. "contents": "contents",
  58. // Note: this is sometimes block
  59. "list-item": "list-item"
  60. };
  61. function test_display_value(val)
  62. {
  63. var floatLeftElem = document.getElementById("float-left");
  64. floatLeftElem.style.display = val;
  65. var floatLeftConversion = window.getComputedStyle(floatLeftElem, null).display;
  66. floatLeftElem.style.display = "";
  67. var floatRightElem = document.getElementById("float-right");
  68. floatRightElem.style.display = val;
  69. var floatRightConversion = window.getComputedStyle(floatRightElem, null).display;
  70. floatRightElem.style.display = "";
  71. var posAbsoluteElem = document.getElementById("position-absolute");
  72. posAbsoluteElem.style.display = val;
  73. var posAbsoluteConversion = window.getComputedStyle(posAbsoluteElem, null).display;
  74. posAbsoluteElem.style.display = "";
  75. var posFixedElem = document.getElementById("position-fixed");
  76. posFixedElem.style.display = val;
  77. var posFixedConversion = window.getComputedStyle(posFixedElem, null).display;
  78. posFixedElem.style.display = "";
  79. if (mapping[val]) {
  80. is(floatLeftConversion, mapping[val],
  81. "Element display should be converted when floated left");
  82. is(floatRightConversion, mapping[val],
  83. "Element display should be converted when floated right");
  84. is(posAbsoluteConversion, mapping[val],
  85. "Element display should be converted when absolutely positioned");
  86. is(posFixedConversion, mapping[val],
  87. "Element display should be converted when fixed positioned");
  88. } else {
  89. ok(false, "missing rules for display value " + val);
  90. }
  91. }
  92. var displayInfo = gCSSProperties["display"];
  93. displayInfo.initial_values.forEach(test_display_value);
  94. displayInfo.other_values.forEach(test_display_value);
  95. </script>
  96. </pre>
  97. </body>
  98. </html>