chore: fix protocol-types-generator to work with new API

Follow-up to a2ab645e635797eac857b077c5f4d5986ca31820
This commit is contained in:
Andrey Lushnikov 2020-02-05 16:49:09 -08:00
parent 55b6fe241e
commit cd68619786

View File

@ -10,11 +10,13 @@ async function generateChromiunProtocol(revision) {
if (revision.local && fs.existsSync(outputPath))
return;
const playwright = await require('../../index').chromium;
const browser = await playwright.launch({ executablePath: revision.executablePath });
const browserServer = await playwright.launchServer({ executablePath: revision.executablePath });
const origin = browserServer.wsEndpoint().match(/ws:\/\/([0-9A-Za-z:\.]*)\//)[1];
const browser = await playwright.connect({ wsEndpoint: browserServer.wsEndpoint() });
const page = await browser.newPage();
await page.goto(`http://${origin}/json/protocol`);
const json = JSON.parse(await page.evaluate(() => document.documentElement.innerText));
await browser.close();
await browserServer.kill();
fs.writeFileSync(outputPath, jsonToTS(json));
console.log(`Wrote protocol.ts to ${path.relative(process.cwd(), outputPath)}`);
}