Cleanup Page class

This patch removes unneeded dependency from Page
to Browser.
This commit is contained in:
Andrey Lushnikov 2017-06-15 21:35:31 -07:00
parent f62cfc3b34
commit ff2c3bbca9
2 changed files with 4 additions and 7 deletions

View File

@ -73,7 +73,7 @@ class Browser {
if (!this._chromeProcess || this._terminated)
throw new Error('ERROR: this chrome instance is not alive any more!');
var client = await Connection.create(this._remoteDebuggingPort);
var page = await Page.create(this, client);
var page = await Page.create(client);
return page;
}

View File

@ -23,11 +23,10 @@ var Dialog = require('./Dialog');
class Page extends EventEmitter {
/**
* @param {!Browser} browser
* @param {!Connection} client
* @return {!Promise<!Page>}
*/
static async create(browser, client) {
static async create(client) {
await Promise.all([
client.send('Network.enable', {}),
client.send('Page.enable', {}),
@ -35,20 +34,18 @@ class Page extends EventEmitter {
client.send('Security.enable', {}),
]);
var screenDPI = await helpers.evaluate(client, () => window.devicePixelRatio, []);
var page = new Page(browser, client, screenDPI.result.value);
var page = new Page(client, screenDPI.result.value);
// Initialize default page size.
await page.setViewportSize({width: 400, height: 300});
return page;
}
/**
* @param {!Browser} browser
* @param {!Connection} client
* @param {number} screenDPI
*/
constructor(browser, client, screenDPI) {
constructor(client, screenDPI) {
super();
this._browser = browser;
this._client = client;
this._screenDPI = screenDPI;
this._extraHeaders = {};