-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: better times for generated network requests #14714
Changes from 3 commits
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 |
---|---|---|
|
@@ -41,19 +41,19 @@ describe('Metrics: Lantern FCP', () => { | |
const devtoolsLog = networkRecordsToDevtoolsLog([ | ||
{ | ||
transferSize: 2000, | ||
url: 'https://example.com/', | ||
url: 'https://example.com/', // Main document (always included). | ||
resourceType: 'Document', | ||
priority: 'High', | ||
startTime: 0, | ||
endTime: 0.0001, // Before FCP | ||
endTime: 1000, | ||
timing: {sslStart: 50, sslEnd: 100, connectStart: 50, connectEnd: 100}, | ||
Comment on lines
+48
to
49
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. these |
||
}, | ||
{ | ||
transferSize: 2000, | ||
url: 'https://example.com/script.js', | ||
resourceType: 'Script', | ||
priority: 'High', | ||
startTime: 0.015, // After FCP | ||
startTime: 1000, // After FCP. | ||
endTime: -1, | ||
timing: {sslStart: 50, sslEnd: 100, connectStart: 50, connectEnd: 100}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,29 @@ | |
*/ | ||
|
||
import InspectorIssues from '../../../gather/gatherers/inspector-issues.js'; | ||
import {NetworkRequest} from '../../../lib/network-request.js'; | ||
import {createMockContext} from '../mock-driver.js'; | ||
import {flushAllTimersAndMicrotasks, timers} from '../../test-utils.js'; | ||
import {networkRecordsToDevtoolsLog} from '../../network-records-to-devtools-log.js'; | ||
import {NetworkRecorder} from '../../../lib/network-recorder.js'; | ||
|
||
/** | ||
* @param {Partial<LH.Artifacts.NetworkRequest>=} partial | ||
* @return {LH.Artifacts.NetworkRequest} | ||
* @return {Partial<LH.Artifacts.NetworkRequest>} | ||
*/ | ||
function mockRequest(partial) { | ||
return Object.assign(new NetworkRequest(), { | ||
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. assigning to a new |
||
return { | ||
url: 'https://example.com', | ||
documentURL: 'https://example.com', | ||
finished: true, | ||
frameId: 'frameId', | ||
isSecure: true, | ||
isValid: true, | ||
parsedURL: {scheme: 'https'}, | ||
parsedURL: {scheme: 'https', host: 'example.com', securityOrigin: 'https://example.com'}, | ||
protocol: 'http/1.1', | ||
requestMethod: 'GET', | ||
resourceType: 'Document', | ||
...partial, | ||
}); | ||
}; | ||
} | ||
|
||
/** | ||
|
@@ -185,11 +185,12 @@ describe('_getArtifact', () => { | |
mockCSP(), | ||
mockDeprecation('AuthorizationCoveredByWildcard'), | ||
]; | ||
const networkRecords = [ | ||
const devtoolsLog = networkRecordsToDevtoolsLog([ | ||
mockRequest({requestId: '1'}), | ||
mockRequest({requestId: '2'}), | ||
mockRequest({requestId: '3'}), | ||
]; | ||
]); | ||
const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); | ||
|
||
const artifact = await gatherer._getArtifact(networkRecords); | ||
|
||
|
@@ -258,11 +259,12 @@ describe('_getArtifact', () => { | |
mockBlockedByResponse({request: {requestId: '5'}}), | ||
mockBlockedByResponse({request: {requestId: '6'}}), | ||
]; | ||
const networkRecords = [ | ||
const devtoolsLog = networkRecordsToDevtoolsLog([ | ||
mockRequest({requestId: '1'}), | ||
mockRequest({requestId: '3'}), | ||
mockRequest({requestId: '5'}), | ||
]; | ||
]); | ||
const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); | ||
|
||
const artifact = await gatherer._getArtifact(networkRecords); | ||
|
||
|
@@ -327,10 +329,10 @@ describe('FR compat (inspector-issues)', () => { | |
.mockEvent('Audits.issueAdded', { | ||
issue: mockMixedContent({request: {requestId: '1'}}), | ||
}); | ||
networkRecords = [ | ||
devtoolsLog = networkRecordsToDevtoolsLog([ | ||
mockRequest({requestId: '1'}), | ||
]; | ||
devtoolsLog = networkRecordsToDevtoolsLog(networkRecords); | ||
]); | ||
networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); | ||
}); | ||
|
||
it('uses loadData in legacy mode', async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,9 +112,9 @@ describe('NetworkRequest', () => { | |
function getRequest() { | ||
return { | ||
rendererStartTime: 0, | ||
startTime: 0, | ||
endTime: 2000, | ||
startTime: 50, | ||
responseReceivedTime: 1000, | ||
endTime: 2000, | ||
Comment on lines
-116
to
+117
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. test change from #14574 to verify this works for that |
||
|
||
// units = ms | ||
responseHeaders: [ | ||
|
@@ -135,11 +135,11 @@ describe('NetworkRequest', () => { | |
const record = NetworkRecorder.recordsFromLogs(devtoolsLog)[0]; | ||
|
||
expect(record.rendererStartTime).toStrictEqual(0); | ||
expect(record.startTime).toStrictEqual(0); | ||
expect(record.startTime).toStrictEqual(50); | ||
expect(record.endTime).toStrictEqual(2000); | ||
expect(record.responseReceivedTime).toStrictEqual(1000); | ||
expect(record.lrStatistics).toStrictEqual({ | ||
endTimeDeltaMs: -8000, | ||
endTimeDeltaMs: -8050, | ||
TCPMs: 5000, | ||
requestMs: 2500, | ||
responseMs: 2500, | ||
|
@@ -228,7 +228,7 @@ describe('NetworkRequest', () => { | |
const record = NetworkRecorder.recordsFromLogs(devtoolsLog)[0]; | ||
|
||
expect(record.lrStatistics).toStrictEqual({ | ||
endTimeDeltaMs: -8000, | ||
endTimeDeltaMs: -8050, | ||
TCPMs: 0, | ||
requestMs: 0, | ||
responseMs: 10000, | ||
|
@@ -246,7 +246,7 @@ describe('NetworkRequest', () => { | |
const record = NetworkRecorder.recordsFromLogs(devtoolsLog)[0]; | ||
|
||
expect(record.lrStatistics).toStrictEqual({ | ||
endTimeDeltaMs: -8000, | ||
endTimeDeltaMs: -8050, | ||
TCPMs: 1000, | ||
requestMs: 0, | ||
responseMs: 9000, | ||
|
@@ -270,7 +270,7 @@ describe('NetworkRequest', () => { | |
sslStart: 35, | ||
}); | ||
expect(lrRecord.lrStatistics).toStrictEqual({ | ||
endTimeDeltaMs: -8000, | ||
endTimeDeltaMs: -8050, | ||
TCPMs: 5000, | ||
requestMs: 2500, | ||
responseMs: 2500, | ||
|
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.
startTime
0 +receiveHeadersEnd
500 is well after anendTime
of 0.5 :)