Bug 1067325 - Allow DevTools to use view source in tab. r=jsantell
--- a/browser/devtools/shared/source-utils.js
+++ b/browser/devtools/shared/source-utils.js
@@ -118,11 +118,20 @@ exports.viewSourceInScratchpad = Task.as
*
* @param {Toolbox} toolbox
* @param {string} sourceURL
* @param {number} sourceLine
*
* @return {Promise}
*/
exports.viewSource = Task.async(function *(toolbox, sourceURL, sourceLine) {
+ // Attempt to access view source via a browser first, which may display it in
+ // a tab, if enabled.
+ let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
+ if (browserWin) {
+ return browserWin.BrowserViewSourceOfDocument({
+ URL: sourceURL,
+ lineNumber: sourceLine
+ });
+ }
let utils = toolbox.gViewSourceUtils;
utils.viewSource(sourceURL, null, toolbox.doc, sourceLine || 0);
});
--- a/browser/devtools/webconsole/hudservice.js
+++ b/browser/devtools/webconsole/hudservice.js
@@ -429,16 +429,25 @@ WebConsole.prototype = {
* Open a link in Firefox's view source.
*
* @param string aSourceURL
* The URL of the file.
* @param integer aSourceLine
* The line number which should be highlighted.
*/
viewSource: function WC_viewSource(aSourceURL, aSourceLine) {
+ // Attempt to access view source via a browser first, which may display it in
+ // a tab, if enabled.
+ let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
+ if (browserWin) {
+ return browserWin.BrowserViewSourceOfDocument({
+ URL: aSourceURL,
+ lineNumber: aSourceLine
+ });
+ }
this.gViewSourceUtils.viewSource(aSourceURL, null, this.iframeWindow.document, aSourceLine || 0);
},
/**
* Tries to open a Stylesheet file related to the web page for the web console
* instance in the Style Editor. If the file is not found, it is opened in
* source view instead.
*