Bug 1454041 - Fix view-source links from Error Console. r=jorgk a=jorgk DONTBUILD BETA_60_CONTINUATION
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 21 Jun 2018 16:44:29 +1200
branchBETA_60_CONTINUATION
changeset 32011 6f0d6ee66882
parent 32010 5bd3ff66e9cd
child 32012 c26f70927c76
push id384
push userclokep@gmail.com
push dateTue, 26 Jun 2018 01:38:29 +0000
reviewersjorgk, jorgk
bugs1454041
Bug 1454041 - Fix view-source links from Error Console. r=jorgk a=jorgk DONTBUILD
mail/base/content/mailCore.js
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -13,18 +13,33 @@
  */
 
 ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource:///modules/mailServices.js");
 
-XPCOMUtils.defineLazyScriptGetter(this, "gViewSourceUtils",
-                                  "chrome://global/content/viewSourceUtils.js");
+XPCOMUtils.defineLazyGetter(this, "gViewSourceUtils", function() {
+  let scope = {};
+  Services.scriptloader.loadSubScript("chrome://global/content/viewSourceUtils.js", scope);
+  scope.gViewSourceUtils.viewSource = async function (aArgs) {
+    // Check if external view source is enabled. If so, try it. If it fails,
+    // fallback to internal view source.
+    if (Services.prefs.getBoolPref("view_source.editor.external")) {
+      try {
+        await this.openInExternalEditor(aArgs);
+        return;
+      } catch (ex) {}
+    }
+
+    window.openDialog("chrome://messenger/content/viewSource.xul", "_blank", "all,dialog=no", aArgs);
+  };
+  return scope.gViewSourceUtils;
+});
 
 var gCustomizeSheet = false;
 
 function overlayRestoreDefaultSet() {
   let toolbox = null;
   if ("arguments" in window && window.arguments[0])
     toolbox = window.arguments[0];
   else if (window.frameElement && "toolbox" in window.frameElement)