Bug 1294237 - Set userContextId when DOMContentLoaded before updateBrowserRemoteness. r=mconley
authorJonathan Hao <jhao@mozilla.com>
Fri, 12 Aug 2016 02:10:00 -0400
changeset 401555 c7e5f970ee618bf454a14aae498a8031b1dfa100
parent 401554 831107a4950a1fcc7c0f86240fd9f62a165bbe88
child 401556 39949c733f5cd3651ddad754106c92086a253ae7
child 401557 c1a3f0f3a00f5f738ec03873904a2e5270d90f06
child 401562 571a6fa6581132b699001a7954bdc0f1eaa15dff
child 401574 c0988ccd418f4ed3984b3c5b1792364043f7a4fd
child 401576 8934b920346b3dc0317902b692c7b0fbb152ac70
child 401582 ebf771c42e7dd5ecdc0ff554d8f5423512f25a50
child 401587 4f01a54a9bd734f61066caeffbbe880de1deac23
child 401613 a23fe6e43bdc35856a29ac286fad8201f8d9fd06
child 401750 5aa02060f7c47a1d4c2c198c18ab7fc59771467b
push id26482
push userbmo:jbeich@FreeBSD.org
push dateWed, 17 Aug 2016 04:00:40 +0000
reviewersmconley
bugs1294237
milestone51.0a1
Bug 1294237 - Set userContextId when DOMContentLoaded before updateBrowserRemoteness. r=mconley
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -880,16 +880,27 @@ addEventListener("DOMContentLoaded", fun
         .QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsIXULWindow)
         .XULBrowserWindow = window.XULBrowserWindow;
   window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow =
     new nsBrowserAccess();
 
   let initBrowser =
     document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
+
+  // The window's first argument is a tab if and only if we are swapping tabs.
+  // We must set the browser's usercontextid before updateBrowserRemoteness(),
+  // so that the newly created remote tab child has the correct usercontextid.
+  if (window.arguments) {
+    let tabToOpen = window.arguments[0];
+    if (tabToOpen instanceof XULElement && tabToOpen.hasAttribute("usercontextid")) {
+      initBrowser.setAttribute("usercontextid", tabToOpen.getAttribute("usercontextid"));
+    }
+  }
+
   gBrowser.updateBrowserRemoteness(initBrowser, gMultiProcessBrowser);
 });
 
 var gBrowserInit = {
   delayedStartupFinished: false,
 
   onLoad: function() {
     gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver, false);