layout/reftests/flexbox/flexbox-dyn-insertAroundSpan-2.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.

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

mercurial