Bug 1451625 - Error on overlay load instead of crash. r?mystor draft
authorBrendan Dahl <brendan.dahl@gmail.com>
Thu, 12 Apr 2018 11:56:55 -0700
changeset 781393 213e5d8ac62965aaa9083dbb92d2ace4959c6980
parent 781042 ee1d1bf1dc8a83eec16967ddb61dd5024c8d6058
child 781394 5529222299b6155f2f8aec55b40aefa6b7ce587f
push id106291
push userbmo:bdahl@mozilla.com
push dateThu, 12 Apr 2018 22:03:35 +0000
reviewersmystor
bugs1451625
milestone61.0a1
Bug 1451625 - Error on overlay load instead of crash. r?mystor MozReview-Commit-ID: 4OHBlsTmqik
dom/xul/XULDocument.cpp
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -89,16 +89,17 @@
 #include "nsTextNode.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/URL.h"
 #include "nsIContentPolicy.h"
 #include "mozAutoDocUpdate.h"
 #include "xpcpublic.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
+#include "nsIConsoleService.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 //
 // CIDs
 //
@@ -2262,20 +2263,26 @@ XULDocument::LoadOverlayInternal(nsIURI*
     // loading an overlay will cause a crash as they are no longer allowed.
     // However, overlays are allowed in other applications (e.g. Thunderbird)
     // while they work on removing them. See bug 1448162.
 #ifdef MOZ_CRASH_XUL_OVERLAYS
     nsCString docSpec;
     mCurrentPrototype->GetURI()->GetSpec(docSpec);
     nsCString overlaySpec;
     aURI->GetSpec(overlaySpec);
-    printf("Attempt to load overlay %s into %s\n",
-           overlaySpec.get(),
-           docSpec.get());
-    MOZ_CRASH("Attempt to load overlay");
+    nsPrintfCString msg("Attempt to load overlay %s into %s\n",
+                        overlaySpec.get(),
+                        docSpec.get());
+    nsCOMPtr<nsIConsoleService> consoleSvc =
+        do_GetService("@mozilla.org/consoleservice;1");
+    if (consoleSvc) {
+        consoleSvc->LogStringMessage(NS_ConvertASCIItoUTF16(msg).get());
+    }
+    printf("%s", msg.get());
+    return NS_ERROR_NOT_AVAILABLE;
 #endif
 
     *aShouldReturn = false;
     *aFailureFromContent = false;
 
     if (MOZ_LOG_TEST(gXULLog, LogLevel::Debug)) {
         nsCOMPtr<nsIURI> uri;
         mChannel->GetOriginalURI(getter_AddRefs(uri));