forked from mirrors/gecko-dev
		
	Bug 1810619 - Part 2: Get the content window from client.openWindow on geckoview, r=geckoview-reviewers,m_kato
While writing part 1 of this patch, I noticed that the geckoview code for client.openWindow was returning the outer chrome window's BrowsingContext rather than the BrowsingContext of the primary content frame when opening a pop-up window. This meant that the native code would fail to start navigating the pop-up window (as it would try to navigate the chrome window which is not allowed). It turns out the tests were still passing because the geckoview code was actually starting the load itself, though with the wrong options and properties. In this patch I remove that call to load a URI from the Java code, and fix the code in ClientOpenWindowUtils to return the content BrowsingContext instead of the chrome one. Differential Revision: https://phabricator.services.mozilla.com/D171756
This commit is contained in:
		
							parent
							
								
									d564908035
								
							
						
					
					
						commit
						0acdb79a3f
					
				
					 3 changed files with 18 additions and 6 deletions
				
			
		|  | @ -328,9 +328,9 @@ void GeckoViewOpenWindow(const ClientOpenWindowArgsParsed& aArgsValidated, | ||||||
|   promiseResult->Then( |   promiseResult->Then( | ||||||
|       GetMainThreadSerialEventTarget(), __func__, |       GetMainThreadSerialEventTarget(), __func__, | ||||||
|       [aArgsValidated, promise](nsString sessionId) { |       [aArgsValidated, promise](nsString sessionId) { | ||||||
|         // Retrieve the browsing context by using the GeckoSession ID. The
 |         // Retrieve the primary content BrowsingContext using the GeckoSession
 | ||||||
|         // window is named the same as the ID of the GeckoSession it is
 |         // ID. The chrome window is named the same as the ID of the GeckoSession
 | ||||||
|         // associated with.
 |         // it is associated with.
 | ||||||
|         RefPtr<BrowsingContext> browsingContext; |         RefPtr<BrowsingContext> browsingContext; | ||||||
|         nsresult rv = [&sessionId, &browsingContext]() -> nsresult { |         nsresult rv = [&sessionId, &browsingContext]() -> nsresult { | ||||||
|           nsresult rv; |           nsresult rv; | ||||||
|  | @ -341,8 +341,12 @@ void GeckoViewOpenWindow(const ClientOpenWindowArgsParsed& aArgsValidated, | ||||||
|           rv = wwatch->GetWindowByName(sessionId, getter_AddRefs(chromeWindow)); |           rv = wwatch->GetWindowByName(sessionId, getter_AddRefs(chromeWindow)); | ||||||
|           NS_ENSURE_SUCCESS(rv, rv); |           NS_ENSURE_SUCCESS(rv, rv); | ||||||
|           NS_ENSURE_TRUE(chromeWindow, NS_ERROR_FAILURE); |           NS_ENSURE_TRUE(chromeWindow, NS_ERROR_FAILURE); | ||||||
|           browsingContext = |           nsCOMPtr<nsIDocShellTreeOwner> treeOwner = | ||||||
|               nsPIDOMWindowOuter::From(chromeWindow)->GetBrowsingContext(); |               nsPIDOMWindowOuter::From(chromeWindow)->GetTreeOwner(); | ||||||
|  |           NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE); | ||||||
|  |           rv = treeOwner->GetPrimaryContentBrowsingContext( | ||||||
|  |               getter_AddRefs(browsingContext)); | ||||||
|  |           NS_ENSURE_SUCCESS(rv, rv); | ||||||
|           NS_ENSURE_TRUE(browsingContext, NS_ERROR_FAILURE); |           NS_ENSURE_TRUE(browsingContext, NS_ERROR_FAILURE); | ||||||
|           return NS_OK; |           return NS_OK; | ||||||
|         }(); |         }(); | ||||||
|  |  | ||||||
|  | @ -272,7 +272,6 @@ public final class GeckoRuntime implements Parcelable { | ||||||
|                         if (!session.isOpen()) { |                         if (!session.isOpen()) { | ||||||
|                           session.open(sRuntime); |                           session.open(sRuntime); | ||||||
|                         } |                         } | ||||||
|                         session.loadUri(url); |  | ||||||
|                         result.complete(session.getId()); |                         result.complete(session.getId()); | ||||||
|                       } else { |                       } else { | ||||||
|                         result.complete(null); |                         result.complete(null); | ||||||
|  |  | ||||||
|  | @ -51,6 +51,15 @@ const GeckoViewTabUtil = { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const window = await windowPromise; |     const window = await windowPromise; | ||||||
|  | 
 | ||||||
|  |     // Immediately load the URI in the browser after creating the new tab to
 | ||||||
|  |     // load into. This isn't done from the Java side to align with the
 | ||||||
|  |     // ServiceWorkerOpenWindow infrastructure which this is built on top of.
 | ||||||
|  |     window.browser.fixupAndLoadURIString(url, { | ||||||
|  |       flags: Ci.nsIWebNavigation.LOAD_FLAGS_NONE, | ||||||
|  |       triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     return window.tab; |     return window.tab; | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Nika Layzell
						Nika Layzell