Bug 1522637 - Part 7: Perform the preloaded document swap before checking for HTTP loads, r=mconley
authorNika Layzell <nika@thelayzells.com>
Fri, 15 Feb 2019 19:49:20 +0000
changeset 459594 f7165009914357531d73574cbc8c8eb7e0a39e81
parent 459593 28d4b904c0047f86bb1ab36ac703a6724a53ae2f
child 459595 a92bdbd9b9822f7c25ddd8f5ea28187125d00f7d
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1522637
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522637 - Part 7: Perform the preloaded document swap before checking for HTTP loads, r=mconley For HTTP loads from the preloaded document, no process swap was occuring if the preloaded document was loaded in a 'web' process. This caused test failures, and has potentially undesireable behaviour. This patch just moves the check for preloaded document swaps to before the check for http parent process interception, forcing a swap like normal. Depends on D19691 Differential Revision: https://phabricator.services.mozilla.com/D19692
toolkit/modules/E10SUtils.jsm
--- a/toolkit/modules/E10SUtils.jsm
+++ b/toolkit/modules/E10SUtils.jsm
@@ -318,16 +318,30 @@ var E10SUtils = {
   },
 
   shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData) {
     // Inner frames should always load in the current process
     if (aDocShell.sameTypeParent) {
       return true;
     }
 
+    let webNav = aDocShell.QueryInterface(Ci.nsIWebNavigation);
+    let sessionHistory = webNav.sessionHistory;
+    if (!aHasPostData &&
+        Services.appinfo.remoteType == WEB_REMOTE_TYPE &&
+        sessionHistory.count == 1 &&
+        webNav.currentURI.spec == "about:newtab") {
+      // This is possibly a preloaded browser and we're about to navigate away for
+      // the first time. On the child side there is no way to tell for sure if that
+      // is the case, so let's redirect this request to the parent to decide if a new
+      // process is needed. But we don't currently properly handle POST data in
+      // redirects (bug 1457520), so if there is POST data, don't return false here.
+      return false;
+    }
+
     // If we are performing HTTP response process selection, and are loading an
     // HTTP URI, we can start the load in the current process, and then perform
     // the switch later-on using the RedirectProcessChooser mechanism.
     //
     // We should never be sending a POST request from the parent process to a
     // http(s) uri, so make sure we switch if we're currently in that process.
     if (useHttpResponseProcessSelection &&
         (aURI.scheme == "http" || aURI.scheme == "https") &&
@@ -342,43 +356,29 @@ var E10SUtils = {
     if (!aHasPostData &&
         Services.appinfo.remoteType == LARGE_ALLOCATION_REMOTE_TYPE &&
         !aDocShell.awaitingLargeAlloc &&
         aDocShell.isOnlyToplevelInTabGroup) {
       return false;
     }
 
     // Allow history load if loaded in this process before.
-    let webNav = aDocShell.QueryInterface(Ci.nsIWebNavigation);
-    let sessionHistory = webNav.sessionHistory;
     let requestedIndex = sessionHistory.legacySHistory.requestedIndex;
     if (requestedIndex >= 0) {
       if (sessionHistory.legacySHistory.getEntryAtIndex(requestedIndex).loadedInThisProcess) {
         return true;
       }
 
       // If not originally loaded in this process allow it if the URI would
       // normally be allowed to load in this process by default.
       let remoteType = Services.appinfo.remoteType;
       return remoteType ==
         this.getRemoteTypeForURIObject(aURI, true, remoteType, webNav.currentURI);
     }
 
-    if (!aHasPostData &&
-        Services.appinfo.remoteType == WEB_REMOTE_TYPE &&
-        sessionHistory.count == 1 &&
-        webNav.currentURI.spec == "about:newtab") {
-      // This is possibly a preloaded browser and we're about to navigate away for
-      // the first time. On the child side there is no way to tell for sure if that
-      // is the case, so let's redirect this request to the parent to decide if a new
-      // process is needed. But we don't currently properly handle POST data in
-      // redirects (bug 1457520), so if there is POST data, don't return false here.
-      return false;
-    }
-
     // If the URI can be loaded in the current process then continue
     return this.shouldLoadURIInThisProcess(aURI);
   },
 
   redirectLoad(aDocShell, aURI, aReferrer, aTriggeringPrincipal, aFreshProcess, aFlags) {
     // Retarget the load to the correct process
     let messageManager = aDocShell.messageManager;
     let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;