2022-09-14 14:40:58 +00:00
|
|
|
/**
|
2024-01-03 10:11:33 +00:00
|
|
|
* @license
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
|
2023-09-26 16:24:24 +00:00
|
|
|
import type {ChildProcess} from 'child_process';
|
2023-02-15 23:09:31 +00:00
|
|
|
|
2023-09-26 16:24:24 +00:00
|
|
|
import type {Protocol} from 'devtools-protocol';
|
2023-02-15 23:09:31 +00:00
|
|
|
|
2023-10-11 08:11:22 +00:00
|
|
|
import {
|
|
|
|
firstValueFrom,
|
|
|
|
from,
|
|
|
|
merge,
|
|
|
|
raceWith,
|
|
|
|
filterAsync,
|
|
|
|
fromEvent,
|
|
|
|
type Observable,
|
|
|
|
} from '../../third_party/rxjs/rxjs.js';
|
2023-11-16 07:23:08 +00:00
|
|
|
import type {ProtocolType} from '../common/ConnectOptions.js';
|
2023-09-15 11:00:20 +00:00
|
|
|
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
|
2023-10-11 08:11:22 +00:00
|
|
|
import {debugError} from '../common/util.js';
|
|
|
|
import {timeout} from '../common/util.js';
|
2023-09-19 16:13:51 +00:00
|
|
|
import {asyncDisposeSymbol, disposeSymbol} from '../util/disposable.js';
|
2023-02-15 23:09:31 +00:00
|
|
|
|
2022-10-19 07:06:31 +00:00
|
|
|
import type {BrowserContext} from './BrowserContext.js';
|
2023-07-17 12:13:13 +00:00
|
|
|
import type {Page} from './Page.js';
|
2023-07-21 07:04:14 +00:00
|
|
|
import type {Target} from './Target.js';
|
2022-09-14 14:40:58 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface BrowserContextOptions {
|
|
|
|
/**
|
|
|
|
* Proxy server with optional port to use for all requests.
|
|
|
|
* Username and password can be set in `Page.authenticate`.
|
|
|
|
*/
|
|
|
|
proxyServer?: string;
|
|
|
|
/**
|
|
|
|
* Bypass the proxy for the given list of hosts.
|
|
|
|
*/
|
|
|
|
proxyBypassList?: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export type BrowserCloseCallback = () => Promise<void> | void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2023-07-20 14:18:00 +00:00
|
|
|
export type TargetFilterCallback = (target: Target) => boolean;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2023-07-20 14:18:00 +00:00
|
|
|
export type IsPageTargetCallback = (target: Target) => boolean;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export const WEB_PERMISSION_TO_PROTOCOL_PERMISSION = new Map<
|
|
|
|
Permission,
|
|
|
|
Protocol.Browser.PermissionType
|
|
|
|
>([
|
|
|
|
['geolocation', 'geolocation'],
|
|
|
|
['midi', 'midi'],
|
|
|
|
['notifications', 'notifications'],
|
|
|
|
// TODO: push isn't a valid type?
|
|
|
|
// ['push', 'push'],
|
|
|
|
['camera', 'videoCapture'],
|
|
|
|
['microphone', 'audioCapture'],
|
|
|
|
['background-sync', 'backgroundSync'],
|
|
|
|
['ambient-light-sensor', 'sensors'],
|
|
|
|
['accelerometer', 'sensors'],
|
|
|
|
['gyroscope', 'sensors'],
|
|
|
|
['magnetometer', 'sensors'],
|
|
|
|
['accessibility-events', 'accessibilityEvents'],
|
|
|
|
['clipboard-read', 'clipboardReadWrite'],
|
|
|
|
['clipboard-write', 'clipboardReadWrite'],
|
2023-06-19 08:53:54 +00:00
|
|
|
['clipboard-sanitized-write', 'clipboardSanitizedWrite'],
|
2022-09-14 14:40:58 +00:00
|
|
|
['payment-handler', 'paymentHandler'],
|
|
|
|
['persistent-storage', 'durableStorage'],
|
|
|
|
['idle-detection', 'idleDetection'],
|
|
|
|
// chrome-specific permissions we have.
|
|
|
|
['midi-sysex', 'midiSysex'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type Permission =
|
|
|
|
| 'geolocation'
|
|
|
|
| 'midi'
|
|
|
|
| 'notifications'
|
|
|
|
| 'camera'
|
|
|
|
| 'microphone'
|
|
|
|
| 'background-sync'
|
|
|
|
| 'ambient-light-sensor'
|
|
|
|
| 'accelerometer'
|
|
|
|
| 'gyroscope'
|
|
|
|
| 'magnetometer'
|
|
|
|
| 'accessibility-events'
|
|
|
|
| 'clipboard-read'
|
|
|
|
| 'clipboard-write'
|
2023-06-19 08:53:54 +00:00
|
|
|
| 'clipboard-sanitized-write'
|
2022-09-14 14:40:58 +00:00
|
|
|
| 'payment-handler'
|
|
|
|
| 'persistent-storage'
|
|
|
|
| 'idle-detection'
|
|
|
|
| 'midi-sysex';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface WaitForTargetOptions {
|
|
|
|
/**
|
|
|
|
* Maximum wait time in milliseconds. Pass `0` to disable the timeout.
|
2023-09-18 09:05:23 +00:00
|
|
|
*
|
2023-03-29 13:27:29 +00:00
|
|
|
* @defaultValue `30_000`
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
timeout?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All the events a {@link Browser | browser instance} may emit.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
*/
|
2023-09-13 13:47:55 +00:00
|
|
|
export const enum BrowserEvent {
|
2022-09-14 14:40:58 +00:00
|
|
|
/**
|
2023-05-02 06:53:40 +00:00
|
|
|
* Emitted when Puppeteer gets disconnected from the browser instance. This
|
2023-09-18 09:05:23 +00:00
|
|
|
* might happen because either:
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* - The browser closes/crashes or
|
|
|
|
* - {@link Browser.disconnect} was called.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
Disconnected = 'disconnected',
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Emitted when the URL of a target changes. Contains a {@link Target}
|
|
|
|
* instance.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @remarks Note that this includes target changes in incognito browser
|
|
|
|
* contexts.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
TargetChanged = 'targetchanged',
|
|
|
|
/**
|
|
|
|
* Emitted when a target is created, for example when a new page is opened by
|
|
|
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
|
|
|
|
* or by {@link Browser.newPage | browser.newPage}
|
|
|
|
*
|
|
|
|
* Contains a {@link Target} instance.
|
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @remarks Note that this includes target creations in incognito browser
|
|
|
|
* contexts.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
TargetCreated = 'targetcreated',
|
|
|
|
/**
|
|
|
|
* Emitted when a target is destroyed, for example when a page is closed.
|
|
|
|
* Contains a {@link Target} instance.
|
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @remarks Note that this includes target destructions in incognito browser
|
|
|
|
* contexts.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
|
|
|
TargetDestroyed = 'targetdestroyed',
|
2023-09-13 13:47:55 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
TargetDiscovered = 'targetdiscovered',
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
/**
|
|
|
|
* @deprecated Use {@link BrowserEvent}.
|
|
|
|
*/
|
|
|
|
BrowserEvent as BrowserEmittedEvents,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface BrowserEvents extends Record<EventType, unknown> {
|
|
|
|
[BrowserEvent.Disconnected]: undefined;
|
|
|
|
[BrowserEvent.TargetCreated]: Target;
|
|
|
|
[BrowserEvent.TargetDestroyed]: Target;
|
|
|
|
[BrowserEvent.TargetChanged]: Target;
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
[BrowserEvent.TargetDiscovered]: Protocol.Target.TargetInfo;
|
2022-09-14 14:40:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* {@link Browser} represents a browser instance that is either:
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* - connected to via {@link Puppeteer.connect} or
|
|
|
|
* - launched by {@link PuppeteerNode.launch}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* {@link Browser} {@link EventEmitter | emits} various events which are
|
|
|
|
* documented in the {@link BrowserEvent} enum.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @example Using a {@link Browser} to create a {@link Page}:
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
|
|
|
* ```ts
|
2022-12-09 12:57:39 +00:00
|
|
|
* import puppeteer from 'puppeteer';
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* const browser = await puppeteer.launch();
|
|
|
|
* const page = await browser.newPage();
|
|
|
|
* await page.goto('https://example.com');
|
|
|
|
* await browser.close();
|
2022-09-14 14:40:58 +00:00
|
|
|
* ```
|
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @example Disconnecting from and reconnecting to a {@link Browser}:
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
|
|
|
* ```ts
|
2022-12-09 12:57:39 +00:00
|
|
|
* import puppeteer from 'puppeteer';
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* const browser = await puppeteer.launch();
|
|
|
|
* // Store the endpoint to be able to reconnect to the browser.
|
|
|
|
* const browserWSEndpoint = browser.wsEndpoint();
|
|
|
|
* // Disconnect puppeteer from the browser.
|
2023-11-30 14:27:49 +00:00
|
|
|
* await browser.disconnect();
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* // Use the endpoint to reestablish a connection
|
|
|
|
* const browser2 = await puppeteer.connect({browserWSEndpoint});
|
|
|
|
* // Close the browser.
|
|
|
|
* await browser2.close();
|
2022-09-14 14:40:58 +00:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
export abstract class Browser extends EventEmitter<BrowserEvents> {
|
2022-09-14 14:40:58 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets the associated
|
|
|
|
* {@link https://nodejs.org/api/child_process.html#class-childprocess | ChildProcess}.
|
|
|
|
*
|
|
|
|
* @returns `null` if this instance was connected to via
|
2022-09-14 14:40:58 +00:00
|
|
|
* {@link Puppeteer.connect}.
|
|
|
|
*/
|
2023-11-09 12:57:33 +00:00
|
|
|
abstract process(): ChildProcess | null;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Creates a new incognito {@link BrowserContext | browser context}.
|
|
|
|
*
|
|
|
|
* This won't share cookies/cache with other {@link BrowserContext | browser contexts}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
|
|
|
* @example
|
|
|
|
*
|
|
|
|
* ```ts
|
2023-09-18 09:05:23 +00:00
|
|
|
* import puppeteer from 'puppeteer';
|
|
|
|
*
|
|
|
|
* const browser = await puppeteer.launch();
|
|
|
|
* // Create a new incognito browser context.
|
|
|
|
* const context = await browser.createIncognitoBrowserContext();
|
|
|
|
* // Create a new page in a pristine context.
|
|
|
|
* const page = await context.newPage();
|
|
|
|
* // Do stuff
|
|
|
|
* await page.goto('https://example.com');
|
2022-09-14 14:40:58 +00:00
|
|
|
* ```
|
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract createIncognitoBrowserContext(
|
2022-09-14 14:40:58 +00:00
|
|
|
options?: BrowserContextOptions
|
|
|
|
): Promise<BrowserContext>;
|
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets a list of open {@link BrowserContext | browser contexts}.
|
|
|
|
*
|
|
|
|
* In a newly-created {@link Browser | browser}, this will return a single
|
|
|
|
* instance of {@link BrowserContext}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract browserContexts(): BrowserContext[];
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets the default {@link BrowserContext | browser context}.
|
|
|
|
*
|
|
|
|
* @remarks The default {@link BrowserContext | browser context} cannot be
|
|
|
|
* closed.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract defaultBrowserContext(): BrowserContext;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets the WebSocket URL to connect to this {@link Browser | browser}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* This is usually used with {@link Puppeteer.connect}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* You can find the debugger URL (`webSocketDebuggerUrl`) from
|
2023-11-29 13:29:13 +00:00
|
|
|
* `http://HOST:PORT/json/version`.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* See {@link
|
2022-09-14 14:40:58 +00:00
|
|
|
* https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
|
2023-09-18 09:05:23 +00:00
|
|
|
* | browser endpoint} for more information.
|
|
|
|
*
|
2023-11-29 13:29:13 +00:00
|
|
|
* @remarks The format is always `ws://HOST:PORT/devtools/browser/<id>`.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract wsEndpoint(): string;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Creates a new {@link Page | page} in the
|
|
|
|
* {@link Browser.defaultBrowserContext | default browser context}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract newPage(): Promise<Page>;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets all active {@link Target | targets}.
|
|
|
|
*
|
|
|
|
* In case of multiple {@link BrowserContext | browser contexts}, this returns
|
|
|
|
* all {@link Target | targets} in all
|
|
|
|
* {@link BrowserContext | browser contexts}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract targets(): Target[];
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets the {@link Target | target} associated with the
|
|
|
|
* {@link Browser.defaultBrowserContext | default browser context}).
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract target(): Target;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Waits until a {@link Target | target} matching the given `predicate`
|
|
|
|
* appears and returns it.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* This will look all open {@link BrowserContext | browser contexts}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @example Finding a target for a page opened via `window.open`:
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* await page.evaluate(() => window.open('https://www.example.com/'));
|
|
|
|
* const newWindowTarget = await browser.waitForTarget(
|
|
|
|
* target => target.url() === 'https://www.example.com/'
|
|
|
|
* );
|
|
|
|
* ```
|
|
|
|
*/
|
2023-07-24 10:23:39 +00:00
|
|
|
async waitForTarget(
|
2022-09-14 14:40:58 +00:00
|
|
|
predicate: (x: Target) => boolean | Promise<boolean>,
|
2023-07-24 10:23:39 +00:00
|
|
|
options: WaitForTargetOptions = {}
|
|
|
|
): Promise<Target> {
|
2023-10-11 08:11:22 +00:00
|
|
|
const {timeout: ms = 30000} = options;
|
|
|
|
return await firstValueFrom(
|
|
|
|
merge(
|
|
|
|
fromEvent(this, BrowserEvent.TargetCreated) as Observable<Target>,
|
|
|
|
fromEvent(this, BrowserEvent.TargetChanged) as Observable<Target>,
|
|
|
|
from(this.targets())
|
|
|
|
).pipe(filterAsync(predicate), raceWith(timeout(ms)))
|
|
|
|
);
|
2022-09-14 14:40:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-21 09:09:27 +00:00
|
|
|
* Gets a list of all open {@link Page | pages} inside this {@link Browser}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* If there ar multiple {@link BrowserContext | browser contexts}, this
|
|
|
|
* returns all {@link Page | pages} in all
|
|
|
|
* {@link BrowserContext | browser contexts}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
|
|
|
|
* will not be listed here. You can find them using {@link Target.page}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-06-16 13:27:31 +00:00
|
|
|
async pages(): Promise<Page[]> {
|
|
|
|
const contextPages = await Promise.all(
|
|
|
|
this.browserContexts().map(context => {
|
|
|
|
return context.pages();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
// Flatten array.
|
|
|
|
return contextPages.reduce((acc, x) => {
|
|
|
|
return acc.concat(x);
|
|
|
|
}, []);
|
2022-09-14 14:40:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets a string representing this {@link Browser | browser's} name and
|
|
|
|
* version.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* For headless browser, this is similar to `"HeadlessChrome/61.0.3153.0"`. For
|
|
|
|
* non-headless or new-headless, this is similar to `"Chrome/61.0.3153.0"`. For
|
|
|
|
* Firefox, it is similar to `"Firefox/116.0a1"`.
|
2022-09-14 14:40:58 +00:00
|
|
|
*
|
2023-09-18 09:05:23 +00:00
|
|
|
* The format of {@link Browser.version} might change with future releases of
|
2023-06-13 08:17:23 +00:00
|
|
|
* browsers.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract version(): Promise<string>;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Gets this {@link Browser | browser's} original user agent.
|
|
|
|
*
|
|
|
|
* {@link Page | Pages} can override the user agent with
|
2022-09-14 14:40:58 +00:00
|
|
|
* {@link Page.setUserAgent}.
|
2023-11-16 07:22:32 +00:00
|
|
|
*
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-11-09 12:57:33 +00:00
|
|
|
abstract userAgent(): Promise<string>;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Closes this {@link Browser | browser} and all associated
|
|
|
|
* {@link Page | pages}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:05:23 +00:00
|
|
|
abstract close(): Promise<void>;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Disconnects Puppeteer from this {@link Browser | browser}, but leaves the
|
|
|
|
* process running.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-11-30 14:27:49 +00:00
|
|
|
abstract disconnect(): Promise<void>;
|
2022-09-14 14:40:58 +00:00
|
|
|
|
2023-09-18 09:14:10 +00:00
|
|
|
/**
|
|
|
|
* Whether Puppeteer is connected to this {@link Browser | browser}.
|
|
|
|
*
|
|
|
|
* @deprecated Use {@link Browser.connected}.
|
|
|
|
*/
|
|
|
|
isConnected(): boolean {
|
|
|
|
return this.connected;
|
|
|
|
}
|
|
|
|
|
2022-09-14 14:40:58 +00:00
|
|
|
/**
|
2023-09-18 09:05:23 +00:00
|
|
|
* Whether Puppeteer is connected to this {@link Browser | browser}.
|
2022-09-14 14:40:58 +00:00
|
|
|
*/
|
2023-09-18 09:14:10 +00:00
|
|
|
abstract get connected(): boolean;
|
2023-08-30 11:10:06 +00:00
|
|
|
|
2023-09-15 15:07:05 +00:00
|
|
|
/** @internal */
|
2023-09-19 16:13:51 +00:00
|
|
|
[disposeSymbol](): void {
|
2023-08-30 11:10:06 +00:00
|
|
|
return void this.close().catch(debugError);
|
|
|
|
}
|
|
|
|
|
2023-09-15 15:07:05 +00:00
|
|
|
/** @internal */
|
2023-09-19 16:13:51 +00:00
|
|
|
[asyncDisposeSymbol](): Promise<void> {
|
2023-08-30 11:10:06 +00:00
|
|
|
return this.close();
|
|
|
|
}
|
2023-11-10 12:55:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2023-11-16 07:23:08 +00:00
|
|
|
abstract get protocol(): ProtocolType;
|
2022-09-14 14:40:58 +00:00
|
|
|
}
|