Bug 1331903 part 1 - Fix test_inherit_computation.html test for width and inline-size. r?dbaron draft
authorXidorn Quan <me@upsuper.org>
Thu, 19 Jan 2017 22:33:33 +1100
changeset 463587 c50e646ec873cb0a696f0733cb0495ac75064fef
parent 463580 8705d493d33f6593846bea93ccb0b39c269688dd
child 463588 f601c4ad3aca213aa0bb26a9411fd61cbd2d62f6
push id42122
push userxquan@mozilla.com
push dateThu, 19 Jan 2017 11:35:42 +0000
reviewersdbaron
bugs1331903
milestone53.0a1
Bug 1331903 part 1 - Fix test_inherit_computation.html test for width and inline-size. r?dbaron MozReview-Commit-ID: HoGM5x7xVMK
layout/style/test/property_database.js
layout/style/test/test_inherit_computation.html
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -3954,18 +3954,23 @@ var gCSSProperties = {
     initial_values: [ "normal" ],
     other_values: [ "pre", "nowrap", "pre-wrap", "pre-line", "-moz-pre-space" ],
     invalid_values: []
   },
   "width": {
     domProp: "width",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
-    /* computed value tests for width test more with display:block */
-    prerequisites: { "display": "block" },
+    prerequisites: {
+      // computed value tests for width test more with display:block
+      "display": "block",
+      // add some margin to avoid the initial "auto" value getting
+      // resolved to the same length as the parent element.
+      "margin-left": "5px",
+    },
     initial_values: [ " auto" ],
     /* XXX these have prerequisites */
     other_values: [ "15px", "3em", "15%",
       // these three keywords compute to the initial value only when the
       // writing mode is vertical, and we're testing with a horizontal
       // writing mode
       "-moz-max-content", "-moz-min-content", "-moz-fit-content",
       // whether -moz-available computes to the initial value depends on
@@ -5101,17 +5106,22 @@ var gCSSProperties = {
     domProp: "inlineSize",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     logical: true,
     axis: true,
     get_computed: logical_axis_prop_get_computed,
     /* XXX testing auto has prerequisites */
     initial_values: [ "auto" ],
-    prerequisites: { "display": "block" },
+    prerequisites: {
+      "display": "block",
+      // add some margin to avoid the initial "auto" value getting
+      // resolved to the same length as the parent element.
+      "margin-left": "5px",
+    },
     other_values: [ "15px", "3em", "15%",
       // these three keywords compute to the initial value only when the
       // writing mode is vertical, and we're testing with a horizontal
       // writing mode
       "-moz-max-content", "-moz-min-content", "-moz-fit-content",
       // whether -moz-available computes to the initial value depends on
       // the container size, and for the container size we're testing
       // with, it does
--- a/layout/style/test/test_inherit_computation.html
+++ b/layout/style/test/test_inherit_computation.html
@@ -122,19 +122,25 @@ function test_property(property)
          property + "'");
       gParentRuleTop.style.removeProperty(property);
       gChildRule1.style.setProperty(property, info.other_values[0], "");
       var inherit_initial_computed_n = get_computed_value_node(gNChild, property);
       var inherit_initial_computed_f = get_computed_value_node(gFChild, property);
       is(inherit_initial_computed_n, initial_computed_n,
          keyword + " should cause inheritance of initial value for '" +
          property + "'");
-      is(inherit_initial_computed_f, initial_computed_f,
-         keyword + " should cause inheritance of initial value for '" +
-         property + "'");
+      // For width and inline-size, getComputedStyle returns used value
+      // when the element is displayed. Their initial value "auto" makes
+      // the element fill available space of the parent, so it doesn't
+      // make sense to compare it with the value we get before.
+      if (property != "width" && property != "inline-size") {
+        is(inherit_initial_computed_f, initial_computed_f,
+           keyword + " should cause inheritance of initial value for '" +
+           property + "'");
+      }
       gParentRuleTop.style.removeProperty(property);
       gChildRule1.style.removeProperty(property);
       gChildRule2.style.removeProperty(property);
     }
 
     if ("prerequisites" in info) {
       var prereqs = info.prerequisites;
       for (var prereq in prereqs) {