Bug 1806794 - Support "network.response" events for cached responses r=webdriver-reviewers,whimboo,devtools-reviewers,ochameau

This fixes two issues:
- the transferred size was missing from cached responseStarted events
- the fromCache flag needs to be read on the initial network event payload from devtools, because relying on the isFromCache logic used to build the addResponseStart payload does not properly detect all cached responses (eg for a cached 301)

Differential Revision: https://phabricator.services.mozilla.com/D171508
This commit is contained in:
Julian Descottes 2023-03-16 14:01:03 +00:00
parent 0b1f7a1ae5
commit ab3931ad56
2 changed files with 5 additions and 1 deletions

View File

@ -481,6 +481,7 @@ export class NetworkObserver {
statusText,
bodySize: 0,
headersSize: 0,
transferredSize: 0,
waitingTime: 0,
},
"",

View File

@ -19,6 +19,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
*/
export class NetworkEventRecord {
#channel;
#fromCache;
#networkListener;
#redirectCount;
#requestData;
@ -38,6 +39,8 @@ export class NetworkEventRecord {
*/
constructor(networkEvent, channel, networkListener) {
this.#channel = channel;
this.#fromCache = networkEvent.fromCache;
this.#wrappedChannel = ChannelWrapper.get(channel);
this.#networkListener = networkListener;
@ -115,7 +118,7 @@ export class NetworkEventRecord {
...this.#responseData,
bodySize: response.bodySize,
bytesReceived: response.transferredSize,
fromCache: response.fromCache,
fromCache: this.#fromCache || response.fromCache,
// Note: at this point we only have access to the headers size. Parsed
// headers will be added in addResponseHeaders.
headersSize: response.headersSize,