Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(network-recorder): set target type of unfinished request #15232

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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