Bug 1343677 part 2. Assert in nsCSSprops::IsEnabled that we have received all preferences. r=dholbert,billm
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 16 Mar 2017 17:43:17 -0400
changeset 348049 d6b773c155936cbc1f21dbcfe84531976a8bdb22
parent 348048 55ee07a916b838e153231bf92b0a6fcec4e4b99d
child 348050 008b180abd4a5f5195c4784f62573ac2a3704305
push id88136
push userbzbarsky@mozilla.com
push dateThu, 16 Mar 2017 21:55:04 +0000
treeherdermozilla-inbound@7b89ee0ae420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, billm
bugs1343677
milestone55.0a1
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 1343677 part 2. Assert in nsCSSprops::IsEnabled that we have received all preferences. r=dholbert,billm This ensures that we don't read incorrect values out of the gPropertyEnabled array simply because we haven't gotten preference values from the parent process yet. MozReview-Commit-ID: 59AgN3ecXQl
layout/style/nsCSSProps.h
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -15,16 +15,18 @@
 #include <type_traits>
 #include "nsString.h"
 #include "nsCSSPropertyID.h"
 #include "nsStyleStructFwd.h"
 #include "nsCSSKeywords.h"
 #include "mozilla/CSSEnabledState.h"
 #include "mozilla/UseCounter.h"
 #include "mozilla/EnumTypeTraits.h"
+#include "mozilla/Preferences.h"
+#include "nsXULAppAPI.h"
 
 // Length of the "--" prefix on custom names (such as custom property names,
 // and, in the future, custom media query names).
 #define CSS_CUSTOM_NAME_PREFIX_LENGTH 2
 
 // Flags for ParseVariant method
 #define VARIANT_KEYWORD         0x000001  // K
 #define VARIANT_LENGTH          0x000002  // L
@@ -626,16 +628,22 @@ public:
     MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
                "out of range");
     return kIDLNameSortPositionTable[aProperty];
   }
 
   static bool IsEnabled(nsCSSPropertyID aProperty) {
     MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases,
                "out of range");
+    // We don't have useful pref init phases in the parent process.  But in the
+    // child process, assert that we're not trying to parse stylesheets before
+    // we've gotten all our prefs.
+    MOZ_ASSERT(XRE_IsParentProcess() ||
+               mozilla::Preferences::InitPhase() == END_ALL_PREFS,
+               "Checking style preferences before they have been set");
     return gPropertyEnabled[aProperty];
   }
 
   // A table for the use counter associated with each CSS property.  If a
   // property does not have a use counter defined in UseCounters.conf, then
   // its associated entry is |eUseCounter_UNKNOWN|.
   static const mozilla::UseCounter gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands];