Skip to content

Commit 4bab8b1

Browse files
committed
chore: wk webview experiment
1 parent b4d8076 commit 4bab8b1

18 files changed

Lines changed: 10629 additions & 6 deletions

File tree

packages/injected/src/injectedScript.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,9 @@ export class InjectedScript {
11121112
return;
11131113

11141114
// Playwright only issues trusted events, so allow any custom events originating from
1115-
// the page or content scripts.
1116-
if (!event.isTrusted)
1115+
// the page or content scripts. The WebView backend cannot produce trusted events, so
1116+
// it marks synthetic events with __pwTrustedSynthetic to opt back into interception.
1117+
if (!event.isTrusted && !(event as any).__pwTrustedSynthetic)
11171118
return;
11181119

11191120
// Determine the event point. Note that Firefox does not always have window.TouchEvent.

packages/playwright-core/src/client/browserType.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
150150
}
151151

152152
async _connectOverCDP(endpointURL: string, params: api.ConnectOverCDPOptions = {}): Promise<Browser> {
153-
if (this.name() !== 'chromium')
154-
throw new Error('Connecting over CDP is only supported in Chromium.');
153+
if (this.name() !== 'chromium' && this.name() !== 'webkit')
154+
throw new Error('Connecting over CDP is only supported in Chromium and WebKit.');
155155
const headers = params.headers ? headersObjectToArray(params.headers) : undefined;
156156
const result = await this._channel.connectOverCDP({
157157
endpointURL,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*]
2+
@isomorphic/**
3+
@utils/**
4+
../
5+
../registry/
6+
node_modules/jpeg-js
7+
node_modules/pngjs
8+
9+
[webkit.ts]
10+
./webview/wvBrowser.ts

packages/playwright-core/src/server/webkit/webkit.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ import path from 'path';
2020
import { wrapInASCIIBox } from '@utils/ascii';
2121
import { spawnAsync } from '@utils/spawnAsync';
2222
import { kBrowserCloseMessageId } from './wkConnection';
23+
import { Browser } from '../browser';
2324
import { BrowserType, kNoXServerRunningError } from '../browserType';
24-
import { WKBrowser } from '../webkit/wkBrowser';
25+
import { WKBrowser } from './wkBrowser';
26+
import { connectOverRDP } from './webview/wvBrowser';
2527

2628
import type { BrowserOptions } from '../browser';
2729
import type { SdkObject } from '../instrumentation';
30+
import type { Progress } from '../progress';
2831
import type { ConnectionTransport } from '../transport';
2932
import type * as types from '../types';
3033

@@ -37,6 +40,10 @@ export class WebKit extends BrowserType {
3740
return WKBrowser.connect(this.attribution.playwright, transport, options);
3841
}
3942

43+
override async connectOverCDP(progress: Progress, endpointURL: string, options: { slowMo?: number, headers?: types.HeadersArray, isLocal?: boolean, noDefaults?: boolean }): Promise<Browser> {
44+
return connectOverRDP(progress, this, endpointURL, options);
45+
}
46+
4047
override amendEnvironment(env: NodeJS.ProcessEnv, userDataDir: string, isPersistent: boolean, options: types.LaunchOptions): NodeJS.ProcessEnv {
4148
return {
4249
...env,

0 commit comments

Comments
 (0)