Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 5 | --> |
michael@0 | 6 | <!-- |
michael@0 | 7 | This test verifies that we reconstruct frames as necessary, after content |
michael@0 | 8 | (including whitespace & divs) is dynamically inserted as a child of a |
michael@0 | 9 | flexbox. (Note that in cases where we know the whitespace is going to be |
michael@0 | 10 | dropped, we don't bother reconstructing frames. This test is to be sure we |
michael@0 | 11 | aren't overzealous with that optimization.) |
michael@0 | 12 | --> |
michael@0 | 13 | <html xmlns="http://www.w3.org/1999/xhtml" |
michael@0 | 14 | class="reftest-wait"> |
michael@0 | 15 | <head> |
michael@0 | 16 | <style> |
michael@0 | 17 | body { font-size: 10px; } |
michael@0 | 18 | |
michael@0 | 19 | <!-- to make inserted div elements stand out --> |
michael@0 | 20 | div.inserted { background: teal; } |
michael@0 | 21 | |
michael@0 | 22 | div.flexbox { |
michael@0 | 23 | border: 1px dashed blue; |
michael@0 | 24 | width: 300px; |
michael@0 | 25 | display: flex; |
michael@0 | 26 | justify-content: space-around; |
michael@0 | 27 | margin-bottom: 1px; |
michael@0 | 28 | white-space: pre; |
michael@0 | 29 | } |
michael@0 | 30 | </style> |
michael@0 | 31 | <script> |
michael@0 | 32 | function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) { |
michael@0 | 33 | var parent = document.getElementById(aParentId); |
michael@0 | 34 | var insertBeforeTarget = parent.firstChild; |
michael@0 | 35 | for (var i = 0; i < aPosn; i++) { |
michael@0 | 36 | insertBeforeTarget = insertBeforeTarget.nextSibling; |
michael@0 | 37 | } |
michael@0 | 38 | parent.insertBefore(aNodeToInsert, insertBeforeTarget); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function createDivElem() { |
michael@0 | 42 | var div = document.createElement("div"); |
michael@0 | 43 | div.setAttribute("class", "inserted"); |
michael@0 | 44 | div.appendChild(document.createTextNode("[NewDiv]")); |
michael@0 | 45 | return div; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function tweak() { |
michael@0 | 49 | // Inserting div, adjacent to inline content |
michael@0 | 50 | // ----------------------------------------- |
michael@0 | 51 | insertNodeAtPosnInElem(createDivElem(), 0, "f0"); |
michael@0 | 52 | insertNodeAtPosnInElem(createDivElem(), 1, "f1"); |
michael@0 | 53 | |
michael@0 | 54 | // Inserting div and whitespace, before inline content |
michael@0 | 55 | // --------------------------------------------------- |
michael@0 | 56 | insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2"); |
michael@0 | 57 | insertNodeAtPosnInElem(createDivElem(), 0, "f2"); |
michael@0 | 58 | |
michael@0 | 59 | insertNodeAtPosnInElem(createDivElem(), 0, "f3"); |
michael@0 | 60 | insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3"); |
michael@0 | 61 | |
michael@0 | 62 | // Inserting div and whitespace, after inline content |
michael@0 | 63 | // --------------------------------------------------- |
michael@0 | 64 | insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4"); |
michael@0 | 65 | insertNodeAtPosnInElem(createDivElem(), 1, "f4"); |
michael@0 | 66 | |
michael@0 | 67 | insertNodeAtPosnInElem(createDivElem(), 1, "f5"); |
michael@0 | 68 | insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5"); |
michael@0 | 69 | |
michael@0 | 70 | // Inserting div and text, before inline content |
michael@0 | 71 | // --------------------------------------------------- |
michael@0 | 72 | insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6"); |
michael@0 | 73 | insertNodeAtPosnInElem(createDivElem(), 0, "f6"); |
michael@0 | 74 | |
michael@0 | 75 | insertNodeAtPosnInElem(createDivElem(), 0, "f7"); |
michael@0 | 76 | insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7"); |
michael@0 | 77 | |
michael@0 | 78 | // Inserting div and text, after inline content |
michael@0 | 79 | // --------------------------------------------------- |
michael@0 | 80 | insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8"); |
michael@0 | 81 | insertNodeAtPosnInElem(createDivElem(), 1, "f8"); |
michael@0 | 82 | |
michael@0 | 83 | insertNodeAtPosnInElem(createDivElem(), 1, "f9"); |
michael@0 | 84 | insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9"); |
michael@0 | 85 | |
michael@0 | 86 | document.documentElement.removeAttribute("class"); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | window.addEventListener("MozReftestInvalidate", tweak, false); |
michael@0 | 90 | </script> |
michael@0 | 91 | </head> |
michael@0 | 92 | <body> |
michael@0 | 93 | <div class="flexbox" id="f0"><div>[OldText]</div></div> |
michael@0 | 94 | <div class="flexbox" id="f1"><div>[OldText]</div></div> |
michael@0 | 95 | <div class="flexbox" id="f2"><div>[OldText]</div></div> |
michael@0 | 96 | <div class="flexbox" id="f3"><div>[OldText]</div></div> |
michael@0 | 97 | <div class="flexbox" id="f4"><div>[OldText]</div></div> |
michael@0 | 98 | <div class="flexbox" id="f5"><div>[OldText]</div></div> |
michael@0 | 99 | <div class="flexbox" id="f6"><div>[OldText]</div></div> |
michael@0 | 100 | <div class="flexbox" id="f7"><div>[OldText]</div></div> |
michael@0 | 101 | <div class="flexbox" id="f8"><div>[OldText]</div></div> |
michael@0 | 102 | <div class="flexbox" id="f9"><div>[OldText]</div></div> |
michael@0 | 103 | </body> |
michael@0 | 104 | </html> |