Bug 1241892 - Make View Source work in the sidebar browser. r?jryans
The sidebar browser is always non-remote, so when we open a new tab
to open view source for it, we should ensure that that tab is also
non-remote.
MozReview-Commit-ID: 3pH9okO3Boz
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2247,34 +2247,46 @@ function BrowserViewSourceOfDocument(aAr
} else {
args = aArgsOrDocument;
}
let viewInternal = () => {
let inTab = Services.prefs.getBoolPref("view_source.tab");
if (inTab) {
let tabBrowser = gBrowser;
+ let forceNotRemote = false;
+ if (!tabBrowser) {
+ if (!args.browser) {
+ throw new Error("BrowserViewSourceOfDocument should be passed the " +
+ "subject browser if called from a window without " +
+ "gBrowser defined.");
+ }
+ forceNotRemote = !args.browser.isRemoteBrowser;
+ } else {
+ // Some internal URLs (such as specific chrome: and about: URLs that are
+ // not yet remote ready) cannot be loaded in a remote browser. View
+ // source in tab expects the new view source browser's remoteness to match
+ // that of the original URL, so disable remoteness if necessary for this
+ // URL.
+ let contentProcess = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
+ forceNotRemote =
+ gMultiProcessBrowser &&
+ !E10SUtils.canLoadURIInProcess(args.URL, contentProcess)
+ }
+
// In the case of sidebars and chat windows, gBrowser is defined but null,
// because no #content element exists. For these cases, we need to find
// the most recent browser window.
// In the case of popups, we need to find a non-popup browser window.
if (!tabBrowser || !window.toolbar.visible) {
// This returns only non-popup browser windows by default.
let browserWindow = RecentWindow.getMostRecentBrowserWindow();
tabBrowser = browserWindow.gBrowser;
}
- // Some internal URLs (such as specific chrome: and about: URLs that are
- // not yet remote ready) cannot be loaded in a remote browser. View
- // source in tab expects the new view source browser's remoteness to match
- // that of the original URL, so disable remoteness if necessary for this
- // URL.
- let contentProcess = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
- let forceNotRemote =
- gMultiProcessBrowser &&
- !E10SUtils.canLoadURIInProcess(args.URL, contentProcess);
+
// `viewSourceInBrowser` will load the source content from the page
// descriptor for the tab (when possible) or fallback to the network if
// that fails. Either way, the view source module will manage the tab's
// location, so use "about:blank" here to avoid unnecessary redundant
// requests.
let tab = tabBrowser.loadOneTab("about:blank", {
relatedToCurrent: true,
inBackground: false,