chore: move static constructor to the top (#3873)

This commit is contained in:
Andrey Lushnikov 2019-01-31 17:33:38 -08:00 committed by GitHub
parent d89ec00122
commit 3c516f2114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,20 @@ const {TaskQueue} = require('./TaskQueue');
const {Events} = require('./Events'); const {Events} = require('./Events');
class Browser extends EventEmitter { class Browser extends EventEmitter {
/**
* @param {!Puppeteer.Connection} connection
* @param {!Array<string>} contextIds
* @param {boolean} ignoreHTTPSErrors
* @param {?Puppeteer.Viewport} defaultViewport
* @param {?Puppeteer.ChildProcess} process
* @param {function()=} closeCallback
*/
static async create(connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback) {
const browser = new Browser(connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback);
await connection.send('Target.setDiscoverTargets', {discover: true});
return browser;
}
/** /**
* @param {!Puppeteer.Connection} connection * @param {!Puppeteer.Connection} connection
* @param {!Array<string>} contextIds * @param {!Array<string>} contextIds
@ -91,20 +105,6 @@ class Browser extends EventEmitter {
this._contexts.delete(contextId); this._contexts.delete(contextId);
} }
/**
* @param {!Puppeteer.Connection} connection
* @param {!Array<string>} contextIds
* @param {boolean} ignoreHTTPSErrors
* @param {?Puppeteer.Viewport} defaultViewport
* @param {?Puppeteer.ChildProcess} process
* @param {function()=} closeCallback
*/
static async create(connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback) {
const browser = new Browser(connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback);
await connection.send('Target.setDiscoverTargets', {discover: true});
return browser;
}
/** /**
* @param {!Protocol.Target.targetCreatedPayload} event * @param {!Protocol.Target.targetCreatedPayload} event
*/ */