Skip to content

Commit

Permalink
chore: revert protocol_
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Nov 23, 2023
1 parent 37b74bd commit 6fd123d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 33 deletions.
5 changes: 3 additions & 2 deletions packages/puppeteer-core/src/common/ConnectOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ export interface BrowserConnectOptions {
* @internal
*/
_isPageTarget?: IsPageTargetCallback;

/**
* @defaultValue 'cdp'
* @internal
* @public
*/
protocol_?: ProtocolType;
protocol?: ProtocolType;
/**
* Timeout setting for individual protocol (CDP) calls.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/puppeteer-core/src/common/Puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Puppeteer {
* @returns Promise which resolves to browser instance.
*/
connect(options: ConnectOptions): Promise<Browser> {
if (options.protocol_ === 'webDriverBiDi') {
if (options.protocol === 'webDriverBiDi') {
return _connectToBiDiOverCdpBrowser(options);
} else {
return _connectToCdpBrowser(options);
Expand Down
12 changes: 1 addition & 11 deletions packages/puppeteer-core/src/node/ProductLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
import type {Browser, BrowserCloseCallback} from '../api/Browser.js';
import {CdpBrowser} from '../cdp/Browser.js';
import {Connection} from '../cdp/Connection.js';
import type {ProtocolType} from '../common/ConnectOptions.js';
import {TimeoutError} from '../common/Errors.js';
import type {Product} from '../common/Product.js';
import {debugError} from '../common/util.js';
Expand Down Expand Up @@ -96,19 +95,10 @@ export abstract class ProductLauncher {
slowMo = 0,
timeout = 30000,
waitForInitialPage = true,
protocol_: protocol_,
protocolTimeout,
protocol,
} = options;

let protocol = protocol_;

if (
this.#product === 'firefox' &&
(options as {protocol?: ProtocolType}).protocol
) {
protocol = (options as {protocol?: ProtocolType}).protocol;
}

const launchArgs = await this.computeLaunchArguments(options);

const usePipe = launchArgs.args.includes('--remote-debugging-pipe');
Expand Down
4 changes: 2 additions & 2 deletions test/src/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Browser specs', function () {
const browserWSEndpoint = browser.wsEndpoint();
const remoteBrowser = await puppeteer.connect({
browserWSEndpoint,
protocol_: browser.protocol,
protocol: browser.protocol,
});
expect(remoteBrowser.process()).toBe(null);
remoteBrowser.disconnect();
Expand All @@ -81,7 +81,7 @@ describe('Browser specs', function () {
const browserWSEndpoint = browser.wsEndpoint();
const newBrowser = await puppeteer.connect({
browserWSEndpoint,
protocol_: browser.protocol,
protocol: browser.protocol,
});
expect(newBrowser.isConnected()).toBe(true);
newBrowser.disconnect();
Expand Down
2 changes: 1 addition & 1 deletion test/src/browsercontext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('BrowserContext', function () {
expect(browser.browserContexts()).toHaveLength(2);
const remoteBrowser = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
const contexts = remoteBrowser.browserContexts();
expect(contexts).toHaveLength(2);
Expand Down
26 changes: 13 additions & 13 deletions test/src/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Launcher specs', function () {
try {
const remote = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
const page = await remote.newPage();
const navigationPromise = page
Expand All @@ -70,7 +70,7 @@ describe('Launcher specs', function () {
try {
const remote = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
const page = await remote.newPage();
const watchdog = page
Expand All @@ -92,7 +92,7 @@ describe('Launcher specs', function () {
try {
const remote = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
const newPage = await remote.newPage();
const results = await Promise.all([
Expand Down Expand Up @@ -627,7 +627,7 @@ describe('Launcher specs', function () {
try {
const otherBrowser = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
const page = await otherBrowser.newPage();
expect(
Expand All @@ -652,7 +652,7 @@ describe('Launcher specs', function () {
try {
const remoteBrowser = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
await Promise.all([
waitEvent(browser, 'disconnected'),
Expand All @@ -674,7 +674,7 @@ describe('Launcher specs', function () {
);
const remoteBrowser = await puppeteer.connect({
browserWSEndpoint: browser.wsEndpoint(),
protocol_: browser.protocol,
protocol: browser.protocol,
});
await Promise.all([
waitEvent(browser, 'disconnected'),
Expand All @@ -697,7 +697,7 @@ describe('Launcher specs', function () {
const remoteBrowser = await puppeteer.connect({
browserWSEndpoint,
ignoreHTTPSErrors: true,
protocol_: browser.protocol,
protocol: browser.protocol,
});
const page = await remoteBrowser.newPage();
const [serverRequest, response] = await Promise.all([
Expand Down Expand Up @@ -761,7 +761,7 @@ describe('Launcher specs', function () {
targetFilter: target => {
return !target.url().includes('should-be-ignored');
},
protocol_: browser.protocol,
protocol: browser.protocol,
});

const pages = await remoteBrowser.pages();
Expand Down Expand Up @@ -792,7 +792,7 @@ describe('Launcher specs', function () {

const remoteBrowser = await puppeteer.connect({
browserWSEndpoint,
protocol_: browser.protocol,
protocol: browser.protocol,
});
const pages = await remoteBrowser.pages();
const restoredPage = pages.find(page => {
Expand Down Expand Up @@ -822,7 +822,7 @@ describe('Launcher specs', function () {
try {
const browserTwo = await puppeteer.connect({
browserWSEndpoint: browserOne.wsEndpoint(),
protocol_: browserOne.protocol,
protocol: browserOne.protocol,
});
const [page1, page2] = await Promise.all([
new Promise<Page | null>(x => {
Expand Down Expand Up @@ -862,7 +862,7 @@ describe('Launcher specs', function () {

const browserTwo = await puppeteer.connect({
browserWSEndpoint,
protocol_: browserOne.protocol,
protocol: browserOne.protocol,
});
const pages = await browserTwo.pages();
const pageTwo = pages.find(page => {
Expand Down Expand Up @@ -960,11 +960,11 @@ describe('Launcher specs', function () {
const browserWSEndpoint = browser.wsEndpoint();
const remoteBrowser1 = await puppeteer.connect({
browserWSEndpoint,
protocol_: browser.protocol,
protocol: browser.protocol,
});
const remoteBrowser2 = await puppeteer.connect({
browserWSEndpoint,
protocol_: browser.protocol,
protocol: browser.protocol,
});

let disconnectedOriginal = 0;
Expand Down
6 changes: 3 additions & 3 deletions test/src/mocha-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const defaultBrowserOptions = Object.assign(
executablePath: process.env['BINARY'],
headless: headless === 'new' ? ('new' as const) : isHeadless,
dumpio: !!process.env['DUMPIO'],
protocol_: protocol,
protocol,
},
extraLaunchOptions
);
Expand All @@ -129,15 +129,15 @@ const processVariables: {
isHeadless: boolean;
isFirefox: boolean;
isChrome: boolean;
protocol_: 'cdp' | 'webDriverBiDi';
protocol: 'cdp' | 'webDriverBiDi';
defaultBrowserOptions: PuppeteerLaunchOptions;
} = {
product,
headless,
isHeadless,
isFirefox,
isChrome,
protocol_: protocol,
protocol,
defaultBrowserOptions,
};

Expand Down

0 comments on commit 6fd123d

Please sign in to comment.