mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(webkit): no start window, healthy pipe (#1113)
This commit is contained in:
parent
b8c6069853
commit
d20f3cac89
@ -10,7 +10,7 @@
|
|||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "744254",
|
"chromium_revision": "744254",
|
||||||
"firefox_revision": "1031",
|
"firefox_revision": "1031",
|
||||||
"webkit_revision": "1155"
|
"webkit_revision": "1159"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
||||||
|
@ -22,7 +22,7 @@ import * as types from '../types';
|
|||||||
import { WKBrowser } from '../webkit/wkBrowser';
|
import { WKBrowser } from '../webkit/wkBrowser';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { PipeTransport } from './pipeTransport';
|
import { PipeTransport } from './pipeTransport';
|
||||||
import { launchProcess, waitForLine } from './processLauncher';
|
import { launchProcess } from './processLauncher';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as platform from '../platform';
|
import * as platform from '../platform';
|
||||||
@ -31,7 +31,7 @@ import * as os from 'os';
|
|||||||
import { assert, helper } from '../helper';
|
import { assert, helper } from '../helper';
|
||||||
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
|
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
|
||||||
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
|
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
|
||||||
import { ConnectionTransport, DeferWriteTransport } from '../transport';
|
import { ConnectionTransport } from '../transport';
|
||||||
import * as ws from 'ws';
|
import * as ws from 'ws';
|
||||||
import * as uuidv4 from 'uuid/v4';
|
import * as uuidv4 from 'uuid/v4';
|
||||||
import { ConnectOptions, LaunchType } from '../browser';
|
import { ConnectOptions, LaunchType } from '../browser';
|
||||||
@ -108,9 +108,9 @@ export class WebKit implements BrowserType {
|
|||||||
|
|
||||||
const webkitArguments = [];
|
const webkitArguments = [];
|
||||||
if (!ignoreDefaultArgs)
|
if (!ignoreDefaultArgs)
|
||||||
webkitArguments.push(...this._defaultArgs(options, userDataDir!, port || 0));
|
webkitArguments.push(...this._defaultArgs(options, launchType, userDataDir!, port || 0));
|
||||||
else if (Array.isArray(ignoreDefaultArgs))
|
else if (Array.isArray(ignoreDefaultArgs))
|
||||||
webkitArguments.push(...this._defaultArgs(options, userDataDir!, port || 0).filter(arg => ignoreDefaultArgs.indexOf(arg) === -1));
|
webkitArguments.push(...this._defaultArgs(options, launchType, userDataDir!, port || 0).filter(arg => ignoreDefaultArgs.indexOf(arg) === -1));
|
||||||
else
|
else
|
||||||
webkitArguments.push(...args);
|
webkitArguments.push(...args);
|
||||||
|
|
||||||
@ -149,9 +149,7 @@ export class WebKit implements BrowserType {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
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}`);
|
transport = new PipeTransport(launchedProcess.stdio[3] as NodeJS.WritableStream, launchedProcess.stdio[4] as NodeJS.ReadableStream);
|
||||||
await waitForLine(launchedProcess, launchedProcess.stdout, /^Web Inspector is reading from pipe #3$/, timeout, timeoutError);
|
|
||||||
transport = new DeferWriteTransport(new PipeTransport(launchedProcess.stdio[3] as NodeJS.WritableStream, launchedProcess.stdio[4] as NodeJS.ReadableStream));
|
|
||||||
browserServer = new BrowserServer(launchedProcess, gracefullyClose, launchType === 'server' ? await wrapTransportWithWebSocket(transport, port || 0) : null);
|
browserServer = new BrowserServer(launchedProcess, gracefullyClose, launchType === 'server' ? await wrapTransportWithWebSocket(transport, port || 0) : null);
|
||||||
return { browserServer, transport };
|
return { browserServer, transport };
|
||||||
}
|
}
|
||||||
@ -173,7 +171,7 @@ export class WebKit implements BrowserType {
|
|||||||
return { TimeoutError };
|
return { TimeoutError };
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaultArgs(options: BrowserArgOptions = {}, userDataDir: string, port: number): string[] {
|
_defaultArgs(options: BrowserArgOptions = {}, launchType: LaunchType, userDataDir: string, port: number): string[] {
|
||||||
const {
|
const {
|
||||||
devtools = false,
|
devtools = false,
|
||||||
headless = !devtools,
|
headless = !devtools,
|
||||||
@ -187,7 +185,10 @@ export class WebKit implements BrowserType {
|
|||||||
const webkitArguments = ['--inspector-pipe'];
|
const webkitArguments = ['--inspector-pipe'];
|
||||||
if (headless)
|
if (headless)
|
||||||
webkitArguments.push('--headless');
|
webkitArguments.push('--headless');
|
||||||
|
if (launchType === 'persistent')
|
||||||
webkitArguments.push(`--user-data-dir=${userDataDir}`);
|
webkitArguments.push(`--user-data-dir=${userDataDir}`);
|
||||||
|
else
|
||||||
|
webkitArguments.push(`--no-startup-window`);
|
||||||
webkitArguments.push(...args);
|
webkitArguments.push(...args);
|
||||||
return webkitArguments;
|
return webkitArguments;
|
||||||
}
|
}
|
||||||
@ -361,18 +362,6 @@ async function wrapTransportWithWebSocket(transport: ConnectionTransport, port:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sockets.add(socket);
|
sockets.add(socket);
|
||||||
// Following two messages are reporting the default browser context and the default page.
|
|
||||||
socket.send(JSON.stringify({
|
|
||||||
method: 'Browser.pageProxyCreated',
|
|
||||||
params: { pageProxyInfo: { pageProxyId: '5', browserContextId: '0000000000000002' } }
|
|
||||||
}));
|
|
||||||
socket.send(JSON.stringify({
|
|
||||||
method: 'Target.targetCreated',
|
|
||||||
params: {
|
|
||||||
targetInfo: { targetId: 'page-6', type: 'page', isPaused: false }
|
|
||||||
},
|
|
||||||
pageProxyId: '5'
|
|
||||||
}));
|
|
||||||
|
|
||||||
socket.on('message', (message: string) => {
|
socket.on('message', (message: string) => {
|
||||||
const parsedMessage = JSON.parse(Buffer.from(message).toString());
|
const parsedMessage = JSON.parse(Buffer.from(message).toString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user