chore(docs): migrate BrowserContext
events (#6168)
This commit is contained in:
parent
e2e050259f
commit
2256b8d7d7
@ -15,6 +15,8 @@ export declare class BrowserContext extends EventEmitter
|
|||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|
||||||
|
The Browser class extends from Puppeteer's [EventEmitter](./puppeteer.eventemitter.md) class and will emit various events which are documented in the [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md) enum.
|
||||||
|
|
||||||
If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context.
|
If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context.
|
||||||
|
|
||||||
Puppeteer allows creation of "incognito" browser contexts with [Browser.createIncognitoBrowserContext](./puppeteer.browser.createincognitobrowsercontext.md) method. "Incognito" browser contexts don't write any browsing data to disk.
|
Puppeteer allows creation of "incognito" browser contexts with [Browser.createIncognitoBrowserContext](./puppeteer.browser.createincognitobrowsercontext.md) method. "Incognito" browser contexts don't write any browsing data to disk.
|
||||||
|
20
new-docs/puppeteer.browsercontextemittedevents.md
Normal file
20
new-docs/puppeteer.browsercontextemittedevents.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md)
|
||||||
|
|
||||||
|
## BrowserContextEmittedEvents enum
|
||||||
|
|
||||||
|
<b>Signature:</b>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare const enum BrowserContextEmittedEvents
|
||||||
|
```
|
||||||
|
|
||||||
|
## Enumeration Members
|
||||||
|
|
||||||
|
| Member | Value | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| TargetChanged | <code>"targetchanged"</code> | Emitted when the url of a target inside the browser context changes. Contains a [Target](./puppeteer.target.md) instance. |
|
||||||
|
| TargetCreated | <code>"targetcreated"</code> | Emitted when a target is created within the browser context, for example when a new page is opened by [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) or by [browserContext.newPage](./puppeteer.browsercontext.newpage.md)<!-- -->Contains a [Target](./puppeteer.target.md) instance. |
|
||||||
|
| TargetDestroyed | <code>"targetdestroyed"</code> | Emitted when a target is destroyed within the browser context, for example when a page is closed. Contains a [Target](./puppeteer.target.md) instance. |
|
||||||
|
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
| Enumeration | Description |
|
| Enumeration | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
| [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md) | |
|
||||||
| [BrowserEmittedEvents](./puppeteer.browseremittedevents.md) | All the events a [browser instance](./puppeteer.browser.md) may emit. |
|
| [BrowserEmittedEvents](./puppeteer.browseremittedevents.md) | All the events a [browser instance](./puppeteer.browser.md) may emit. |
|
||||||
| [PageEmittedEvents](./puppeteer.pageemittedevents.md) | All the events that a page instance may emit. |
|
| [PageEmittedEvents](./puppeteer.pageemittedevents.md) | All the events that a page instance may emit. |
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ export class Browser extends EventEmitter {
|
|||||||
|
|
||||||
if (await target._initializedPromise) {
|
if (await target._initializedPromise) {
|
||||||
this.emit(BrowserEmittedEvents.TargetCreated, target);
|
this.emit(BrowserEmittedEvents.TargetCreated, target);
|
||||||
context.emit(Events.BrowserContext.TargetCreated, target);
|
context.emit(BrowserContextEmittedEvents.TargetCreated, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ export class Browser extends EventEmitter {
|
|||||||
this.emit(BrowserEmittedEvents.TargetDestroyed, target);
|
this.emit(BrowserEmittedEvents.TargetDestroyed, target);
|
||||||
target
|
target
|
||||||
.browserContext()
|
.browserContext()
|
||||||
.emit(Events.BrowserContext.TargetDestroyed, target);
|
.emit(BrowserContextEmittedEvents.TargetDestroyed, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +324,9 @@ export class Browser extends EventEmitter {
|
|||||||
target._targetInfoChanged(event.targetInfo);
|
target._targetInfoChanged(event.targetInfo);
|
||||||
if (wasInitialized && previousURL !== target.url()) {
|
if (wasInitialized && previousURL !== target.url()) {
|
||||||
this.emit(BrowserEmittedEvents.TargetChanged, target);
|
this.emit(BrowserEmittedEvents.TargetChanged, target);
|
||||||
target.browserContext().emit(Events.BrowserContext.TargetChanged, target);
|
target
|
||||||
|
.browserContext()
|
||||||
|
.emit(BrowserContextEmittedEvents.TargetChanged, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,16 +506,43 @@ export class Browser extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const enum BrowserContextEmittedEvents {
|
||||||
|
/**
|
||||||
|
* Emitted when the url of a target inside the browser context changes.
|
||||||
|
* Contains a {@link Target} instance.
|
||||||
|
*/
|
||||||
|
TargetChanged = 'targetchanged',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when a target is created within the browser context, 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 BrowserContext.newPage | browserContext.newPage}
|
||||||
|
*
|
||||||
|
* Contains a {@link Target} instance.
|
||||||
|
*/
|
||||||
|
TargetCreated = 'targetcreated',
|
||||||
|
/**
|
||||||
|
* Emitted when a target is destroyed within the browser context, for example
|
||||||
|
* when a page is closed. Contains a {@link Target} instance.
|
||||||
|
*/
|
||||||
|
TargetDestroyed = 'targetdestroyed',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BrowserContexts provide a way to operate multiple independent browser sessions.
|
* BrowserContexts provide a way to operate multiple independent browser
|
||||||
* When a browser is launched, it has a single BrowserContext used by default.
|
* sessions. When a browser is launched, it has a single BrowserContext used by
|
||||||
* The method {@link Browser.newPage | Browser.newPage} creates a page
|
* default. The method {@link Browser.newPage | Browser.newPage} creates a page
|
||||||
* in the default browser context.
|
* in the default browser context.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
*
|
*
|
||||||
* If a page opens another page, e.g. with a `window.open` call,
|
* The Browser class extends from Puppeteer's {@link EventEmitter} class and
|
||||||
* the popup will belong to the parent page's browser context.
|
* will emit various events which are documented in the
|
||||||
|
* {@link BrowserContextEmittedEvents} enum.
|
||||||
|
*
|
||||||
|
* If a page opens another page, e.g. with a `window.open` call, the popup will
|
||||||
|
* belong to the parent page's browser context.
|
||||||
*
|
*
|
||||||
* Puppeteer allows creation of "incognito" browser contexts with
|
* Puppeteer allows creation of "incognito" browser contexts with
|
||||||
* {@link Browser.createIncognitoBrowserContext | Browser.createIncognitoBrowserContext}
|
* {@link Browser.createIncognitoBrowserContext | Browser.createIncognitoBrowserContext}
|
||||||
|
Loading…
Reference in New Issue
Block a user