Bug 1067325 - Allow DevTools to use view source in tab. r=jsantell

This commit is contained in:
J. Ryan Stinnett 2015-05-23 18:17:50 -05:00
parent 6e6443b342
commit f4f438183c
2 changed files with 18 additions and 0 deletions

View File

@ -123,6 +123,15 @@ exports.viewSourceInScratchpad = Task.async(function *(sourceURL, 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);
});

View File

@ -434,6 +434,15 @@ WebConsole.prototype = {
* 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);
},