chore: roll Electron to 12.2.1 (#9271)

This commit is contained in:
Pavel Feldman 2021-10-01 19:40:47 -07:00 committed by GitHub
parent edf07949be
commit 913821f675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 68 additions and 55 deletions

45
package-lock.json generated
View File

@ -62,7 +62,7 @@
"@types/extract-zip": "^1.6.2", "@types/extract-zip": "^1.6.2",
"@types/mime": "^2.0.3", "@types/mime": "^2.0.3",
"@types/minimatch": "^3.0.3", "@types/minimatch": "^3.0.3",
"@types/node": "^10.17.28", "@types/node": "^14.17.15",
"@types/pixelmatch": "^5.2.1", "@types/pixelmatch": "^5.2.1",
"@types/pngjs": "^3.4.2", "@types/pngjs": "^3.4.2",
"@types/progress": "^2.0.3", "@types/progress": "^2.0.3",
@ -87,7 +87,7 @@
"concurrently": "^6.2.1", "concurrently": "^6.2.1",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"css-loader": "^5.2.6", "css-loader": "^5.2.6",
"electron": "^11.1.1", "electron": "^12.2.1",
"eslint": "^7.31.0", "eslint": "^7.31.0",
"eslint-plugin-notice": "^0.9.10", "eslint-plugin-notice": "^0.9.10",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
@ -1486,9 +1486,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "10.17.60", "version": "14.17.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.15.tgz",
"integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" "integrity": "sha512-D1sdW0EcSCmNdLKBGMYb38YsHUS6JcM7yQ6sLQ9KuZ35ck7LYCKE7kYFHOO59ayFOY3zobWVZxf4KXhYHcHYFA=="
}, },
"node_modules/@types/normalize-package-data": { "node_modules/@types/normalize-package-data": {
"version": "2.4.1", "version": "2.4.1",
@ -4151,13 +4151,14 @@
} }
}, },
"node_modules/electron": { "node_modules/electron": {
"version": "11.4.6", "version": "12.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-11.4.6.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-12.2.1.tgz",
"integrity": "sha512-WN7zUwaAmcB1lXyyaMxPsNWAFCpRMDltQb4zCjvoD5TBBoePcjd6UwyVUD93pSKJXjmWoae8PbZWrbZlXowcSg==", "integrity": "sha512-Gp+rO81qoaRDP7PTVtBOvnSgDgGlwUuAEWXxi621uOJMIlYFas9ChXe8pjdL0R0vyUpiHVzp6Vrjx41VZqEpsw==",
"dev": true, "dev": true,
"hasInstallScript": true,
"dependencies": { "dependencies": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
"@types/node": "^12.0.12", "@types/node": "^14.6.2",
"extract-zip": "^1.0.3" "extract-zip": "^1.0.3"
}, },
"bin": { "bin": {
@ -4173,9 +4174,9 @@
"integrity": "sha512-WmCgAeURsMFiyoJ646eUaJQ7GNfvMRLXo+GamUyKVNEM4MqTAsXyC0f38JEB4N3BtbD0tlAKozGP5E2T9K3YGg==" "integrity": "sha512-WmCgAeURsMFiyoJ646eUaJQ7GNfvMRLXo+GamUyKVNEM4MqTAsXyC0f38JEB4N3BtbD0tlAKozGP5E2T9K3YGg=="
}, },
"node_modules/electron/node_modules/@types/node": { "node_modules/electron/node_modules/@types/node": {
"version": "12.20.13", "version": "14.17.20",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.13.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.20.tgz",
"integrity": "sha512-1x8W5OpxPq+T85OUsHRP6BqXeosKmeXRtjoF39STcdf/UWLqUsoehstZKOi0CunhVqHG17AyZgpj20eRVooK6A==", "integrity": "sha512-gI5Sl30tmhXsqkNvopFydP7ASc4c2cLfGNQrVKN3X90ADFWFsPEsotm/8JHSUJQKTHbwowAHtcJPeyVhtKv0TQ==",
"dev": true "dev": true
}, },
"node_modules/electron/node_modules/debug": { "node_modules/electron/node_modules/debug": {
@ -11936,9 +11937,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "10.17.60", "version": "14.17.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.15.tgz",
"integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" "integrity": "sha512-D1sdW0EcSCmNdLKBGMYb38YsHUS6JcM7yQ6sLQ9KuZ35ck7LYCKE7kYFHOO59ayFOY3zobWVZxf4KXhYHcHYFA=="
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
"version": "2.4.1", "version": "2.4.1",
@ -14161,20 +14162,20 @@
} }
}, },
"electron": { "electron": {
"version": "11.4.6", "version": "12.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-11.4.6.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-12.2.1.tgz",
"integrity": "sha512-WN7zUwaAmcB1lXyyaMxPsNWAFCpRMDltQb4zCjvoD5TBBoePcjd6UwyVUD93pSKJXjmWoae8PbZWrbZlXowcSg==", "integrity": "sha512-Gp+rO81qoaRDP7PTVtBOvnSgDgGlwUuAEWXxi621uOJMIlYFas9ChXe8pjdL0R0vyUpiHVzp6Vrjx41VZqEpsw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
"@types/node": "^12.0.12", "@types/node": "^14.6.2",
"extract-zip": "^1.0.3" "extract-zip": "^1.0.3"
}, },
"dependencies": { "dependencies": {
"@types/node": { "@types/node": {
"version": "12.20.13", "version": "14.17.20",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.13.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.20.tgz",
"integrity": "sha512-1x8W5OpxPq+T85OUsHRP6BqXeosKmeXRtjoF39STcdf/UWLqUsoehstZKOi0CunhVqHG17AyZgpj20eRVooK6A==", "integrity": "sha512-gI5Sl30tmhXsqkNvopFydP7ASc4c2cLfGNQrVKN3X90ADFWFsPEsotm/8JHSUJQKTHbwowAHtcJPeyVhtKv0TQ==",
"dev": true "dev": true
}, },
"debug": { "debug": {

View File

@ -91,7 +91,7 @@
"@types/extract-zip": "^1.6.2", "@types/extract-zip": "^1.6.2",
"@types/mime": "^2.0.3", "@types/mime": "^2.0.3",
"@types/minimatch": "^3.0.3", "@types/minimatch": "^3.0.3",
"@types/node": "^10.17.28", "@types/node": "^14.17.15",
"@types/pixelmatch": "^5.2.1", "@types/pixelmatch": "^5.2.1",
"@types/pngjs": "^3.4.2", "@types/pngjs": "^3.4.2",
"@types/progress": "^2.0.3", "@types/progress": "^2.0.3",
@ -116,7 +116,7 @@
"concurrently": "^6.2.1", "concurrently": "^6.2.1",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"css-loader": "^5.2.6", "css-loader": "^5.2.6",
"electron": "^11.1.1", "electron": "^12.2.1",
"eslint": "^7.31.0", "eslint": "^7.31.0",
"eslint-plugin-notice": "^0.9.10", "eslint-plugin-notice": "^0.9.10",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",

View File

@ -241,7 +241,7 @@ function filePayloadToJson(payload: FilePayload): ServerFilePayload {
async function readStreamToJson(stream: fs.ReadStream): Promise<ServerFilePayload> { async function readStreamToJson(stream: fs.ReadStream): Promise<ServerFilePayload> {
const buffer = await new Promise<Buffer>((resolve, reject) => { const buffer = await new Promise<Buffer>((resolve, reject) => {
const chunks: Buffer[] = []; const chunks: Buffer[] = [];
stream.on('data', chunk => chunks.push(chunk)); stream.on('data', chunk => chunks.push(chunk as Buffer));
stream.on('end', () => resolve(Buffer.concat(chunks))); stream.on('end', () => resolve(Buffer.concat(chunks)));
stream.on('error', err => reject(err)); stream.on('error', err => reject(err));
}); });

View File

@ -48,7 +48,7 @@ class StreamImpl extends Readable {
this.push(null); this.push(null);
} }
override _destroy(error: Error | null, callback: (error: Error | null) => void): void { override _destroy(error: Error | null, callback: (error: Error | null | undefined) => void): void {
// Stream might be destroyed after the connection was closed. // Stream might be destroyed after the connection was closed.
this._channel.close().catch(e => null); this._channel.close().catch(e => null);
super._destroy(error, callback); super._destroy(error, callback);

View File

@ -51,7 +51,7 @@ class PlaywrightClient {
this._driverProcess.on('exit', this._onExit); this._driverProcess.on('exit', this._onExit);
const connection = new Connection(); const connection = new Connection();
const transport = new Transport(this._driverProcess.stdin, this._driverProcess.stdout); const transport = new Transport(this._driverProcess.stdin!, this._driverProcess.stdout!);
connection.onmessage = message => transport.send(JSON.stringify(message)); connection.onmessage = message => transport.send(JSON.stringify(message));
transport.onmessage = message => connection.dispatch(JSON.parse(message)); transport.onmessage = message => connection.dispatch(JSON.parse(message));
this._closePromise = new Promise(f => transport.onclose = f); this._closePromise = new Promise(f => transport.onclose = f);
@ -61,9 +61,9 @@ class PlaywrightClient {
async stop() { async stop() {
this._driverProcess.removeListener('exit', this._onExit); this._driverProcess.removeListener('exit', this._onExit);
this._driverProcess.stdin.destroy(); this._driverProcess.stdin!.destroy();
this._driverProcess.stdout.destroy(); this._driverProcess.stdout!.destroy();
this._driverProcess.stderr.destroy(); this._driverProcess.stderr!.destroy();
await this._closePromise; await this._closePromise;
} }
} }

View File

@ -76,6 +76,10 @@ export class PlaywrightServer {
const wsEndpoint = await new Promise<string>((resolve, reject) => { const wsEndpoint = await new Promise<string>((resolve, reject) => {
server.listen(port, () => { server.listen(port, () => {
const address = server.address(); const address = server.address();
if (!address) {
reject(new Error('Could not bind server socket'));
return;
}
const wsEndpoint = typeof address === 'string' ? `${address}${path}` : `ws://127.0.0.1:${address.port}${path}`; const wsEndpoint = typeof address === 'string' ? `${address}${path}` : `ws://127.0.0.1:${address.port}${path}`;
resolve(wsEndpoint); resolve(wsEndpoint);
}).on('error', reject); }).on('error', reject);

View File

@ -109,16 +109,16 @@ export class VideoRecorder {
tempDirectories: [], tempDirectories: [],
attemptToGracefullyClose: async () => { attemptToGracefullyClose: async () => {
progress.log('Closing stdin...'); progress.log('Closing stdin...');
launchedProcess.stdin.end(); launchedProcess.stdin!.end();
}, },
onExit: (exitCode, signal) => { onExit: (exitCode, signal) => {
progress.log(`ffmpeg onkill exitCode=${exitCode} signal=${signal}`); progress.log(`ffmpeg onkill exitCode=${exitCode} signal=${signal}`);
}, },
}); });
launchedProcess.stdin.on('finish', () => { launchedProcess.stdin!.on('finish', () => {
progress.log('ffmpeg finished input.'); progress.log('ffmpeg finished input.');
}); });
launchedProcess.stdin.on('error', () => { launchedProcess.stdin!.on('error', () => {
progress.log('ffmpeg error.'); progress.log('ffmpeg error.');
}); });
this._process = launchedProcess; this._process = launchedProcess;
@ -150,7 +150,7 @@ export class VideoRecorder {
} }
private async _sendFrame(frame: Buffer) { private async _sendFrame(frame: Buffer) {
return new Promise(f => this._process!.stdin.write(frame, f)).then(error => { return new Promise(f => this._process!.stdin!.write(frame, f)).then(error => {
if (error) if (error)
this._progress.log(`ffmpeg failed to write: ${error}`); this._progress.log(`ffmpeg failed to write: ${error}`);
}); });

View File

@ -193,7 +193,7 @@ export class Electron extends SdkObject {
function waitForLine(progress: Progress, process: childProcess.ChildProcess, regex: RegExp): Promise<RegExpMatchArray> { function waitForLine(progress: Progress, process: childProcess.ChildProcess, regex: RegExp): Promise<RegExpMatchArray> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const rl = readline.createInterface({ input: process.stderr }); const rl = readline.createInterface({ input: process.stderr! });
const failError = new Error('Process failed to launch!'); const failError = new Error('Process failed to launch!');
const listeners = [ const listeners = [
eventsHelper.addEventListener(rl, 'line', onLine), eventsHelper.addEventListener(rl, 'line', onLine),

View File

@ -78,8 +78,8 @@ export class WebServer {
}); });
this._killProcess = kill; this._killProcess = kill;
launchedProcess.stderr.pipe(newProcessLogPrefixer()).pipe(process.stderr); launchedProcess.stderr!.pipe(newProcessLogPrefixer()).pipe(process.stderr);
launchedProcess.stdout.on('data', () => {}); launchedProcess.stdout!.on('data', () => {});
} }
private async _waitForProcess() { private async _waitForProcess() {

View File

@ -19,6 +19,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import { Server as WebSocketServer } from 'ws'; import { Server as WebSocketServer } from 'ws';
import * as mime from 'mime'; import * as mime from 'mime';
import { assert } from './utils';
export type ServerRouteHandler = (request: http.IncomingMessage, response: http.ServerResponse) => boolean; export type ServerRouteHandler = (request: http.IncomingMessage, response: http.ServerResponse) => boolean;
@ -61,6 +62,7 @@ export class HttpServer {
if (typeof address === 'string') { if (typeof address === 'string') {
this._urlPrefix = address; this._urlPrefix = address;
} else { } else {
assert(address, 'Could not bind server socket');
this._port = address.port; this._port = address.port;
this._urlPrefix = `http://127.0.0.1:${address.port}`; this._urlPrefix = `http://127.0.0.1:${address.port}`;
} }

View File

@ -73,7 +73,7 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
shell: options.shell, shell: options.shell,
stdio, stdio,
}; };
const spawnedProcess = childProcess.spawn(options.command, options.args, spawnOptions); const spawnedProcess = childProcess.spawn(options.command, options.args || [], spawnOptions);
const cleanup = async () => { const cleanup = async () => {
options.log(`[pid=${spawnedProcess.pid || 'N/A'}] starting temporary directories cleanup`); options.log(`[pid=${spawnedProcess.pid || 'N/A'}] starting temporary directories cleanup`);
@ -98,12 +98,12 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
} }
options.log(`<launched> pid=${spawnedProcess.pid}`); options.log(`<launched> pid=${spawnedProcess.pid}`);
const stdout = readline.createInterface({ input: spawnedProcess.stdout }); const stdout = readline.createInterface({ input: spawnedProcess.stdout! });
stdout.on('line', (data: string) => { stdout.on('line', (data: string) => {
options.log(`[pid=${spawnedProcess.pid}][out] ` + data); options.log(`[pid=${spawnedProcess.pid}][out] ` + data);
}); });
const stderr = readline.createInterface({ input: spawnedProcess.stderr }); const stderr = readline.createInterface({ input: spawnedProcess.stderr! });
stderr.on('line', (data: string) => { stderr.on('line', (data: string) => {
options.log(`[pid=${spawnedProcess.pid}][err] ` + data); options.log(`[pid=${spawnedProcess.pid}][err] ` + data);
}); });

View File

@ -226,7 +226,7 @@ function toMegabytes(bytes: number) {
return `${Math.round(mb * 10) / 10} Mb`; return `${Math.round(mb * 10) / 10} Mb`;
} }
export function spawnAsync(cmd: string, args: string[], options?: SpawnOptions): Promise<{stdout: string, stderr: string, code: number, error?: Error}> { export function spawnAsync(cmd: string, args: string[], options: SpawnOptions = {}): Promise<{stdout: string, stderr: string, code: number | null, error?: Error}> {
const process = spawn(cmd, args, options); const process = spawn(cmd, args, options);
return new Promise(resolve => { return new Promise(resolve => {

View File

@ -31,7 +31,7 @@ export class TestProxy {
static async create(port: number): Promise<TestProxy> { static async create(port: number): Promise<TestProxy> {
const proxy = new TestProxy(port); const proxy = new TestProxy(port);
await new Promise(f => proxy._server.listen(port, f)); await new Promise<void>(f => proxy._server.listen(port, f));
return proxy; return proxy;
} }

View File

@ -42,8 +42,9 @@ function expectContexts(pageImpl, count, browserName) {
expect(pageImpl._delegate._contextIdToContext.size).toBe(count); expect(pageImpl._delegate._contextIdToContext.size).toBe(count);
} }
it('should dispose context on navigation', async ({ page, server, toImpl, browserName, mode }) => { it('should dispose context on navigation', async ({ page, server, toImpl, browserName, mode, isElectron }) => {
it.skip(mode !== 'default'); it.skip(mode !== 'default');
it.skip(isElectron);
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
@ -52,8 +53,9 @@ it('should dispose context on navigation', async ({ page, server, toImpl, browse
expectContexts(toImpl(page), 2, browserName); expectContexts(toImpl(page), 2, browserName);
}); });
it('should dispose context on cross-origin navigation', async ({ page, server, toImpl, browserName, mode }) => { it('should dispose context on cross-origin navigation', async ({ page, server, toImpl, browserName, mode, isElectron }) => {
it.skip(mode !== 'default'); it.skip(mode !== 'default');
it.skip(isElectron);
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);

View File

@ -33,8 +33,9 @@ it('should work with navigation', async ({ page, server }) => {
expect(requests.get('style.css').isNavigationRequest()).toBe(false); expect(requests.get('style.css').isNavigationRequest()).toBe(false);
}); });
it('should intercept after a service worker', async ({ page, server, isAndroid }) => { it('should intercept after a service worker', async ({ page, server, isAndroid, isElectron }) => {
it.skip(isAndroid); it.skip(isAndroid);
it.skip(isElectron);
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html'); await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
await page.evaluate(() => window['activationPromise']); await page.evaluate(() => window['activationPromise']);

View File

@ -41,8 +41,9 @@ it('should fire for fetches', async ({ page, server }) => {
expect(requests.length).toBe(2); expect(requests.length).toBe(2);
}); });
it('should report requests and responses handled by service worker', async ({ page, server, isAndroid }) => { it('should report requests and responses handled by service worker', async ({ page, server, isAndroid, isElectron }) => {
it.fixme(isAndroid); it.fixme(isAndroid);
it.fixme(isElectron);
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html'); await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
await page.evaluate(() => window['activationPromise']); await page.evaluate(() => window['activationPromise']);

View File

@ -495,7 +495,8 @@ it('should fail when navigating and show the url at the error message', async fu
expect(error.message).toContain(url); expect(error.message).toContain(url);
}); });
it('should be able to navigate to a page controlled by service worker', async ({ page, server }) => { it('should be able to navigate to a page controlled by service worker', async ({ page, server, isElectron }) => {
it.skip(isElectron);
await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html'); await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html');
await page.evaluate(() => window['activationPromise']); await page.evaluate(() => window['activationPromise']);
await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html'); await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html');

View File

@ -171,8 +171,9 @@ it.describe('page screenshot', () => {
expect(screenshot).toMatchSnapshot('screenshot-canvas.png', { threshold: 0.4 }); expect(screenshot).toMatchSnapshot('screenshot-canvas.png', { threshold: 0.4 });
}); });
it('should capture canvas changes', async ({ page, browserName, isMac }) => { it('should capture canvas changes', async ({ page, browserName, isMac, isElectron }) => {
it.fail(browserName === 'webkit' && isMac, 'https://github.com/microsoft/playwright/issues/8796'); it.fail(browserName === 'webkit' && isMac, 'https://github.com/microsoft/playwright/issues/8796');
it.skip(isElectron);
await page.goto('data:text/html,<canvas></canvas>'); await page.goto('data:text/html,<canvas></canvas>');
await page.evaluate(() => { await page.evaluate(() => {
const canvas = document.querySelector('canvas'); const canvas = document.querySelector('canvas');

View File

@ -138,7 +138,7 @@ test('should be able to specify the baseURL without the server', async ({ runInl
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => { const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>hello</body></html>'); res.end('<html><body>hello</body></html>');
}); });
await new Promise(resolve => server.listen(port, resolve)); await new Promise<void>(resolve => server.listen(port, resolve));
const result = await runInlineTest({ const result = await runInlineTest({
'test.spec.ts': ` 'test.spec.ts': `
const { test } = pwt; const { test } = pwt;
@ -167,7 +167,7 @@ test('should be able to use an existing server when reuseExistingServer:true ',
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => { const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>hello</body></html>'); res.end('<html><body>hello</body></html>');
}); });
await new Promise(resolve => server.listen(port, resolve)); await new Promise<void>(resolve => server.listen(port, resolve));
const result = await runInlineTest({ const result = await runInlineTest({
'test.spec.ts': ` 'test.spec.ts': `
const { test } = pwt; const { test } = pwt;
@ -200,7 +200,7 @@ test('should throw when a server is already running on the given port and strict
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => { const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>hello</body></html>'); res.end('<html><body>hello</body></html>');
}); });
await new Promise(resolve => server.listen(port, resolve)); await new Promise<void>(resolve => server.listen(port, resolve));
const result = await runInlineTest({ const result = await runInlineTest({
'test.spec.ts': ` 'test.spec.ts': `
const { test } = pwt; const { test } = pwt;
@ -232,7 +232,7 @@ for (const host of ['localhost', '127.0.0.1', '0.0.0.0']) {
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => { const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>hello</body></html>'); res.end('<html><body>hello</body></html>');
}); });
await new Promise(resolve => server.listen(port, host, resolve)); await new Promise<void>(resolve => server.listen(port, host, resolve));
try { try {
const result = await runInlineTest({ const result = await runInlineTest({
'test.spec.ts': ` 'test.spec.ts': `

View File

@ -86,7 +86,7 @@ async function startTestServer() {
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => { const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>from-retargeted-server</body></html>'); res.end('<html><body>from-retargeted-server</body></html>');
}); });
await new Promise(resolve => server.listen(0, resolve)); await new Promise<void>(resolve => server.listen(0, resolve));
return { return {
testServerPort: (server.address() as net.AddressInfo).port, testServerPort: (server.address() as net.AddressInfo).port,
stopTestServer: () => server.close() stopTestServer: () => server.close()

View File

@ -186,7 +186,7 @@ it('should use proxy with emulated user agent', async ({ browserType, browserOpt
socket.end(); socket.end();
}); });
}); });
await new Promise(f => server.listen(0, f)); await new Promise<void>(f => server.listen(0, f));
const browser = await browserType.launch({ const browser = await browserType.launch({
...browserOptions, ...browserOptions,
@ -221,7 +221,7 @@ async function setupSocksForwardingServer(port: number, forwardPort: number){
dstSock.connect(forwardPort, '127.0.0.1'); dstSock.connect(forwardPort, '127.0.0.1');
} }
}); });
await new Promise(resolve => socksServer.listen(port, 'localhost', resolve)); await new Promise<void>(resolve => socksServer.listen(port, 'localhost', resolve));
socksServer.useAuth(socks.auth.None()); socksServer.useAuth(socks.auth.None());
return { return {
closeProxyServer: () => socksServer.close(), closeProxyServer: () => socksServer.close(),