Fix Google sign-in infinite loading in browser pane (#1493)
* Add regression test for Google sign-in popup fallback (#1491) * Fix Google sign-in popup routing regression (#1491)
This commit is contained in:
parent
bd1788639d
commit
2e4c482c21
2 changed files with 32 additions and 4 deletions
|
|
@ -4654,6 +4654,14 @@ func browserNavigationShouldCreatePopup(
|
|||
return navigationType == .other && !isUserNewTab
|
||||
}
|
||||
|
||||
func browserNavigationShouldFallbackNilTargetToNewTab(
|
||||
navigationType: WKNavigationType
|
||||
) -> Bool {
|
||||
// Scripted popups rely on WKUIDelegate.createWebViewWith returning a live
|
||||
// web view so window.opener/postMessage remain intact across OAuth flows.
|
||||
navigationType != .other
|
||||
}
|
||||
|
||||
private class BrowserNavigationDelegate: NSObject, WKNavigationDelegate {
|
||||
var didFinish: ((WKWebView) -> Void)?
|
||||
var didFailNavigation: ((WKWebView, String) -> Void)?
|
||||
|
|
@ -4891,11 +4899,13 @@ private class BrowserNavigationDelegate: NSObject, WKNavigationDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
// Catch-all for nil-target navigations where createWebViewWith
|
||||
// returned nil: external URLs, user-initiated new-window actions
|
||||
// (target=_blank, context menu) that fall through the classifier,
|
||||
// or when popup creation is unavailable.
|
||||
// target=_blank link navigations should open in a new tab.
|
||||
// Scripted popups (navigationType == .other) are handled in
|
||||
// WKUIDelegate.createWebViewWith so OAuth opener linkage survives.
|
||||
if navigationAction.targetFrame == nil,
|
||||
browserNavigationShouldFallbackNilTargetToNewTab(
|
||||
navigationType: navigationAction.navigationType
|
||||
),
|
||||
let url = navigationAction.request.url {
|
||||
#if DEBUG
|
||||
dlog("browser.nav.decidePolicy.action kind=openInNewTabFromNilTarget url=\(url.absoluteString)")
|
||||
|
|
|
|||
|
|
@ -2659,6 +2659,24 @@ final class BrowserPopupDecisionTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
final class BrowserNilTargetFallbackDecisionTests: XCTestCase {
|
||||
func testOtherNavigationDoesNotFallbackToNewTab() {
|
||||
XCTAssertFalse(
|
||||
browserNavigationShouldFallbackNilTargetToNewTab(
|
||||
navigationType: .other
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
func testLinkActivatedNavigationFallsBackToNewTab() {
|
||||
XCTAssertTrue(
|
||||
browserNavigationShouldFallbackNilTargetToNewTab(
|
||||
navigationType: .linkActivated
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
final class BrowserPopupContentRectTests: XCTestCase {
|
||||
func testExplicitTopOriginCoordinatesConvertToAppKitBottomOrigin() {
|
||||
let rect = browserPopupContentRect(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue