Bug 1201535 - Open view source tabs with about:blank. r=bz a=sylvestre
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 22 Sep 2015 13:33:55 -0500
changeset 289386 080829e4a7492d15f56c22264025f361d51c84c5
parent 289385 049aa80f8fa234881a87c1a276d172422b2cad24
child 289387 6c9982fcf3bc76e74d65a5e80ffc7f1e2daeb43d
push id5099
push userjryans@gmail.com
push dateSat, 26 Sep 2015 07:41:27 +0000
treeherdermozilla-beta@e46b12a6d456 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1201535
milestone42.0
Bug 1201535 - Open view source tabs with about:blank. r=bz a=sylvestre Loading a view source tab as "about:blank" gets us the fresh tab we need without making redundant requests. The view source module will retrieve the actual data as needed.
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2365,28 +2365,32 @@ function BrowserViewSourceOfDocument(aAr
     args = { browser, outerWindowID, URL };
   } else {
     args = aArgsOrDocument;
   }
 
   let viewInternal = () => {
     let inTab = Services.prefs.getBoolPref("view_source.tab");
     if (inTab) {
-      let viewSourceURL = `view-source:${args.URL}`;
       let tabBrowser = gBrowser;
       // 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;
       }
-      let tab = tabBrowser.loadOneTab(viewSourceURL, {
+      // `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
       });
       args.viewSourceBrowser = tabBrowser.getBrowserForTab(tab);
       top.gViewSourceUtils.viewSourceInBrowser(args);
     } else {
       top.gViewSourceUtils.viewSource(args);
     }