mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Cleanup Page class
This patch removes unneeded dependency from Page to Browser.
This commit is contained in:
parent
f62cfc3b34
commit
ff2c3bbca9
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 = {};
|
||||
|
Loading…
Reference in New Issue
Block a user