Skip to content

Commit

Permalink
core(network-recorder): set target type of unfinished request (#15232)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Jul 7, 2023
1 parent 477c876 commit 7c5f223
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/lib/network-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class NetworkRecorder extends RequestEventEmitter {
const request = new NetworkRequest();
request.onRequestWillBeSent(data);
request.sessionId = event.sessionId;
request.sessionTargetType = event.targetType;
this.onRequestStarted(request);
log.verbose('network', `request will be sent to ${request.url}`);
return;
Expand Down
13 changes: 13 additions & 0 deletions core/test/lib/network-recorder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ describe('network recorder', function() {
]);
});

it('should set sessionId and sessionTargetType of from just request event', () => {
const devtoolsLogs = networkRecordsToDevtoolsLog([
{url: 'http://iframe.com', sessionId: 'session2', sessionTargetType: 'iframe'},
]);
const requestWillBeSentLog =
devtoolsLogs.filter(entry => entry.method === 'Network.requestWillBeSent');

const records = NetworkRecorder.recordsFromLogs(requestWillBeSentLog);
expect(records).toMatchObject([
{url: 'http://iframe.com', sessionTargetType: 'iframe', sessionId: 'session2'},
]);
});

it('should handle prefetch requests', () => {
const records = NetworkRecorder.recordsFromLogs(prefetchedScriptDevtoolsLog);
expect(records).toHaveLength(5);
Expand Down

0 comments on commit 7c5f223

Please sign in to comment.