flexbox-float-1c.xhtml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Any copyright is dedicated to the Public Domain.
  4. http://creativecommons.org/publicdomain/zero/1.0/
  5. -->
  6. <!--
  7. This test is like flexbox-float-1a.xhtml, but with the float-styled
  8. element dynamically inserted.
  9. -->
  10. <html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
  11. <head>
  12. <script>
  13. function generateFloat(aFloatDirection) {
  14. var newElem = document.createElement("span");
  15. newElem.setAttribute("style", "float: " + aFloatDirection);
  16. newElem.innerHTML = aFloatDirection == "left" ? "[[[" : "]]]";
  17. return newElem;
  18. }
  19. function tweak() {
  20. var containerList = document.getElementsByClassName("flexbox");
  21. for (var i = 0; i &lt; containerList.length; i++) {
  22. var container = containerList[i];
  23. var newElem = generateFloat(container.getAttribute("floatValToUse"));
  24. var nodeToInsertBefore;
  25. var insertPosn = container.getAttribute("insertPosn");
  26. if (insertPosn == "begin") {
  27. nodeToInsertBefore = container.firstChild;
  28. } else if (insertPosn == "mid") {
  29. nodeToInsertBefore = container.firstChild.nextSibling;
  30. } else if (insertPosn == "end") {
  31. nodeToInsertBefore = null;
  32. }
  33. container.insertBefore(newElem, nodeToInsertBefore);
  34. }
  35. document.documentElement.removeAttribute("class");
  36. }
  37. window.addEventListener("MozReftestInvalidate", tweak, false);
  38. </script>
  39. <style>
  40. div.flexbox {
  41. display: flex;
  42. width: 400px;
  43. margin-bottom: 2px;
  44. font-family: sans-serif;
  45. background: lightgreen;
  46. justify-content: space-around;
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <div class="flexbox" floatValToUse="left" insertPosn="mid">
  52. aaa<span>bbb</span>
  53. </div>
  54. <div class="flexbox" floatValToUse="right" insertPosn="mid">
  55. aaa<span>bbb</span>
  56. </div>
  57. <div class="flexbox" floatValToUse="left" insertPosn="end">
  58. aaa
  59. </div>
  60. <div class="flexbox" floatValToUse="right" insertPosn="end">
  61. aaa
  62. </div>
  63. <div class="flexbox" floatValToUse="left" insertPosn="begin">
  64. bbb
  65. </div>
  66. <div class="flexbox" floatValToUse="right" insertPosn="begin">
  67. bbb
  68. </div>
  69. </body>
  70. </html>