1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/reftests/flexbox/flexbox-dyn-insertAroundText-3.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 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 { 1.21 + font-size: 10px; 1.22 + } 1.23 + 1.24 + span.inserted { 1.25 + background: teal; /* To make inserted span elements stand out. */ 1.26 + } 1.27 + 1.28 + div.flexbox { 1.29 + border: 1px dashed blue; 1.30 + width: 300px; 1.31 + display: flex; 1.32 + justify-content: space-around; 1.33 + margin-bottom: 1px; 1.34 + white-space: pre; 1.35 + } 1.36 + </style> 1.37 + <script> 1.38 + function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) { 1.39 + var parent = document.getElementById(aParentId); 1.40 + var insertBeforeTarget = parent.firstChild; 1.41 + for (var i = 0; i < aPosn; i++) { 1.42 + insertBeforeTarget = insertBeforeTarget.nextSibling; 1.43 + } 1.44 + parent.insertBefore(aNodeToInsert, insertBeforeTarget); 1.45 + } 1.46 + 1.47 + function createSpanElem() { 1.48 + var span = document.createElement("span"); 1.49 + span.setAttribute("class", "inserted"); 1.50 + span.appendChild(document.createTextNode("[NewSpan]")); 1.51 + return span; 1.52 + } 1.53 + 1.54 + function tweak() { 1.55 + // Inserting span, on either side of existing content 1.56 + // -------------------------------------------------- 1.57 + insertNodeAtPosnInElem(createSpanElem(), 0, "f0"); 1.58 + insertNodeAtPosnInElem(createSpanElem(), 1, "f1"); 1.59 + 1.60 + // Inserting span and whitespace, before existing content 1.61 + // ------------------------------------------------------ 1.62 + insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2"); 1.63 + insertNodeAtPosnInElem(createSpanElem(), 0, "f2"); 1.64 + 1.65 + insertNodeAtPosnInElem(createSpanElem(), 0, "f3"); 1.66 + insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3"); 1.67 + 1.68 + // Inserting span and whitespace, after existing content 1.69 + // ----------------------------------------------------- 1.70 + insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4"); 1.71 + insertNodeAtPosnInElem(createSpanElem(), 1, "f4"); 1.72 + 1.73 + insertNodeAtPosnInElem(createSpanElem(), 1, "f5"); 1.74 + insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5"); 1.75 + 1.76 + // Inserting span and text, before existing content 1.77 + // ------------------------------------------------ 1.78 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6"); 1.79 + insertNodeAtPosnInElem(createSpanElem(), 0, "f6"); 1.80 + 1.81 + insertNodeAtPosnInElem(createSpanElem(), 0, "f7"); 1.82 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7"); 1.83 + 1.84 + // Inserting span and text, after existing content 1.85 + // ----------------------------------------------- 1.86 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8"); 1.87 + insertNodeAtPosnInElem(createSpanElem(), 1, "f8"); 1.88 + 1.89 + insertNodeAtPosnInElem(createSpanElem(), 1, "f9"); 1.90 + insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9"); 1.91 + 1.92 + document.documentElement.removeAttribute("class"); 1.93 + } 1.94 + 1.95 + window.addEventListener("MozReftestInvalidate", tweak, false); 1.96 + </script> 1.97 + </head> 1.98 + <body> 1.99 + <div class="flexbox" id="f0">[OldText]</div> 1.100 + <div class="flexbox" id="f1">[OldText]</div> 1.101 + <div class="flexbox" id="f2">[OldText]</div> 1.102 + <div class="flexbox" id="f3">[OldText]</div> 1.103 + <div class="flexbox" id="f4">[OldText]</div> 1.104 + <div class="flexbox" id="f5">[OldText]</div> 1.105 + <div class="flexbox" id="f6">[OldText]</div> 1.106 + <div class="flexbox" id="f7">[OldText]</div> 1.107 + <div class="flexbox" id="f8">[OldText]</div> 1.108 + <div class="flexbox" id="f9">[OldText]</div> 1.109 + </body> 1.110 +</html>