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

mercurial