diff --git a/packages/playwright-core/src/server/webkit/webview/wvBrowser.ts b/packages/playwright-core/src/server/webkit/webview/wvBrowser.ts index 4bbdc1833b014..8aa5db558ca51 100644 --- a/packages/playwright-core/src/server/webkit/webview/wvBrowser.ts +++ b/packages/playwright-core/src/server/webkit/webview/wvBrowser.ts @@ -241,7 +241,6 @@ export class WVBrowser extends Browser { this._dialogBridge.registerTab(pageId, req => page.onBridgeDialog(req)); this._tabs.set(pageId, { pageId, transport, connection, page }); transport.open?.(); - connection.outerSession.sendMayFail('Target.setPauseOnStart', { pauseOnStart: true }); await page.waitForInitialized(); } diff --git a/packages/playwright-core/src/server/webkit/webview/wvPage.ts b/packages/playwright-core/src/server/webkit/webview/wvPage.ts index d678d3ce0e7d8..547e4db6548d2 100644 --- a/packages/playwright-core/src/server/webkit/webview/wvPage.ts +++ b/packages/playwright-core/src/server/webkit/webview/wvPage.ts @@ -54,6 +54,7 @@ export class WVPage implements PageDelegate { readonly rawKeyboard: RawKeyboardImpl; readonly rawTouchscreen: RawTouchscreenImpl; private _session!: WVSession; + private _sentPauseOnStart = false; private readonly _outerSession: WVSession; private _provisionalPage: WVProvisionalPage | null = null; readonly _page: Page; @@ -265,6 +266,13 @@ export class WVPage implements PageDelegate { } private async _onTargetCreated(event: Protocol.Target.targetCreatedPayload) { + // The Target domain only exists for the top-level web-page target, so send it as soon as we know it exists. + // Commands sent before the first Target.targetCreated event may be silently dropped as targets may not exist yet. + if (!this._sentPauseOnStart) { + this._sentPauseOnStart = true; + await this._outerSession.sendMayFail('Target.setPauseOnStart', { pauseOnStart: true }); + } + const { targetInfo } = event; if (targetInfo.type !== 'page') { // Site-isolated WebKit (iOS 26+) reports a separate target per frame. We diff --git a/tests/webview/expectations/webkit-webview-page.txt b/tests/webview/expectations/webkit-webview-page.txt index ff586e2079071..af49d4ab36dca 100644 --- a/tests/webview/expectations/webkit-webview-page.txt +++ b/tests/webview/expectations/webkit-webview-page.txt @@ -382,7 +382,6 @@ page/page-event-request.spec.ts › should finish 204 request [fail] page/page-event-request.spec.ts › should fire requestfailed when intercepting race [fail] page/page-event-request.spec.ts › should report navigation requests and responses handled by service worker with routing [fail] page/page-event-request.spec.ts › should return response body when Cross-Origin-Opener-Policy is set [fail] -page/page-expose-function.spec.ts › should work after cross origin navigation [fail] page/page-expose-function.spec.ts › should work with busted Array.prototype.map/push [fail] page/page-expose-function.spec.ts › should work with overridden console object [fail] page/page-fill.spec.ts › should throw on incorrect date [fail] @@ -398,7 +397,6 @@ page/page-goto.spec.ts › should fail when navigating and show the url at the e page/page-goto.spec.ts › should fail when navigating to bad SSL [fail] page/page-goto.spec.ts › should fail when navigating to bad SSL after redirects [fail] page/page-goto.spec.ts › should fail when server returns 204 [fail] -page/page-goto.spec.ts › should work cross-process [fail] page/page-goto.spec.ts › should work with Cross-Origin-Opener-Policy [fail] page/page-goto.spec.ts › should work with Cross-Origin-Opener-Policy after redirect [fail] page/page-goto.spec.ts › should work with Cross-Origin-Opener-Policy and interception [fail] @@ -667,77 +665,34 @@ page/page-fill.spec.ts › should throw on incorrect datetime-local [fail] # leaves the page target dead for the next test's first navigation (see the # worker-remaining section). Re-run and prune this section as triggers are fixed. # ============================================================================ -# These two pass in isolation but their cross-process/cross-site MAIN navigation -# leaves the page target dead for the following test in the file, so they stay -# skipped with the rest of the cascade triggers. -page/frame-evaluate.spec.ts › should execute after cross-site navigation [fail] -page/frame-hierarchy.spec.ts › should persist mainFrame on cross-process navigation [fail] -page/elementhandle-click.spec.ts › should work @smoke [fail] page/elementhandle-owner-frame.spec.ts › should work for adopted elements [fail] page/elementhandle-query-selector.spec.ts › should work for adopted elements [fail] page/elementhandle-scroll-into-view.spec.ts › should scroll display:contents into view [fail] page/frame-hierarchy.spec.ts › should send "framenavigated" when navigating on anchor URLs [fail] -page/interception.spec.ts › should intercept network activity from worker [fail] page/interception.spec.ts › should intercept worker requests when enabled after worker creation [fail] -page/interception.spec.ts › should work with navigation @smoke [fail] -page/locator-frame.spec.ts › frameLocator.owner should work [fail] -page/locator-frame.spec.ts › locator.contentFrame should work [fail] -page/locator-frame.spec.ts › should work for $ and $$ [fail] -page/locator-misc-2.spec.ts › Locator.locator() and FrameLocator.locator() should accept locator [fail] page/network-post-data.spec.ts › should get post data for file/blob [fail] page/network-post-data.spec.ts › should get post data for navigator.sendBeacon api calls [fail] -page/page-add-init-script.spec.ts › should remove init script after dispose [fail] page/page-add-init-script.spec.ts › should work after a cross origin navigation [fail] page/page-autowaiting-basic.spec.ts › should await cross-process navigation when clicking anchor [fail] page/page-autowaiting-basic.spec.ts › should await form-get on click [fail] -page/page-autowaiting-no-hang.spec.ts › clicking in the middle of navigation that commits [fail] -page/page-autowaiting-no-hang.spec.ts › goBack in the middle of navigation that commits [fail] page/page-basic.spec.ts › frame.press should work [fail] page/page-basic.spec.ts › page.close should work with window.close [fail] page/page-basic.spec.ts › should provide access to the opener page [fail] page/page-click-scroll.spec.ts › should scroll into view display:contents [fail] page/page-click-scroll.spec.ts › should scroll into view display:contents with position [fail] -page/page-click-timeout-1.spec.ts › should avoid side effects after timeout [fail] -page/page-click-timeout-3.spec.ts › should fail when element jumps during hit testing [fail] page/page-click.spec.ts › should click a very large button with offset [fail] -page/page-click.spec.ts › should click the button after a cross origin navigation [fail] page/page-click.spec.ts › should click the button when window.innerWidth is corrupted [fail] page/page-click.spec.ts › should select the text by triple clicking [fail] -page/page-dispatchevent.spec.ts › should dispatch click after a cross origin navigation [fail] -page/page-dispatchevent.spec.ts › should dispatch click after navigation [fail] page/page-dispatchevent.spec.ts › should dispatch click when node is added in shadow dom [fail] -page/page-dispatchevent.spec.ts › should throw if argument is from different frame [fail] -page/page-evaluate.spec.ts › should evaluate in the page context [fail] page/page-evaluate.spec.ts › should not throw an error when evaluation does a navigation [fail] page/page-evaluate.spec.ts › should transfer 100Mb of data from page to node.js [fail] -page/page-evaluate.spec.ts › should work right after a cross-origin navigation [fail] -page/page-expose-function.spec.ts › should alias Window, Document and Node [fail] -page/page-expose-function.spec.ts › should await returned promise [fail] -page/page-expose-function.spec.ts › should serialize cycles [fail] -page/page-expose-function.spec.ts › should survive navigation [fail] page/page-expose-function.spec.ts › should work on frames [fail] page/page-expose-function.spec.ts › should work on frames before navigation [fail] -page/page-expose-function.spec.ts › should work with complex objects [fail] -page/page-expose-function.spec.ts › should work with setContent [fail] page/page-goto.spec.ts › js redirect overrides url bar navigation [fail] -# First does a cross-origin navigation that kills the page target; second is a -# plain navigation that inherits 'Target closed' when it runs after such a -# trigger. Keep skipped until cross-process navigation stops tearing down the -# session. -page/page-goto.spec.ts › should not crash when navigating to bad SSL after a cross origin navigation [fail] -page/page-goto.spec.ts › should not throw if networkidle0 is passed as an option [fail] page/page-request-fulfill.spec.ts › should fulfill preload link requests [fail] -page/page-request-intercept.spec.ts › should give access to the intercepted response [fail] -page/page-request-intercept.spec.ts › should intercept with post data override [fail] -page/page-route.spec.ts › should be able to intercept every navigation to a page controlled by service worker [fail] -page/page-route.spec.ts › should intercept main resource during cross-process navigation [fail] page/page-route.spec.ts › should not fulfill with redirect status [fail] -page/page-route.spec.ts › should not throw if request was cancelled by the page [fail] page/page-screenshot.spec.ts › page screenshot animations › should trigger particular events for INfinite css animation [fail] -page/page-screenshot.spec.ts › page screenshot animations › should trigger particular events for css transitions [fail] page/page-screenshot.spec.ts › page screenshot animations › should trigger particular events for finite css animation [fail] -page/page-screenshot.spec.ts › page screenshot › mask option › should work when subframe has stalled navigation [fail] -page/page-wait-for-function.spec.ts › should survive cross-process navigation [fail] page/page-wait-for-function.spec.ts › should survive navigations [fail] page/page-wait-for-load-state.spec.ts › should wait for load state of about:blank popup [fail] page/page-wait-for-load-state.spec.ts › should wait for load state of about:blank popup with noopener [fail] @@ -745,30 +700,15 @@ page/page-wait-for-load-state.spec.ts › should wait for load state of popup wi page/page-wait-for-load-state.spec.ts › should wait for load state of popup with network url and noopener [fail] page/page-wait-for-load-state.spec.ts › should work with clicking target=_blank [fail] page/page-wait-for-load-state.spec.ts › should work with pages that have loaded before being connected to [fail] -page/page-wait-for-navigation.spec.ts › should work for cross-process navigations [fail] page/page-wait-for-navigation.spec.ts › should work on frame [fail] page/page-wait-for-navigation.spec.ts › should work with clicking on anchor links [fail] page/page-wait-for-navigation.spec.ts › should work with history.pushState() [fail] page/page-wait-for-navigation.spec.ts › should work with history.replaceState() [fail] page/page-wait-for-navigation.spec.ts › should work with url match for same document navigations [fail] page/page-wait-for-selector-2.spec.ts › should support >> selector syntax [fail] -page/page-wait-for-selector-2.spec.ts › should survive cross-process navigation [fail] page/page-wait-for-url.spec.ts › should work with clicking on anchor links [fail] page/page-wait-for-url.spec.ts › should work with history.pushState() [fail] page/page-wait-for-url.spec.ts › should work with history.replaceState() [fail] page/page-wait-for-url.spec.ts › should work with url match for same document navigations [fail] page/retarget.spec.ts › should check the box outside shadow dom label [fail] -page/selectors-frame.spec.ts › should work for $ and $$ [fail] -# ============================================================================ -# worker-remaining (2 tests) -# Web Workers attach over the WebView backend now (Worker.enable is sent during -# session init), so page/workers.spec.ts mostly passes. Two gaps remain: -# - 'should clear upon cross-process navigation' passes its own assertions but -# the cross-process target swap leaves the page in a 'Target closed' state for -# the next test (same root cause as target-closed-cascade above). -# - 'should support extra http headers': setExtraHTTPHeaders is not applied to -# the worker script request, so worker.js arrives without the header. -# ============================================================================ -page/workers.spec.ts › should clear upon cross-process navigation [fail] -page/workers.spec.ts › should support extra http headers [fail]