Bug 1063052. NS_RUNTIMEABORT if a builtin stylesheet fails to load. r=heycam,a=lmandel
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 10 Sep 2014 13:10:18 +1200
changeset 216711 c43d3d833973
parent 216706 d4082d3a082c
child 216712 a706b85f6d4d
push id3886
push userrocallahan@mozilla.com
push date2014-09-12 04:24 +0000
treeherdermozilla-beta@c43d3d833973 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, lmandel
bugs1063052
milestone33.0
Bug 1063052. NS_RUNTIMEABORT if a builtin stylesheet fails to load. r=heycam,a=lmandel
layout/style/nsLayoutStylesheetCache.cpp
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/css/Loader.h"
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIXULRuntime.h"
+#include "nsPrintfCString.h"
 
 using namespace mozilla;
 
 static bool sNumberControlEnabled;
 
 #define NUMBER_CONTROL_PREF "dom.forms.number"
 
 NS_IMPL_ISUPPORTS(
@@ -423,34 +424,52 @@ nsLayoutStylesheetCache::LoadSheetFile(n
   if (!exists) return;
 
   nsCOMPtr<nsIURI> uri;
   NS_NewFileURI(getter_AddRefs(uri), aFile);
 
   LoadSheet(uri, aSheet, false);
 }
 
+static void
+ErrorLoadingBuiltinSheet(nsIURI* aURI, const char* aMsg)
+{
+  nsAutoCString spec;
+  if (aURI) {
+    aURI->GetSpec(spec);
+  }
+  NS_RUNTIMEABORT(nsPrintfCString("%s loading built-in stylesheet '%s'",
+                                  aMsg, spec.get()).get());
+}
+
 void
 nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
                                    nsRefPtr<CSSStyleSheet>& aSheet,
                                    bool aEnableUnsafeRules)
 {
   if (!aURI) {
-    NS_ERROR("Null URI. Out of memory?");
+    ErrorLoadingBuiltinSheet(aURI, "null URI");
     return;
   }
 
   if (!gCSSLoader) {
     gCSSLoader = new mozilla::css::Loader();
     NS_IF_ADDREF(gCSSLoader);
+    if (!gCSSLoader) {
+      ErrorLoadingBuiltinSheet(aURI, "no Loader");
+      return;
+    }
   }
 
-  if (gCSSLoader) {
-    gCSSLoader->LoadSheetSync(aURI, aEnableUnsafeRules, true,
-                              getter_AddRefs(aSheet));
+
+  nsresult rv = gCSSLoader->LoadSheetSync(aURI, aEnableUnsafeRules, true,
+                                          getter_AddRefs(aSheet));
+  if (NS_FAILED(rv)) {
+    ErrorLoadingBuiltinSheet(aURI,
+      nsPrintfCString("LoadSheetSync failed with error %x", rv).get());
   }
 }
 
 mozilla::StaticRefPtr<nsLayoutStylesheetCache>
 nsLayoutStylesheetCache::gStyleCache;
 
 mozilla::css::Loader*
 nsLayoutStylesheetCache::gCSSLoader = nullptr;