test: pass protocol
in Puppeteer.connect
in tests (#11342)
Add an internal field protocol: 'cdp' | 'webDriverBiDi' to the Browser and use is in tests when Puppeter.connect(...) is called. Co-authored-by: Maksim Sadym <sadym@google.com>
This commit is contained in:
parent
b829f42074
commit
0533764aac
@ -437,4 +437,9 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
|
|||||||
[asyncDisposeSymbol](): Promise<void> {
|
[asyncDisposeSymbol](): Promise<void> {
|
||||||
return this.close();
|
return this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
abstract get protocol(): 'cdp' | 'webDriverBiDi';
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ export interface BidiBrowserOptions {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class BidiBrowser extends Browser {
|
export class BidiBrowser extends Browser {
|
||||||
|
readonly protocol = 'webDriverBiDi';
|
||||||
|
|
||||||
// TODO: Update generator to include fully module
|
// TODO: Update generator to include fully module
|
||||||
static readonly subscribeModules: string[] = [
|
static readonly subscribeModules: string[] = [
|
||||||
'browsingContext',
|
'browsingContext',
|
||||||
|
@ -53,6 +53,8 @@ import {TargetManagerEvent, type TargetManager} from './TargetManager.js';
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class CdpBrowser extends BrowserBase {
|
export class CdpBrowser extends BrowserBase {
|
||||||
|
readonly protocol = 'cdp';
|
||||||
|
|
||||||
static async _create(
|
static async _create(
|
||||||
product: 'firefox' | 'chrome' | undefined,
|
product: 'firefox' | 'chrome' | undefined,
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
|
@ -381,13 +381,13 @@
|
|||||||
"testIdPattern": "[browser.spec] Browser specs Browser.isConnected should set the browser connected state",
|
"testIdPattern": "[browser.spec] Browser specs Browser.isConnected should set the browser connected state",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[browser.spec] Browser specs Browser.process should not return child_process for remote browser",
|
"testIdPattern": "[browser.spec] Browser specs Browser.process should not return child_process for remote browser",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[browser.spec] Browser specs Browser.process should return child_process instance",
|
"testIdPattern": "[browser.spec] Browser specs Browser.process should return child_process instance",
|
||||||
@ -2031,19 +2031,19 @@
|
|||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to close remote browser",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to close remote browser",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect multiple times to the same browser",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect multiple times to the same browser",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
|
||||||
@ -2061,7 +2061,7 @@
|
|||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to the same page simultaneously",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to the same page simultaneously",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to reconnect to a disconnected browser",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to reconnect to a disconnected browser",
|
||||||
@ -2073,13 +2073,13 @@
|
|||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support ignoreHTTPSErrors option",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support ignoreHTTPSErrors option",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
|
||||||
|
@ -67,6 +67,7 @@ describe('Browser specs', function () {
|
|||||||
const browserWSEndpoint = browser.wsEndpoint();
|
const browserWSEndpoint = browser.wsEndpoint();
|
||||||
const remoteBrowser = await puppeteer.connect({
|
const remoteBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
expect(remoteBrowser.process()).toBe(null);
|
expect(remoteBrowser.process()).toBe(null);
|
||||||
remoteBrowser.disconnect();
|
remoteBrowser.disconnect();
|
||||||
@ -80,6 +81,7 @@ describe('Browser specs', function () {
|
|||||||
const browserWSEndpoint = browser.wsEndpoint();
|
const browserWSEndpoint = browser.wsEndpoint();
|
||||||
const newBrowser = await puppeteer.connect({
|
const newBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
expect(newBrowser.isConnected()).toBe(true);
|
expect(newBrowser.isConnected()).toBe(true);
|
||||||
newBrowser.disconnect();
|
newBrowser.disconnect();
|
||||||
|
@ -226,6 +226,7 @@ describe('BrowserContext', function () {
|
|||||||
expect(browser.browserContexts()).toHaveLength(2);
|
expect(browser.browserContexts()).toHaveLength(2);
|
||||||
const remoteBrowser = await puppeteer.connect({
|
const remoteBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const contexts = remoteBrowser.browserContexts();
|
const contexts = remoteBrowser.browserContexts();
|
||||||
expect(contexts).toHaveLength(2);
|
expect(contexts).toHaveLength(2);
|
||||||
|
@ -43,6 +43,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const remote = await puppeteer.connect({
|
const remote = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const page = await remote.newPage();
|
const page = await remote.newPage();
|
||||||
const navigationPromise = page
|
const navigationPromise = page
|
||||||
@ -69,6 +70,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const remote = await puppeteer.connect({
|
const remote = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const page = await remote.newPage();
|
const page = await remote.newPage();
|
||||||
const watchdog = page
|
const watchdog = page
|
||||||
@ -90,6 +92,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const remote = await puppeteer.connect({
|
const remote = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const newPage = await remote.newPage();
|
const newPage = await remote.newPage();
|
||||||
const results = await Promise.all([
|
const results = await Promise.all([
|
||||||
@ -624,6 +627,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const otherBrowser = await puppeteer.connect({
|
const otherBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const page = await otherBrowser.newPage();
|
const page = await otherBrowser.newPage();
|
||||||
expect(
|
expect(
|
||||||
@ -648,6 +652,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const remoteBrowser = await puppeteer.connect({
|
const remoteBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
waitEvent(browser, 'disconnected'),
|
waitEvent(browser, 'disconnected'),
|
||||||
@ -669,6 +674,7 @@ describe('Launcher specs', function () {
|
|||||||
);
|
);
|
||||||
const remoteBrowser = await puppeteer.connect({
|
const remoteBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint: browser.wsEndpoint(),
|
browserWSEndpoint: browser.wsEndpoint(),
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
waitEvent(browser, 'disconnected'),
|
waitEvent(browser, 'disconnected'),
|
||||||
@ -691,6 +697,7 @@ describe('Launcher specs', function () {
|
|||||||
const remoteBrowser = await puppeteer.connect({
|
const remoteBrowser = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const page = await remoteBrowser.newPage();
|
const page = await remoteBrowser.newPage();
|
||||||
let error!: Error;
|
let error!: Error;
|
||||||
@ -758,6 +765,7 @@ describe('Launcher specs', function () {
|
|||||||
targetFilter: target => {
|
targetFilter: target => {
|
||||||
return !target.url().includes('should-be-ignored');
|
return !target.url().includes('should-be-ignored');
|
||||||
},
|
},
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
|
|
||||||
const pages = await remoteBrowser.pages();
|
const pages = await remoteBrowser.pages();
|
||||||
@ -786,7 +794,10 @@ describe('Launcher specs', function () {
|
|||||||
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
||||||
browser.disconnect();
|
browser.disconnect();
|
||||||
|
|
||||||
const remoteBrowser = await puppeteer.connect({browserWSEndpoint});
|
const remoteBrowser = await puppeteer.connect({
|
||||||
|
browserWSEndpoint,
|
||||||
|
protocol: browser.protocol,
|
||||||
|
});
|
||||||
const pages = await remoteBrowser.pages();
|
const pages = await remoteBrowser.pages();
|
||||||
const restoredPage = pages.find(page => {
|
const restoredPage = pages.find(page => {
|
||||||
return page.url() === server.PREFIX + '/frames/nested-frames.html';
|
return page.url() === server.PREFIX + '/frames/nested-frames.html';
|
||||||
@ -815,6 +826,7 @@ describe('Launcher specs', function () {
|
|||||||
try {
|
try {
|
||||||
const browserTwo = await puppeteer.connect({
|
const browserTwo = await puppeteer.connect({
|
||||||
browserWSEndpoint: browserOne.wsEndpoint(),
|
browserWSEndpoint: browserOne.wsEndpoint(),
|
||||||
|
protocol: browserOne.protocol,
|
||||||
});
|
});
|
||||||
const [page1, page2] = await Promise.all([
|
const [page1, page2] = await Promise.all([
|
||||||
new Promise<Page | null>(x => {
|
new Promise<Page | null>(x => {
|
||||||
@ -854,6 +866,7 @@ describe('Launcher specs', function () {
|
|||||||
|
|
||||||
const browserTwo = await puppeteer.connect({
|
const browserTwo = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
|
protocol: browserOne.protocol,
|
||||||
});
|
});
|
||||||
const pages = await browserTwo.pages();
|
const pages = await browserTwo.pages();
|
||||||
const pageTwo = pages.find(page => {
|
const pageTwo = pages.find(page => {
|
||||||
@ -951,9 +964,11 @@ describe('Launcher specs', function () {
|
|||||||
const browserWSEndpoint = browser.wsEndpoint();
|
const browserWSEndpoint = browser.wsEndpoint();
|
||||||
const remoteBrowser1 = await puppeteer.connect({
|
const remoteBrowser1 = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
const remoteBrowser2 = await puppeteer.connect({
|
const remoteBrowser2 = await puppeteer.connect({
|
||||||
browserWSEndpoint,
|
browserWSEndpoint,
|
||||||
|
protocol: browser.protocol,
|
||||||
});
|
});
|
||||||
|
|
||||||
let disconnectedOriginal = 0;
|
let disconnectedOriginal = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user