mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
refactor: move to flatten protocol (#3827)
DevTools protocol is dropping nested targets and switching to flatten protocol. This patch adopts the new scheme. Once this change lands, tip-of-tree Puppeteer will be incompatible with Chromium below 72.0.3606.0. Chromium 72 goes stable on [Jan, 29](https://www.chromestatus.com/features/schedule) - the same time we release the next version of Puppeteer, so this change won't hurt those clients who try using tip-of-tree Puppeteer with stable chrome. For the record: the previous attempt to land this was https://github.com/GoogleChrome/puppeteer/pull/3524.
This commit is contained in:
@@ -18,6 +18,7 @@ const fs = require('fs');
|
||||
const EventEmitter = require('events');
|
||||
const mime = require('mime');
|
||||
const {Events} = require('./Events');
|
||||
const {Connection} = require('./Connection');
|
||||
const {NetworkManager} = require('./NetworkManager');
|
||||
const {Dialog} = require('./Dialog');
|
||||
const {EmulationManager} = require('./EmulationManager');
|
||||
@@ -47,7 +48,7 @@ class Page extends EventEmitter {
|
||||
const page = new Page(client, target, frameTree, ignoreHTTPSErrors, screenshotTaskQueue);
|
||||
|
||||
await Promise.all([
|
||||
client.send('Target.setAutoAttach', {autoAttach: true, waitForDebuggerOnStart: false}),
|
||||
client.send('Target.setAutoAttach', {autoAttach: true, waitForDebuggerOnStart: false, flatten: true}),
|
||||
client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
|
||||
client.send('Network.enable', {}),
|
||||
client.send('Runtime.enable', {}).then(() => page._frameManager.ensureSecondaryDOMWorld()),
|
||||
@@ -106,11 +107,10 @@ class Page extends EventEmitter {
|
||||
}).catch(debugError);
|
||||
return;
|
||||
}
|
||||
const session = client._createSession(event.targetInfo.type, event.sessionId);
|
||||
const session = Connection.fromSession(client).session(event.sessionId);
|
||||
const worker = new Worker(session, event.targetInfo.url, this._addConsoleMessage.bind(this), this._handleException.bind(this));
|
||||
this._workers.set(event.sessionId, worker);
|
||||
this.emit(Events.Page.WorkerCreated, worker);
|
||||
|
||||
});
|
||||
client.on('Target.detachedFromTarget', event => {
|
||||
const worker = this._workers.get(event.sessionId);
|
||||
|
||||
Reference in New Issue
Block a user