-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: update create-test-trace utility #13942
Changes from all 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 |
---|---|---|
|
@@ -298,7 +298,7 @@ describe('Metrics: CLS', () => { | |
|
||
it('ignores layout shift data from other tabs', async () => { | ||
const trace = createTestTrace({timeOrigin: 0, traceEnd: 2000}); | ||
const mainFrame = trace.traceEvents[0].args.frame; | ||
const mainFrame = trace.traceEvents.find(e => e.name === 'navigationStart').args.frame; | ||
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 |
||
const childFrame = 'CHILDFRAME'; | ||
const otherMainFrame = 'ANOTHERTABOPEN'; | ||
const cat = 'loading,rail,devtools.timeline'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,16 @@ | |
|
||
const pid = 1111; | ||
const tid = 222; | ||
const browserPid = 13725; | ||
const rootFrame = '3EFC2700D7BC3F4734CAF2F726EFB78C'; | ||
const frameUrl = 'https://example.com/'; | ||
const defaultUrl = 'https://example.com/'; | ||
|
||
/** @typedef {{ts: number, duration: number, children?: Array<ChildTaskDef>}} TopLevelTaskDef */ | ||
/** @typedef {{ts: number, duration: number, url: string | undefined}} ChildTaskDef */ | ||
/** @typedef {{frame: string}} ChildFrame */ | ||
/** | ||
* @typedef TraceOptions | ||
* @property {string} [frameUrl] | ||
* @property {number} [timeOrigin] | ||
* @property {number} [largestContentfulPaint] | ||
* @property {number} [traceEnd] | ||
|
@@ -33,11 +35,8 @@ function getTopLevelTask({ts, duration}) { | |
pid, | ||
tid, | ||
ph: 'X', | ||
cat: 'disabled-by-default-lighthouse', | ||
args: { | ||
src_file: '../../third_party/blink/renderer/core/fake_runner.cc', | ||
src_func: 'FakeRunnerFinished', | ||
}, | ||
cat: 'disabled-by-default-devtools.timeline', | ||
args: {}, | ||
}; | ||
} | ||
|
||
|
@@ -52,12 +51,11 @@ function getChildTask({ts, duration, url}) { | |
pid, | ||
tid, | ||
ph: 'X', | ||
cat: 'disabled-by-default-lighthouse', | ||
cat: 'devtools.timeline', | ||
args: { | ||
src_file: '../../third_party/blink/renderer/core/fake_runner.cc', | ||
src_func: 'FakeRunnerFinished', | ||
data: { | ||
url, | ||
functionName: 'fakeFunction', | ||
}, | ||
}, | ||
}; | ||
|
@@ -70,34 +68,38 @@ function getChildTask({ts, duration, url}) { | |
* @param {TraceOptions} options | ||
*/ | ||
function createTestTrace(options) { | ||
const frameUrl = options.frameUrl ?? defaultUrl; | ||
const timeOrigin = (options.timeOrigin || 0) * 1000; | ||
|
||
const traceEvents = [{ | ||
name: 'navigationStart', | ||
ts: timeOrigin, | ||
pid, | ||
tid, | ||
ph: 'R', | ||
cat: 'blink.user_timing', | ||
args: { | ||
frame: rootFrame, | ||
data: {documentLoaderURL: 'https://example.com/'}, | ||
}, | ||
}, { | ||
name: 'TracingStartedInBrowser', | ||
ts: timeOrigin, | ||
pid, | ||
pid: browserPid, | ||
tid, | ||
ph: 'I', | ||
cat: 'disabled-by-default-devtools.timeline', | ||
args: { | ||
data: { | ||
frameTreeNodeId: 6, | ||
persistentIds: true, | ||
frames: [{frame: rootFrame, url: frameUrl, name: '', processId: pid}], | ||
frames: [{frame: rootFrame, url: 'about:blank', name: '', processId: pid}], | ||
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. now defintely a navigation trace. we could adjust that if needed at some point |
||
}, | ||
}, | ||
s: 't', | ||
}, { | ||
name: 'navigationStart', | ||
ts: timeOrigin, | ||
pid, | ||
tid, | ||
ph: 'R', | ||
cat: 'blink.user_timing', | ||
args: { | ||
frame: rootFrame, | ||
data: { | ||
documentLoaderURL: frameUrl, | ||
isLoadingMainFrame: true, | ||
}, | ||
}, | ||
}, { | ||
// Needed to identify main thread for TracingStartedInBrowser. | ||
name: 'thread_name', | ||
|
@@ -111,7 +113,7 @@ function createTestTrace(options) { | |
// Used for identifying frame tree. | ||
name: 'FrameCommittedInBrowser', | ||
ts: timeOrigin, | ||
pid, | ||
pid: browserPid, | ||
tid, | ||
ph: 'I', | ||
cat: 'disabled-by-default-devtools.timeline', | ||
|
@@ -149,7 +151,7 @@ function createTestTrace(options) { | |
traceEvents.push({ | ||
name: 'FrameCommittedInBrowser', | ||
ts: timeOrigin + 20, | ||
pid, | ||
pid: browserPid, | ||
tid, | ||
ph: 'I', | ||
cat: 'disabled-by-default-devtools.timeline', | ||
|
@@ -174,7 +176,7 @@ function createTestTrace(options) { | |
tid, | ||
ph: 'R', | ||
cat: 'loading,rail,devtools.timeline', | ||
args: {frame: rootFrame, data: {size: 50}}, | ||
args: {frame: rootFrame, isMainFrame: true, data: {size: 50}}, | ||
}); | ||
} | ||
|
||
|
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.
a few of these tests were accidentally relying on the fact that the redirects audit was only using navStart events for the redirect chain if they have a
isLoadingMainFrame
property, andcreate-test-trace
wasn't setting that property. The generated navStart event now has that property and these tests now set the navStartdocumentLoaderURL
properly