Bug 1499875 part 1: Adjust existing tests/content in test_flex_items.html to prepare for additional flex containers to be added. r=bradwerth
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 18 Oct 2018 23:47:47 +0000
changeset 490422 18152a7b3fa5e5145b87629c4adf38bfbaf11194
parent 490421 1728cf8a0da4da103076a9e1ce02c9f5b4eb3d85
child 490423 c13ad6a94911842a64575de9085c421ef667e8fd
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbradwerth
bugs1499875
milestone64.0a1
Bug 1499875 part 1: Adjust existing tests/content in test_flex_items.html to prepare for additional flex containers to be added. r=bradwerth Differential Revision: https://phabricator.services.mozilla.com/D9152
dom/flex/test/chrome/test_flex_items.html
--- a/dom/flex/test/chrome/test_flex_items.html
+++ b/dom/flex/test/chrome/test_flex_items.html
@@ -6,19 +6,18 @@
 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 <style>
   .container {
     display: flex;
     background-color: grey;
     font: 14px sans-serif;
     height: 50px;
   }
-  .huge {
-    /* This just needs to be large enough so that no shrinking is required
-       inside the flex container that uses this class. */
+  #flex-sanity {
+    /* This just needs to be large enough so that no shrinking is required. */
     width: 1600px;
   }
 
   .base        { align-self: baseline; }
   .lastbase    { align-self: last baseline; }
 
   .offset      { margin-top: 10px;
                  margin-bottom: 3px; }
@@ -51,20 +50,16 @@ SimpleTest.waitForExplicitFinish();
 
 const TEXT_NODE = Node.TEXT_NODE;
 
 function testItemMatchesExpectedValues(item, values, index) {
   if (typeof(values.node) != "undefined") {
     is(item.node, values.node, "Item index " + index + " has expected node.");
   }
 
-  if (typeof(values.node_todo) != "undefined") {
-    todo_is(item.node, values.node_todo, "Item index " + index + " has expected node.");
-  }
-
   if (typeof(values.mainBaseSize) != "undefined") {
     is(item.mainBaseSize, values.mainBaseSize, "Item index " + index + " has expected mainBaseSize.");
   }
 
   if (typeof(values.mainDeltaSize) != "undefined") {
     is(item.mainDeltaSize, values.mainDeltaSize, "Item index " + index + " has expected mainDeltaSize.");
   }
 
@@ -90,18 +85,18 @@ function testItemMatchesExpectedValues(i
     is(item.crossMaxSize, values.crossMaxSize, "Item index " + index + " has expected crossMaxSize.");
   } else {
     // As above for mainMaxSize, no-expected-value implies we expect +infinity.
     is(item.crossMaxSize, Number.POSITIVE_INFINITY,
        "Item index " + index + " has expected (default) crossMaxSize.");
   }
 }
 
-function runTests() {
-  let container = document.getElementById("wrapper");
+function testFlexSanity() {
+  let container = document.getElementById("flex-sanity");
   let flex = container.getAsFlexContainer();
   let lines = flex.getLines();
   is(lines.length, 1, "Container should have expected number of lines.");
 
   let line = lines[0];
   let containerHeight = container.getBoundingClientRect().height;
   is(line.crossSize, containerHeight,
      "Line crossSize should equal the height of the container.");
@@ -178,24 +173,33 @@ function runTests() {
     }
     testItemMatchesExpectedValues(item, values, i);
   }
 
   // Check that the delta size of the first item is (roughly) equal to the
   // actual size minus the base size.
   isfuzzy(items[0].mainDeltaSize, firstRect.width - items[0].mainBaseSize, 1e-4,
           "flex-grow item should have expected mainDeltaSize.");
+}
 
+function runTests() {
+  testFlexSanity();
   SimpleTest.finish();
 }
 </script>
 </head>
 
 <body onLoad="runTests();">
-  <div id="wrapper" class="container huge">
+  <!-- First flex container to be tested: "flex-sanity".
+       We test a few general things, e.g.:
+       - accuracy of reported baselines.
+       - accuracy of reported flex base size, min/max sizes, & trivial deltas.
+       - flex items formation for display:contents subtrees & text nodes.
+   -->
+  <div id="flex-sanity" class="container">
     <div class="lime base flexGrow">one line (first)</div>
     <div class="yellow lastbase" style="width: 100px">one line (last)</div>
     <div class="orange offset lastbase crossMinMax">two<br/>lines and offset (last)</div>
     <div class="pink offset base mainMinMax">offset (first)</div>
     <!-- Inflexible item w/ content-derived flex base size, which has min/max
          but doesn't violate them: -->
     <div class="tan mainMinMax">
       <div class="spacer150"></div>
@@ -208,12 +212,12 @@ function runTests() {
          hardcoded flex base sizes so we can predict & check mainDeltaSize
          for this item: -->
     <!-- Item that wants to grow but is trivially clamped to max-width
          below base size: -->
     <div style="flex: 1 1 50px; max-width: 10px"></div>
     <div style="display:contents">
       <div class="white">replaced</div>
     </div>
-    anonymous text node
+    anon item for text
   </div>
 </body>
 </html>