feat(rpc): in-process rpc on by default (#3104)
This commit is contained in:
parent
1b8128eb84
commit
3179e71912
3
index.js
3
index.js
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
const { Playwright } = require('./lib/server/playwright');
|
const { Playwright } = require('./lib/server/playwright');
|
||||||
const { Electron } = require('./lib/server/electron');
|
const { Electron } = require('./lib/server/electron');
|
||||||
|
const { setupInProcess } = require('./lib/rpc/inprocess');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const playwright = new Playwright(__dirname, require(path.join(__dirname, 'browsers.json'))['browsers']);
|
const playwright = new Playwright(__dirname, require(path.join(__dirname, 'browsers.json'))['browsers']);
|
||||||
playwright.electron = new Electron();
|
playwright.electron = new Electron();
|
||||||
module.exports = playwright;
|
module.exports = setupInProcess(playwright);
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
"tsc": "tsc -p .",
|
"tsc": "tsc -p .",
|
||||||
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
|
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
|
||||||
"doc": "node utils/doclint/cli.js",
|
"doc": "node utils/doclint/cli.js",
|
||||||
"doc-channel": "node utils/doclint/cli.js --channel",
|
"doc-no-channel": "node utils/doclint/cli.js --no-channel",
|
||||||
"test-infra": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
"test-infra": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
||||||
"lint": "npm run eslint && npm run tsc && npm run doc && npm run doc-channel && npm run check-deps && npm run generate-channels && npm run test-types && npm run test-infra",
|
"lint": "npm run eslint && npm run tsc && npm run doc && npm run doc-no-channel && npm run check-deps && npm run generate-channels && npm run test-types && npm run test-infra",
|
||||||
"debug-test": "node --inspect-brk test/test.js",
|
"debug-test": "node --inspect-brk test/test.js",
|
||||||
"clean": "rimraf lib && rimraf types",
|
"clean": "rimraf lib && rimraf types",
|
||||||
"prepare": "node install-from-github.js",
|
"prepare": "node install-from-github.js",
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { Playwright } = require('./lib/server/playwright');
|
const { Playwright } = require('./lib/server/playwright');
|
||||||
|
const { setupInProcess } = require('./lib/rpc/inprocess');
|
||||||
|
|
||||||
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
|
module.exports = setupInProcess(new Playwright(__dirname, require('./browsers.json')['browsers']));
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
const { Playwright } = require('playwright-core/lib/server/playwright');
|
const { Playwright } = require('playwright-core/lib/server/playwright');
|
||||||
const { Electron } = require('playwright-core/lib/server/electron');
|
const { Electron } = require('playwright-core/lib/server/electron');
|
||||||
|
const { setupInProcess } = require('./lib/rpc/inprocess');
|
||||||
|
|
||||||
const playwright = new Playwright(__dirname, require('./browsers.json')['browsers']);
|
const playwright = new Playwright(__dirname, require('./browsers.json')['browsers']);
|
||||||
playwright.electron = new Electron();
|
playwright.electron = new Electron();
|
||||||
module.exports = playwright;
|
module.exports = setupInProcess(playwright);
|
||||||
|
|
|
||||||
4
test/fixtures/closeme.js
vendored
4
test/fixtures/closeme.js
vendored
|
|
@ -9,10 +9,8 @@
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { setUnderTest } = require(path.join(playwrightPath, 'lib', 'helper'));
|
const { setUnderTest } = require(path.join(playwrightPath, 'lib', 'helper'));
|
||||||
const { setupInProcess } = require(path.join(playwrightPath, 'lib', 'rpc', 'inprocess'));
|
|
||||||
setUnderTest();
|
setUnderTest();
|
||||||
const playwrightImpl = require(path.join(playwrightPath, 'index'));
|
const playwright = require(path.join(playwrightPath, 'index'));
|
||||||
const playwright = process.env.PWCHANNEL ? setupInProcess(playwrightImpl) : playwrightImpl;
|
|
||||||
|
|
||||||
const browserServer = await playwright[browserTypeName].launchServer(launchOptions);
|
const browserServer = await playwright[browserTypeName].launchServer(launchOptions);
|
||||||
browserServer.on('close', (exitCode, signal) => {
|
browserServer.on('close', (exitCode, signal) => {
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,15 @@
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
const playwrightImpl = require('../../index');
|
|
||||||
|
|
||||||
const { TestServer } = require('../../utils/testserver');
|
const { TestServer } = require('../../utils/testserver');
|
||||||
const { Connection } = require('../../lib/rpc/client/connection');
|
const { Connection } = require('../../lib/rpc/client/connection');
|
||||||
const { Transport } = require('../../lib/rpc/transport');
|
const { Transport } = require('../../lib/rpc/transport');
|
||||||
const { setupInProcess } = require('../../lib/rpc/inprocess');
|
|
||||||
const { setUnderTest } = require('../../lib/helper');
|
const { setUnderTest } = require('../../lib/helper');
|
||||||
const { valueFromEnv } = require('./utils');
|
const { valueFromEnv } = require('./utils');
|
||||||
const { registerFixture, registerWorkerFixture } = require('./fixturePool');
|
const { registerFixture, registerWorkerFixture } = require('./fixturePool');
|
||||||
|
|
||||||
setUnderTest();
|
setUnderTest(); // Note: we must call setUnderTest before requiring Playwright.
|
||||||
|
|
||||||
const browserName = process.env.BROWSER || 'chromium';
|
const browserName = process.env.BROWSER || 'chromium';
|
||||||
|
|
||||||
|
|
@ -102,13 +100,8 @@ module.exports = function registerFixtures(global) {
|
||||||
spawnedProcess.stdin.destroy();
|
spawnedProcess.stdin.destroy();
|
||||||
spawnedProcess.stdout.destroy();
|
spawnedProcess.stdout.destroy();
|
||||||
spawnedProcess.stderr.destroy();
|
spawnedProcess.stderr.destroy();
|
||||||
} else if (process.env.PWCHANNEL) {
|
|
||||||
const playwright = setupInProcess(playwrightImpl);
|
|
||||||
await test(playwright);
|
|
||||||
} else {
|
} else {
|
||||||
const playwright = playwrightImpl;
|
await test(require('../../index'));
|
||||||
playwright._toImpl = x => x;
|
|
||||||
await test(playwright);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ testOptions.CHROMIUM = browserName === 'chromium';
|
||||||
testOptions.FFOX = browserName === 'firefox';
|
testOptions.FFOX = browserName === 'firefox';
|
||||||
testOptions.WEBKIT = browserName === 'webkit';
|
testOptions.WEBKIT = browserName === 'webkit';
|
||||||
testOptions.USES_HOOKS = process.env.PWCHANNEL === 'wire';
|
testOptions.USES_HOOKS = process.env.PWCHANNEL === 'wire';
|
||||||
testOptions.CHANNEL = !!process.env.PWCHANNEL;
|
testOptions.CHANNEL = true;
|
||||||
testOptions.HEADLESS = !!valueFromEnv('HEADLESS', true);
|
testOptions.HEADLESS = !!valueFromEnv('HEADLESS', true);
|
||||||
testOptions.ASSETS_DIR = path.join(__dirname, '..', 'assets');
|
testOptions.ASSETS_DIR = path.join(__dirname, '..', 'assets');
|
||||||
testOptions.GOLDEN_DIR = path.join(__dirname, '..', 'golden-' + browserName);
|
testOptions.GOLDEN_DIR = path.join(__dirname, '..', 'golden-' + browserName);
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,7 @@ function apiForBrowser(browserName) {
|
||||||
const events = browserConfig.events;
|
const events = browserConfig.events;
|
||||||
// TODO: we should rethink our api.ts approach to ensure coverage and async stacks.
|
// TODO: we should rethink our api.ts approach to ensure coverage and async stacks.
|
||||||
const api = {
|
const api = {
|
||||||
...require('../../lib/api'),
|
...require('../../lib/rpc/client/api'),
|
||||||
Browser: require('../../lib/browser').BrowserBase,
|
|
||||||
BrowserContext: require('../../lib/browserContext').BrowserContextBase,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredKeys = Object.keys(api).filter(apiName => {
|
const filteredKeys = Object.keys(api).filter(apiName => {
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ const {installCoverageHooks} = require('./coverage');
|
||||||
const reportOnly = !!process.env.REPORT_ONLY_PLATFORM;
|
const reportOnly = !!process.env.REPORT_ONLY_PLATFORM;
|
||||||
const { ModuleMocker } = require('jest-mock');
|
const { ModuleMocker } = require('jest-mock');
|
||||||
|
|
||||||
Error.stackTraceLimit = 15;
|
|
||||||
global.testOptions = require('../harness/testOptions');
|
global.testOptions = require('../harness/testOptions');
|
||||||
global.registerFixture = registerFixture;
|
global.registerFixture = registerFixture;
|
||||||
global.registerWorkerFixture = registerWorkerFixture;
|
global.registerWorkerFixture = registerWorkerFixture;
|
||||||
|
|
||||||
registerFixtures(global);
|
registerFixtures(global);
|
||||||
|
|
||||||
const browserName = process.env.BROWSER || 'chromium';
|
const browserName = process.env.BROWSER || 'chromium';
|
||||||
|
|
@ -42,7 +42,7 @@ let currentFixturePool = null;
|
||||||
process.on('SIGINT', async () => {
|
process.on('SIGINT', async () => {
|
||||||
if (currentFixturePool) {
|
if (currentFixturePool) {
|
||||||
await currentFixturePool.teardownScope('test');
|
await currentFixturePool.teardownScope('test');
|
||||||
await currentFixturePool.teardownScope('worker');
|
await currentFixturePool.teardownScope('worker');
|
||||||
}
|
}
|
||||||
process.exit(130);
|
process.exit(130);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ run();
|
||||||
async function run() {
|
async function run() {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const onlyBrowserVersions = process.argv.includes('--only-browser-versions');
|
const onlyBrowserVersions = process.argv.includes('--only-browser-versions');
|
||||||
const channel = process.argv.includes('--channel');
|
const noChannel = process.argv.includes('--no-channel');
|
||||||
if (channel)
|
if (noChannel)
|
||||||
console.warn(`${YELLOW_COLOR}NOTE: checking documentation against //src/rpc/client${RESET_COLOR}`);
|
console.warn(`${YELLOW_COLOR}NOTE: checking documentation against //src${RESET_COLOR}`);
|
||||||
|
|
||||||
/** @type {!Array<!Message>} */
|
/** @type {!Array<!Message>} */
|
||||||
const messages = [];
|
const messages = [];
|
||||||
|
|
@ -70,11 +70,11 @@ async function run() {
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
const checkPublicAPI = require('./check_public_api');
|
const checkPublicAPI = require('./check_public_api');
|
||||||
let jsSources;
|
let jsSources;
|
||||||
if (channel) {
|
if (noChannel) {
|
||||||
jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'rpc', 'client'), '', []);
|
|
||||||
} else {
|
|
||||||
const rpcDir = path.join(PROJECT_DIR, 'src', 'rpc');
|
const rpcDir = path.join(PROJECT_DIR, 'src', 'rpc');
|
||||||
jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src'), '', [rpcDir]);
|
jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src'), '', [rpcDir]);
|
||||||
|
} else {
|
||||||
|
jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'rpc', 'client'), '', []);
|
||||||
}
|
}
|
||||||
messages.push(...await checkPublicAPI(page, [api], jsSources));
|
messages.push(...await checkPublicAPI(page, [api], jsSources));
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ let documentation;
|
||||||
const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));
|
const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));
|
||||||
const {documentation: mdDocumentation} = await require('../doclint/check_public_api/MDBuilder')(page, [api]);
|
const {documentation: mdDocumentation} = await require('../doclint/check_public_api/MDBuilder')(page, [api]);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
const rpcDir = path.join(PROJECT_DIR, 'src', 'rpc');
|
const sources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'rpc', 'client'), '', []);
|
||||||
const sources = await Source.readdir(path.join(PROJECT_DIR, 'src'), '', [rpcDir]);
|
|
||||||
const {documentation: jsDocumentation} = await require('../doclint/check_public_api/JSBuilder').checkSources(sources);
|
const {documentation: jsDocumentation} = await require('../doclint/check_public_api/JSBuilder').checkSources(sources);
|
||||||
documentation = mergeDocumentation(mdDocumentation, jsDocumentation);
|
documentation = mergeDocumentation(mdDocumentation, jsDocumentation);
|
||||||
const handledClasses = new Set();
|
const handledClasses = new Set();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue