Bug 1456254 - Correctly set nextTabParentId in GeckoView r=esawin
authorJames Willcox <snorp@snorp.net>
Mon, 23 Apr 2018 15:07:46 -0500
changeset 472588 de23cd2fcc4af28ff67e24411e0282001a9a94c2
parent 472587 7d2f05a827f3a2b03e8407ba9d92546c85fd3f27
child 472589 5cdb10268f47f90d0e5610d7e714f3a4d4be16d6
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1456254
milestone61.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 1456254 - Correctly set nextTabParentId in GeckoView r=esawin MozReview-Commit-ID: IDh10RkeUpY
mobile/android/modules/geckoview/GeckoViewNavigation.jsm
--- a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
@@ -87,56 +87,62 @@ class GeckoViewNavigation extends GeckoV
     }
   }
 
   // Message manager event handler.
   receiveMessage(aMsg) {
     debug `receiveMessage: ${aMsg.name}`;
   }
 
-  waitAndSetOpener(aSessionId, aOpener) {
+  waitAndSetupWindow(aSessionId, { opener, nextTabParentId }) {
     if (!aSessionId) {
       return Promise.resolve(null);
     }
 
     return new Promise(resolve => {
       const handler = {
         observe(aSubject, aTopic, aData) {
           if (aTopic === "geckoview-window-created" && aSubject.name === aSessionId) {
-            if (aOpener) {
-              aSubject.browser.presetOpenerWindow(aOpener);
+            if (nextTabParentId) {
+              aSubject.browser.setAttribute("nextTabParentId", nextTabParentId.toString());
+            }
+
+            if (opener) {
+              aSubject.browser.presetOpenerWindow(opener);
             }
             Services.obs.removeObserver(handler, "geckoview-window-created");
             resolve(aSubject);
           }
         }
       };
 
       // This event is emitted from createBrowser() in geckoview.js
       Services.obs.addObserver(handler, "geckoview-window-created");
     });
   }
 
-  handleNewSession(aUri, aOpener, aWhere, aFlags, aTriggeringPrincipal) {
+  handleNewSession(aUri, aOpener, aWhere, aFlags, aNextTabParentId) {
     debug `handleNewSession: uri=${aUri && aUri.spec}
                              where=${aWhere} flags=${aFlags}`;
 
     if (!this.isRegistered) {
       return null;
     }
 
     const message = {
       type: "GeckoView:OnNewSession",
       uri: aUri ? aUri.displaySpec : ""
     };
 
     let browser = undefined;
     this.eventDispatcher.sendRequestForResult(message).then(sessionId => {
-      return this.waitAndSetOpener(sessionId,
-        (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER) ? null : aOpener);
+      return this.waitAndSetupWindow(sessionId, {
+        opener: (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER) ? null : aOpener,
+        nextTabParentId: aNextTabParentId
+      });
     }).then(window => {
       browser = (window && window.browser);
     }, () => {
       browser = null;
     });
 
     // Wait indefinitely for app to respond with a browser or null
     Services.tm.spinEventLoopUntil(() => browser !== undefined);
@@ -150,18 +156,17 @@ class GeckoViewNavigation extends GeckoV
 
     if (LoadURIDelegate.load(this.eventDispatcher, aUri, aWhere, aFlags,
                              aTriggeringPrincipal)) {
       // The app has handled the load, abort open-window handling.
       Components.returnCode = Cr.NS_ERROR_ABORT;
       return null;
     }
 
-    const browser = this.handleNewSession(aUri, aOpener, aWhere, aFlags,
-                                          aTriggeringPrincipal);
+    const browser = this.handleNewSession(aUri, aOpener, aWhere, aFlags, null);
     if (!browser) {
       Components.returnCode = Cr.NS_ERROR_ABORT;
       return null;
     }
 
     return browser.contentWindow;
   }
 
@@ -175,23 +180,22 @@ class GeckoViewNavigation extends GeckoV
                                        name=${aName}`;
 
     if (LoadURIDelegate.load(this.eventDispatcher, aUri, aWhere, aFlags, null)) {
       // The app has handled the load, abort open-window handling.
       Components.returnCode = Cr.NS_ERROR_ABORT;
       return null;
     }
 
-    const browser = this.handleNewSession(aUri, null, aWhere, aFlags, null);
+    const browser = this.handleNewSession(aUri, null, aWhere, aFlags, aNextTabParentId);
     if (!browser) {
       Components.returnCode = Cr.NS_ERROR_ABORT;
       return null;
     }
 
-    browser.setAttribute("nextTabParentId", aNextTabParentId);
     return browser;
   }
 
   handleOpenUri(aUri, aOpener, aWhere, aFlags, aTriggeringPrincipal,
                 aNextTabParentId) {
     debug `handleOpenUri: uri=${aUri && aUri.spec}
                           where=${aWhere} flags=${aFlags}`;