From cffe7b65e3ffb713a1f7138d5e881cbba20a569c Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 30 Jan 2023 11:13:56 -0800 Subject: [PATCH] fix: do not hang on submitting target=_blank form (#20458) Fixes #18392 --- packages/playwright-core/src/server/webkit/wkPage.ts | 7 ++++--- tests/page/page-navigation.spec.ts | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.ts index cfb3506dc9..c4cf4059b8 100644 --- a/packages/playwright-core/src/server/webkit/wkPage.ts +++ b/packages/playwright-core/src/server/webkit/wkPage.ts @@ -379,7 +379,7 @@ export class WKPage implements PageDelegate { eventsHelper.addEventListener(this._session, 'Page.frameDetached', event => this._onFrameDetached(event.frameId)), eventsHelper.addEventListener(this._session, 'Page.willCheckNavigationPolicy', event => this._onWillCheckNavigationPolicy(event.frameId)), eventsHelper.addEventListener(this._session, 'Page.didCheckNavigationPolicy', event => this._onDidCheckNavigationPolicy(event.frameId, event.cancel)), - eventsHelper.addEventListener(this._session, 'Page.frameScheduledNavigation', event => this._onFrameScheduledNavigation(event.frameId)), + eventsHelper.addEventListener(this._session, 'Page.frameScheduledNavigation', event => this._onFrameScheduledNavigation(event.frameId, event.delay, event.targetIsCurrentFrame)), eventsHelper.addEventListener(this._session, 'Page.loadEventFired', event => this._page._frameManager.frameLifecycleEvent(event.frameId, 'load')), eventsHelper.addEventListener(this._session, 'Page.domContentEventFired', event => this._page._frameManager.frameLifecycleEvent(event.frameId, 'domcontentloaded')), eventsHelper.addEventListener(this._session, 'Runtime.executionContextCreated', event => this._onExecutionContextCreated(event.context)), @@ -445,8 +445,9 @@ export class WKPage implements PageDelegate { this._page._frameManager.frameAbortedNavigation(frameId, 'Navigation canceled by policy check'); } - private _onFrameScheduledNavigation(frameId: string) { - this._page._frameManager.frameRequestedNavigation(frameId); + private _onFrameScheduledNavigation(frameId: string, delay: number, targetIsCurrentFrame: boolean) { + if (targetIsCurrentFrame) + this._page._frameManager.frameRequestedNavigation(frameId); } private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree) { diff --git a/tests/page/page-navigation.spec.ts b/tests/page/page-navigation.spec.ts index eb85adad01..a4a0942b17 100644 --- a/tests/page/page-navigation.spec.ts +++ b/tests/page/page-navigation.spec.ts @@ -33,9 +33,8 @@ it('should work with cross-process _blank target', async ({ page, server }) => { await page.click('"Click me"'); }); -it('should work with _blank target in form', async ({ page, server, browserName }) => { +it('should work with _blank target in form', async ({ page, server }) => { it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18392' }); - it.fixme(browserName === 'webkit'); server.setRoute('/done.html?', (req, res) => { res.end(`Done`); });