feat(firefox): implement browser.firefox.wsEndpoint() (#233)
This lets us pass the fixtures test for browser shutdown.
This commit is contained in:
Родитель
0675d8ec9a
Коммит
ee1f4784c6
13
docs/api.md
13
docs/api.md
|
@ -2286,6 +2286,15 @@ The `format` options are:
|
|||
> 1. Script tags inside templates are not evaluated.
|
||||
> 2. Page styles are not visible inside templates.
|
||||
|
||||
### class: Firefox
|
||||
|
||||
Firefox-specific features.
|
||||
|
||||
#### firefox.wsEndpoint()
|
||||
- returns: <[string]> Browser websocket url.
|
||||
|
||||
Browser websocket endpoint which can be used as an argument to [playwright.connect](#playwrightconnectoptions).
|
||||
|
||||
|
||||
### class: Chromium
|
||||
|
||||
|
@ -2293,9 +2302,9 @@ Chromium-specific features including Tracing, service worker support, etc.
|
|||
You can use [`chromium.startTracing`](#chromiumstarttracingpage-options) and [`chromium.stopTracing`](#chromiumstoptracing) to create a trace file which can be opened in Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
|
||||
|
||||
```js
|
||||
await page.chromium.startTracing({path: 'trace.json'});
|
||||
await browser.chromium.startTracing(page, {path: 'trace.json'});
|
||||
await page.goto('https://www.google.com');
|
||||
await page.chromium.stopTracing();
|
||||
await browser.chromium.stopTracing();
|
||||
```
|
||||
|
||||
#### event: 'targetchanged'
|
||||
|
|
|
@ -24,6 +24,7 @@ import { Permissions } from './features/permissions';
|
|||
import { Page } from '../page';
|
||||
import * as types from '../types';
|
||||
import { FrameManager } from './FrameManager';
|
||||
import { Firefox } from './features/firefox';
|
||||
import * as network from '../network';
|
||||
import { BrowserContext, BrowserInterface } from '../browserContext';
|
||||
|
||||
|
@ -36,6 +37,7 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||
private _defaultContext: BrowserContext;
|
||||
private _contexts: Map<string, BrowserContext>;
|
||||
private _eventListeners: RegisteredListener[];
|
||||
readonly firefox: Firefox;
|
||||
|
||||
static async create(connection: Connection, defaultViewport: types.Viewport | null, process: import('child_process').ChildProcess | null, closeCallback: () => Promise<void>) {
|
||||
const {browserContextIds} = await connection.send('Target.getBrowserContexts');
|
||||
|
@ -50,6 +52,7 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||
this._defaultViewport = defaultViewport;
|
||||
this._process = process;
|
||||
this._closeCallback = closeCallback;
|
||||
this.firefox = new Firefox(this);
|
||||
|
||||
this._targets = new Map();
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Browser } from '../Browser';
|
||||
import { Connection } from '../Connection';
|
||||
|
||||
export class Firefox {
|
||||
private _connection: Connection;
|
||||
|
||||
constructor(browser: Browser) {
|
||||
this._connection = browser._connection;
|
||||
}
|
||||
|
||||
wsEndpoint(): string {
|
||||
return this._connection.url();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
(async() => {
|
||||
const [, , playwrightRoot, options] = process.argv;
|
||||
const browser = await require(playwrightRoot).launch(JSON.parse(options));
|
||||
console.log(browser.chromium.wsEndpoint());
|
||||
if (browser.chromium)
|
||||
console.log(browser.chromium.wsEndpoint());
|
||||
else if (browser.firefox)
|
||||
console.log(browser.firefox.wsEndpoint());
|
||||
})();
|
||||
|
|
Загрузка…
Ссылка в новой задаче