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 783782 1145c902b1ec4f09ba245fb35465a8c1e9db240e
parent 783549 f94b64e0020225c71701930f193bd96c3ad1d150
push id106776
push userbmo:gijskruitbosch+bugs@gmail.com
push dateTue, 17 Apr 2018 17:37:52 +0000
reviewersmystor
bugs1451625
milestone61.0a1
Bug 1451625 - Error on overlay load instead of crash. r?mystor MozReview-Commit-ID: 4OHBlsTmqik
dom/xul/XULDocument.cpp
dom/xul/moz.build
--- 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
 //
@@ -2254,28 +2255,38 @@ XULDocument::LoadOverlay(const nsAString
 nsresult
 XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
                                  bool* aShouldReturn,
                                  bool* aFailureFromContent)
 {
     nsresult rv;
 
     // XUL overlays are in the process of being removed. In a Firefox build,
-    // loading an overlay will cause a crash as they are no longer allowed.
+    // loading an overlay will no longer work and display an error in the
+    // console. In automation, doing so will cause a crash.
     // However, overlays are allowed in other applications (e.g. Thunderbird)
     // while they work on removing them. See bug 1448162.
-#ifdef MOZ_CRASH_XUL_OVERLAYS
+#ifdef MOZ_BREAK_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());
+    if (xpc::IsInAutomation()) {
+        MOZ_CRASH("Attempt to load overlay.");
+    }
+    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));
--- a/dom/xul/moz.build
+++ b/dom/xul/moz.build
@@ -3,17 +3,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "XUL")
 
 if CONFIG['MOZ_BUILD_APP'] == 'browser':
-    DEFINES['MOZ_CRASH_XUL_OVERLAYS'] = True
+    DEFINES['MOZ_BREAK_XUL_OVERLAYS'] = True
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 
 if CONFIG['MOZ_XUL']:
     XPIDL_SOURCES += [
         'nsIXULOverlayProvider.idl',