-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(oopif): autoattach to all descendants #7517
Changes from 4 commits
7f2f90c
ddd8ee5
552f042
b33d132
e6f2d43
5545c08
79932bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,17 +69,17 @@ class Driver { | |
*/ | ||
this._monitoredUrl = null; | ||
|
||
let targetProxyMessageId = 0; | ||
this.on('Target.attachedToTarget', event => { | ||
targetProxyMessageId++; | ||
// We're only interested in network requests from iframes for now as those are "part of the page". | ||
if (event.targetInfo.type !== 'iframe') return; | ||
|
||
// We want to receive information about network requests from iframes, so enable the Network domain. | ||
// Network events from subtargets will be stringified and sent back on `Target.receivedMessageFromTarget`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still get back these messages over the target domain? In https://github.com/GoogleChrome/puppeteer/pull/3827/files#diff-0c1fe9dd78cc7f29823c09b251c8aae0R109 I saw the sessionId being received and handled in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops no, I need to update the comment 馃憤 |
||
this.sendCommand('Target.sendMessageToTarget', { | ||
message: JSON.stringify({id: targetProxyMessageId, method: 'Network.enable'}), | ||
sessionId: event.sessionId, | ||
this.sendCommand({method: 'Network.enable', sessionId: event.sessionId}); | ||
this.sendCommand({method: 'Target.setAutoAttach', sessionId: event.sessionId}, { | ||
autoAttach: true, | ||
waitForDebuggerOnStart: false, | ||
flatten: true, | ||
}); | ||
}); | ||
|
||
|
@@ -279,11 +279,15 @@ class Driver { | |
* Call protocol methods, with a timeout. | ||
* To configure the timeout for the next call, use 'setNextProtocolTimeout'. | ||
* @template {keyof LH.CrdpCommands} C | ||
* @param {C} method | ||
* @param {C|{method: C, sessionId: string}} methodObj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yah I dig this solution. A followup PR can move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel the same way about this as I did for #6347 :) We're trying to generalize a simple thing by making it more complicated, just for the two calls that need it. Since they're both inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sure |
||
* @param {LH.CrdpCommands[C]['paramsType']} params | ||
* @return {Promise<LH.CrdpCommands[C]['returnType']>} | ||
*/ | ||
sendCommand(method, ...params) { | ||
sendCommand(methodObj, ...params) { | ||
/** @type {C} */ | ||
const method = typeof methodObj === 'string' ? methodObj : methodObj.method; | ||
const sessionId = typeof methodObj === 'string' ? undefined : methodObj.sessionId; | ||
|
||
const timeout = this._nextProtocolTimeout; | ||
this._nextProtocolTimeout = DEFAULT_PROTOCOL_TIMEOUT; | ||
return new Promise(async (resolve, reject) => { | ||
|
@@ -295,7 +299,7 @@ class Driver { | |
reject(err); | ||
}), timeout); | ||
try { | ||
const result = await this._innerSendCommand(method, ...params); | ||
const result = await this._innerSendCommand(method, sessionId, ...params); | ||
resolve(result); | ||
} catch (err) { | ||
reject(err); | ||
|
@@ -310,18 +314,19 @@ class Driver { | |
* @private | ||
* @template {keyof LH.CrdpCommands} C | ||
* @param {C} method | ||
* @param {string|undefined} sessionId | ||
* @param {LH.CrdpCommands[C]['paramsType']} params | ||
* @return {Promise<LH.CrdpCommands[C]['returnType']>} | ||
*/ | ||
_innerSendCommand(method, ...params) { | ||
_innerSendCommand(method, sessionId, ...params) { | ||
const domainCommand = /^(\w+)\.(enable|disable)$/.exec(method); | ||
if (domainCommand) { | ||
if (domainCommand && !sessionId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we're going to expand to other targets, we should probably track enabled domains there as well... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll use your point back atcha for now ;) It's only the two messages that are never disabled, so we can cross that bridge when we get to it IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ha, I am 馃憣馃憣 with crossing that bridge later, but maybe leave a comment about not bothering to check other targets? |
||
const enable = domainCommand[2] === 'enable'; | ||
if (!this._shouldToggleDomain(domainCommand[1], enable)) { | ||
return Promise.resolve(); | ||
} | ||
} | ||
return this._connection.sendCommand(method, ...params); | ||
return this._connection.sendCommand(method, sessionId, ...params); | ||
} | ||
|
||
/** | ||
|
@@ -1045,13 +1050,14 @@ class Driver { | |
await this.sendCommand('Target.setAutoAttach', { | ||
autoAttach: true, | ||
waitForDebuggerOnStart: false, | ||
flatten: true, | ||
}); | ||
|
||
await this.sendCommand('Page.enable'); | ||
await this.sendCommand('Page.setLifecycleEventsEnabled', {enabled: true}); | ||
await this.sendCommand('Emulation.setScriptExecutionDisabled', {value: disableJS}); | ||
// No timeout needed for Page.navigate. See https://github.com/GoogleChrome/lighthouse/pull/6413. | ||
const waitforPageNavigateCmd = this._innerSendCommand('Page.navigate', {url}); | ||
const waitforPageNavigateCmd = this._innerSendCommand('Page.navigate', undefined, {url}); | ||
|
||
if (waitForNavigated) { | ||
await this._waitForFrameNavigated(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,9 +249,7 @@ describe('network recorder', function() { | |
]; | ||
|
||
const periods = NetworkRecorder.findNetworkQuietPeriods(records, 0); | ||
assert.deepStrictEqual(periods, [ | ||
{start: 1200, end: Infinity}, | ||
]); | ||
assert.deepStrictEqual(periods, []); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what changed with the quiet period? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was the intentional removal of our hack for frame roots, now if an iframe never fires There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, got it, I wasn't thinking about the |
||
}); | ||
|
||
it('should handle QUIC requests', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling this is going to have a big effect on TTI as network idle is likely going to be pushed out in a bunch of cases.