layout/reftests/flexbox/flexbox-dyn-insertAroundSpan-3.xhtml

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

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 & spans) 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 {
michael@0 18 font-size: 10px;
michael@0 19 }
michael@0 20
michael@0 21 span.inserted {
michael@0 22 background: teal; /* To make inserted span elements stand out. */
michael@0 23 }
michael@0 24
michael@0 25 div.flexbox {
michael@0 26 border: 1px dashed blue;
michael@0 27 width: 300px;
michael@0 28 display: flex;
michael@0 29 justify-content: space-around;
michael@0 30 margin-bottom: 1px;
michael@0 31 white-space: pre;
michael@0 32 }
michael@0 33 </style>
michael@0 34 <script>
michael@0 35 function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) {
michael@0 36 var parent = document.getElementById(aParentId);
michael@0 37 var insertBeforeTarget = parent.firstChild;
michael@0 38 for (var i = 0; i &lt; aPosn; i++) {
michael@0 39 insertBeforeTarget = insertBeforeTarget.nextSibling;
michael@0 40 }
michael@0 41 parent.insertBefore(aNodeToInsert, insertBeforeTarget);
michael@0 42 }
michael@0 43
michael@0 44 function createSpanElem() {
michael@0 45 var span = document.createElement("span");
michael@0 46 span.setAttribute("class", "inserted");
michael@0 47 span.appendChild(document.createTextNode("[NewSpan]"));
michael@0 48 return span;
michael@0 49 }
michael@0 50
michael@0 51 function tweak() {
michael@0 52 // Inserting span, on either side of existing content
michael@0 53 // --------------------------------------------------
michael@0 54 insertNodeAtPosnInElem(createSpanElem(), 0, "f0");
michael@0 55 insertNodeAtPosnInElem(createSpanElem(), 1, "f1");
michael@0 56
michael@0 57 // Inserting span and whitespace, before existing content
michael@0 58 // ------------------------------------------------------
michael@0 59 insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2");
michael@0 60 insertNodeAtPosnInElem(createSpanElem(), 0, "f2");
michael@0 61
michael@0 62 insertNodeAtPosnInElem(createSpanElem(), 0, "f3");
michael@0 63 insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3");
michael@0 64
michael@0 65 // Inserting span and whitespace, after existing content
michael@0 66 // -----------------------------------------------------
michael@0 67 insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4");
michael@0 68 insertNodeAtPosnInElem(createSpanElem(), 1, "f4");
michael@0 69
michael@0 70 insertNodeAtPosnInElem(createSpanElem(), 1, "f5");
michael@0 71 insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5");
michael@0 72
michael@0 73 // Inserting span and text, before existing content
michael@0 74 // ------------------------------------------------
michael@0 75 insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6");
michael@0 76 insertNodeAtPosnInElem(createSpanElem(), 0, "f6");
michael@0 77
michael@0 78 insertNodeAtPosnInElem(createSpanElem(), 0, "f7");
michael@0 79 insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7");
michael@0 80
michael@0 81 // Inserting span and text, after existing content
michael@0 82 // -----------------------------------------------
michael@0 83 insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8");
michael@0 84 insertNodeAtPosnInElem(createSpanElem(), 1, "f8");
michael@0 85
michael@0 86 insertNodeAtPosnInElem(createSpanElem(), 1, "f9");
michael@0 87 insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9");
michael@0 88
michael@0 89 document.documentElement.removeAttribute("class");
michael@0 90 }
michael@0 91
michael@0 92 window.addEventListener("MozReftestInvalidate", tweak, false);
michael@0 93 </script>
michael@0 94 </head>
michael@0 95 <body>
michael@0 96 <div class="flexbox" id="f0"><span>[OldText]</span></div>
michael@0 97 <div class="flexbox" id="f1"><span>[OldText]</span></div>
michael@0 98 <div class="flexbox" id="f2"><span>[OldText]</span></div>
michael@0 99 <div class="flexbox" id="f3"><span>[OldText]</span></div>
michael@0 100 <div class="flexbox" id="f4"><span>[OldText]</span></div>
michael@0 101 <div class="flexbox" id="f5"><span>[OldText]</span></div>
michael@0 102 <div class="flexbox" id="f6"><span>[OldText]</span></div>
michael@0 103 <div class="flexbox" id="f7"><span>[OldText]</span></div>
michael@0 104 <div class="flexbox" id="f8"><span>[OldText]</span></div>
michael@0 105 <div class="flexbox" id="f9"><span>[OldText]</span></div>
michael@0 106 </body>
michael@0 107 </html>

mercurial