Bug 1454041 - Follow-up: Part 2 - Fix view-source links from Error Console. r=jorgk a=jorgk BETA_60_CONTINUATION
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 25 Jun 2018 12:54:10 +1200
branchBETA_60_CONTINUATION
changeset 32015 30ecc44d5bf4
parent 32014 516fa9132deb
child 32016 f06066471eae
push id384
push userclokep@gmail.com
push date2018-06-26 01:38 +0000
reviewersjorgk, jorgk
bugs1454041
Bug 1454041 - Follow-up: Part 2 - Fix view-source links from Error Console. r=jorgk a=jorgk
mail/components/devtools/webconsole-overlay.xul
--- a/mail/components/devtools/webconsole-overlay.xul
+++ b/mail/components/devtools/webconsole-overlay.xul
@@ -2,11 +2,30 @@
 <!-- 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/. -->
 
 <!DOCTYPE overlay SYSTEM "chrome://messenger/locale/messenger.dtd">
 
 <overlay id="tb-webconsole-overlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script type="application/javascript" src="chrome://global/content/viewSourceUtils.js"/>
+  <script type="application/javascript"><![CDATA[
+    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+    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;
+    });
+  ]]></script>
   <window id="devtools-webconsole" browserConsoleTitle="&errorConsoleCmd.label;"/>
 </overlay>