Bug 1533392 - Fix initial font-family detection in property-database.js. r=dholbert
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 07 Mar 2019 21:27:23 +0000
changeset 520909 91fcd9232c7e64ec113afd5f9eb183939cd52110
parent 520908 3d19ee7bc2d7967b730aab39594f81eb3e0c3626
child 520910 c26d4a8d43c4d0d6f6e13135b8f35924123fe99e
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1533392, 1511138
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533392 - Fix initial font-family detection in property-database.js. r=dholbert Calling getComputedStyle on an element outside of the document always returns the empty string since bug 1511138, so we were incorrectly thinking that the initial font-family was serif when it was not. I chose a <meta> element instead of a <div> because they're undisplayed and they don't cause the <body> of the document to start (though I _think_ that only happens from the parser). In any case I'm pretty surprised this didn't cause issues in other tests... Differential Revision: https://phabricator.services.mozilla.com/D22604
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -76,20 +76,26 @@ const CSS_TYPE_LEGACY_SHORTHAND = 3;
 // property's fields.
 // Helper functions used to construct gCSSProperties.
 function initial_font_family_is_sans_serif()
   // The initial value of 'font-family' might be 'serif' or
   // 'sans-serif'.
-  var div = document.createElement("div");
-  div.setAttribute("style", "font: initial");
-  return getComputedStyle(div, "").fontFamily == "sans-serif";
+  const meta = document.createElement("meta");
+  meta.setAttribute("style", "font: initial;");
+  ok(document.documentElement, "We should have a place to put ourselves into");
+  document.documentElement.appendChild(meta);
+  const family = getComputedStyle(meta).fontFamily;
+  ok(family == "serif" || family == "sans-serif", "Should be able to get the family");
+  meta.remove();
+  return family == "sans-serif";
 var gInitialFontFamilyIsSansSerif = initial_font_family_is_sans_serif();
 // shared by background-image and border-image-source
 var validGradientAndElementValues = [
   "-moz-element(  #a  )",
--- a/layout/style/test/test_revert.html
+++ b/layout/style/test/test_revert.html
@@ -52,19 +52,16 @@ function testResetProperty(property, inf
 function testInheritedProperty(property, info) {
   // Given how line-height works, and that it always returns the used value, we
   // cannot test it. The prerequisites for line-height makes getComputedStyle
   // and getDefaultComputedStyle return the same, even though the computed value
   // is different (normal vs. 19px).
   if (property == "line-height")
-  // Ongoing debugging in bug 1533392.
-  if (property == "font-family")
-    return;
   const div = kInheritedDiv;
   const initial = getInitialValue(div, property);
   const parentValue = computedValue(div.parentNode, property);
   isnot(parentValue, initial, `${property}: Should inherit something non-initial to begin with`);
   const inheritedValue = computedValue(div, property);