flexbox-dyn-insertEmptySpan-1.xhtml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 a variant of flexbox-dyn-insertAroundText-3.xhtml with the
  8. inserted spans being empty & having padding. This triggered invalidation
  9. issues with an older work-in-progress patch, so I'm adding this reftest to
  10. track that issue & prevent it from regressing.
  11. -->
  12. <html xmlns="http://www.w3.org/1999/xhtml"
  13. class="reftest-wait">
  14. <head>
  15. <style>
  16. body { font-size: 10px; }
  17. <!-- to make inserted span elements stand out -->
  18. span {
  19. background: teal;
  20. padding: 3px;
  21. }
  22. div.flexbox {
  23. border: 1px dashed blue;
  24. width: 300px;
  25. display: flex;
  26. justify-content: space-around;
  27. margin-bottom: 1px;
  28. white-space: pre;
  29. }
  30. </style>
  31. <script>
  32. function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) {
  33. var parent = document.getElementById(aParentId);
  34. var insertBeforeTarget = parent.firstChild;
  35. for (var i = 0; i &lt; aPosn; i++) {
  36. insertBeforeTarget = insertBeforeTarget.nextSibling;
  37. }
  38. parent.insertBefore(aNodeToInsert, insertBeforeTarget);
  39. }
  40. function createSpanElem() {
  41. return document.createElement("span");
  42. }
  43. function tweak() {
  44. // Inserting span, on either side of existing content
  45. // --------------------------------------------------
  46. insertNodeAtPosnInElem(createSpanElem(), 0, "f0");
  47. insertNodeAtPosnInElem(createSpanElem(), 1, "f1");
  48. // Inserting span and whitespace, before existing content
  49. // ------------------------------------------------------
  50. insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2");
  51. insertNodeAtPosnInElem(createSpanElem(), 0, "f2");
  52. insertNodeAtPosnInElem(createSpanElem(), 0, "f3");
  53. insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3");
  54. // Inserting span and whitespace, after existing content
  55. // -----------------------------------------------------
  56. insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4");
  57. insertNodeAtPosnInElem(createSpanElem(), 1, "f4");
  58. insertNodeAtPosnInElem(createSpanElem(), 1, "f5");
  59. insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5");
  60. // Inserting span and text, before existing content
  61. // ------------------------------------------------
  62. insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6");
  63. insertNodeAtPosnInElem(createSpanElem(), 0, "f6");
  64. insertNodeAtPosnInElem(createSpanElem(), 0, "f7");
  65. insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7");
  66. // Inserting span and text, after existing content
  67. // -----------------------------------------------
  68. insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8");
  69. insertNodeAtPosnInElem(createSpanElem(), 1, "f8");
  70. insertNodeAtPosnInElem(createSpanElem(), 1, "f9");
  71. insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9");
  72. document.documentElement.removeAttribute("class");
  73. }
  74. window.addEventListener("MozReftestInvalidate", tweak, false);
  75. </script>
  76. </head>
  77. <body>
  78. <div class="flexbox" id="f0">[orig]</div>
  79. <div class="flexbox" id="f1">[orig]</div>
  80. <div class="flexbox" id="f2">[orig]</div>
  81. <div class="flexbox" id="f3">[orig]</div>
  82. <div class="flexbox" id="f4">[orig]</div>
  83. <div class="flexbox" id="f5">[orig]</div>
  84. <div class="flexbox" id="f6">[orig]</div>
  85. <div class="flexbox" id="f7">[orig]</div>
  86. <div class="flexbox" id="f8">[orig]</div>
  87. <div class="flexbox" id="f9">[orig]</div>
  88. </body>
  89. </html>