1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/reftests/flexbox/flexbox-dyn-insertAroundDiv-3.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +<?xml version="1.0" encoding="UTF-8"?> 1.5 +<!-- 1.6 + Any copyright is dedicated to the Public Domain. 1.7 + http://creativecommons.org/publicdomain/zero/1.0/ 1.8 +--> 1.9 +<!-- 1.10 + This test verifies that we reconstruct frames as necessary, after content 1.11 + (including whitespace & spans) is dynamically inserted as a child of a 1.12 + flexbox. (Note that in cases where we know the whitespace is going to be 1.13 + dropped, we don't bother reconstructing frames. This test is to be sure we 1.14 + aren't overzealous with that optimization.) 1.15 +--> 1.16 +<html xmlns="http://www.w3.org/1999/xhtml" 1.17 + class="reftest-wait"> 1.18 + <head> 1.19 + <style> 1.20 + body { font-size: 10px; } 1.21 + 1.22 + <!-- to make inserted span elements stand out --> 1.23 + span.inserted { background: teal; } 1.24 + 1.25 + div.flexbox { 1.26 + border: 1px dashed blue; 1.27 + width: 300px; 1.28 + display: flex; 1.29 + justify-content: space-around; 1.30 + margin-bottom: 1px; 1.31 + white-space: pre; 1.32 + } 1.33 + </style> 1.34 + <script> 1.35 + function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) { 1.36 + var parent = document.getElementById(aParentId); 1.37 + var insertBeforeTarget = parent.firstChild; 1.38 + for (var i = 0; i < aPosn; i++) { 1.39 + insertBeforeTarget = insertBeforeTarget.nextSibling; 1.40 + } 1.41 + parent.insertBefore(aNodeToInsert, insertBeforeTarget); 1.42 + } 1.43 + 1.44 + function createSpanElem() { 1.45 + var span = document.createElement("span"); 1.46 + span.setAttribute("class", "inserted"); 1.47 + span.appendChild(document.createTextNode("[NewSpan]")); 1.48 + return span; 1.49 + } 1.50 + 1.51 + function tweak() { 1.52 + // Inserting span, on either side of existing content 1.53 + // -------------------------------------------------- 1.54 + insertNodeAtPosnInElem(createSpanElem(), 0, "f0"); 1.55 + insertNodeAtPosnInElem(createSpanElem(), 1, "f1"); 1.56 + 1.57 + // Inserting span and whitespace, before existing content 1.58 + // ------------------------------------------------------ 1.59 + insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2"); 1.60 + insertNodeAtPosnInElem(createSpanElem(), 0, "f2"); 1.61 + 1.62 + insertNodeAtPosnInElem(createSpanElem(), 0, "f3"); 1.63 + insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3"); 1.64 + 1.65 + // Inserting span and whitespace, after existing content 1.66 + // ----------------------------------------------------- 1.67 + insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4"); 1.68 + insertNodeAtPosnInElem(createSpanElem(), 1, "f4"); 1.69 + 1.70 + insertNodeAtPosnInElem(createSpanElem(), 1, "f5"); 1.71 + insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5"); 1.72 + 1.73 + // Inserting span and text, before existing content 1.74 + // ------------------------------------------------ 1.75 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6"); 1.76 + insertNodeAtPosnInElem(createSpanElem(), 0, "f6"); 1.77 + 1.78 + insertNodeAtPosnInElem(createSpanElem(), 0, "f7"); 1.79 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7"); 1.80 + 1.81 + // Inserting span and text, after existing content 1.82 + // ----------------------------------------------- 1.83 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8"); 1.84 + insertNodeAtPosnInElem(createSpanElem(), 1, "f8"); 1.85 + 1.86 + insertNodeAtPosnInElem(createSpanElem(), 1, "f9"); 1.87 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9"); 1.88 + 1.89 + document.documentElement.removeAttribute("class"); 1.90 + } 1.91 + 1.92 + window.addEventListener("MozReftestInvalidate", tweak, false); 1.93 + </script> 1.94 + </head> 1.95 + <body> 1.96 + <div class="flexbox" id="f0"><div>[OldText]</div></div> 1.97 + <div class="flexbox" id="f1"><div>[OldText]</div></div> 1.98 + <div class="flexbox" id="f2"><div>[OldText]</div></div> 1.99 + <div class="flexbox" id="f3"><div>[OldText]</div></div> 1.100 + <div class="flexbox" id="f4"><div>[OldText]</div></div> 1.101 + <div class="flexbox" id="f5"><div>[OldText]</div></div> 1.102 + <div class="flexbox" id="f6"><div>[OldText]</div></div> 1.103 + <div class="flexbox" id="f7"><div>[OldText]</div></div> 1.104 + <div class="flexbox" id="f8"><div>[OldText]</div></div> 1.105 + <div class="flexbox" id="f9"><div>[OldText]</div></div> 1.106 + </body> 1.107 +</html>