Skip to content

Commit d20f3ca

Browse files
authored
feat(webkit): no start window, healthy pipe (#1113)
1 parent b8c6069 commit d20f3ca

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"playwright": {
1111
"chromium_revision": "744254",
1212
"firefox_revision": "1031",
13-
"webkit_revision": "1155"
13+
"webkit_revision": "1159"
1414
},
1515
"scripts": {
1616
"ctest": "cross-env BROWSER=chromium node test/test.js",

src/server/webkit.ts

+10-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as types from '../types';
2222
import { WKBrowser } from '../webkit/wkBrowser';
2323
import { execSync } from 'child_process';
2424
import { PipeTransport } from './pipeTransport';
25-
import { launchProcess, waitForLine } from './processLauncher';
25+
import { launchProcess } from './processLauncher';
2626
import * as fs from 'fs';
2727
import * as path from 'path';
2828
import * as platform from '../platform';
@@ -31,7 +31,7 @@ import * as os from 'os';
3131
import { assert, helper } from '../helper';
3232
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
3333
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
34-
import { ConnectionTransport, DeferWriteTransport } from '../transport';
34+
import { ConnectionTransport } from '../transport';
3535
import * as ws from 'ws';
3636
import * as uuidv4 from 'uuid/v4';
3737
import { ConnectOptions, LaunchType } from '../browser';
@@ -108,9 +108,9 @@ export class WebKit implements BrowserType {
108108

109109
const webkitArguments = [];
110110
if (!ignoreDefaultArgs)
111-
webkitArguments.push(...this._defaultArgs(options, userDataDir!, port || 0));
111+
webkitArguments.push(...this._defaultArgs(options, launchType, userDataDir!, port || 0));
112112
else if (Array.isArray(ignoreDefaultArgs))
113-
webkitArguments.push(...this._defaultArgs(options, userDataDir!, port || 0).filter(arg => ignoreDefaultArgs.indexOf(arg) === -1));
113+
webkitArguments.push(...this._defaultArgs(options, launchType, userDataDir!, port || 0).filter(arg => ignoreDefaultArgs.indexOf(arg) === -1));
114114
else
115115
webkitArguments.push(...args);
116116

@@ -149,9 +149,7 @@ export class WebKit implements BrowserType {
149149
},
150150
});
151151

152-
const timeoutError = new TimeoutError(`Timed out after ${timeout} ms while trying to connect to WebKit! The only WebKit revision guaranteed to work is r${this._revision}`);
153-
await waitForLine(launchedProcess, launchedProcess.stdout, /^Web Inspector is reading from pipe #3$/, timeout, timeoutError);
154-
transport = new DeferWriteTransport(new PipeTransport(launchedProcess.stdio[3] as NodeJS.WritableStream, launchedProcess.stdio[4] as NodeJS.ReadableStream));
152+
transport = new PipeTransport(launchedProcess.stdio[3] as NodeJS.WritableStream, launchedProcess.stdio[4] as NodeJS.ReadableStream);
155153
browserServer = new BrowserServer(launchedProcess, gracefullyClose, launchType === 'server' ? await wrapTransportWithWebSocket(transport, port || 0) : null);
156154
return { browserServer, transport };
157155
}
@@ -173,7 +171,7 @@ export class WebKit implements BrowserType {
173171
return { TimeoutError };
174172
}
175173

176-
_defaultArgs(options: BrowserArgOptions = {}, userDataDir: string, port: number): string[] {
174+
_defaultArgs(options: BrowserArgOptions = {}, launchType: LaunchType, userDataDir: string, port: number): string[] {
177175
const {
178176
devtools = false,
179177
headless = !devtools,
@@ -187,7 +185,10 @@ export class WebKit implements BrowserType {
187185
const webkitArguments = ['--inspector-pipe'];
188186
if (headless)
189187
webkitArguments.push('--headless');
190-
webkitArguments.push(`--user-data-dir=${userDataDir}`);
188+
if (launchType === 'persistent')
189+
webkitArguments.push(`--user-data-dir=${userDataDir}`);
190+
else
191+
webkitArguments.push(`--no-startup-window`);
191192
webkitArguments.push(...args);
192193
return webkitArguments;
193194
}
@@ -361,18 +362,6 @@ async function wrapTransportWithWebSocket(transport: ConnectionTransport, port:
361362
return;
362363
}
363364
sockets.add(socket);
364-
// Following two messages are reporting the default browser context and the default page.
365-
socket.send(JSON.stringify({
366-
method: 'Browser.pageProxyCreated',
367-
params: { pageProxyInfo: { pageProxyId: '5', browserContextId: '0000000000000002' } }
368-
}));
369-
socket.send(JSON.stringify({
370-
method: 'Target.targetCreated',
371-
params: {
372-
targetInfo: { targetId: 'page-6', type: 'page', isPaused: false }
373-
},
374-
pageProxyId: '5'
375-
}));
376365

377366
socket.on('message', (message: string) => {
378367
const parsedMessage = JSON.parse(Buffer.from(message).toString());

0 commit comments

Comments
 (0)