-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOMStats] Add DOM stats to sidebar insight
This does not include element links yet. https://screenshot.googleplex.com/JqnQRp97zxj8XGD Bug: 372897811 Change-Id: I5a2a5d47bbfa8d32e3b05e9064243d245227ca53 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6172395 Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Adam Raine <[email protected]>
- Loading branch information
Adam Raine
authored and
Devtools-frontend LUCI CQ
committed
Jan 16, 2025
1 parent
6b80ee8
commit 9611624
Showing
13 changed files
with
178 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2025 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import {describeWithEnvironment} from '../../../testing/EnvironmentHelpers.js'; | ||
import {TraceLoader} from '../../../testing/TraceLoader.js'; | ||
import * as Trace from '../trace.js'; | ||
|
||
describeWithEnvironment('DOMStatsHandler', () => { | ||
beforeEach(() => { | ||
Trace.Handlers.ModelHandlers.DOMStats.reset(); | ||
Trace.Handlers.ModelHandlers.Meta.reset(); | ||
}); | ||
|
||
it('should get DOM stats for each frame', async function() { | ||
const {parsedTrace} = await TraceLoader.traceEngine(this, 'multi-frame-dom-stats.json.gz'); | ||
|
||
const {mainFrameId} = parsedTrace.Meta; | ||
const {domStatsByFrameId} = parsedTrace.DOMStats; | ||
|
||
assert.strictEqual(domStatsByFrameId.size, 2); | ||
const mainFrameStats = domStatsByFrameId.get(mainFrameId)!.at(-1); | ||
const mainFrameData = mainFrameStats!.args.data; | ||
assert.strictEqual(mainFrameData.totalElements, 7); | ||
assert.strictEqual(mainFrameData.maxDepth!.depth, 3); | ||
assert.strictEqual(mainFrameData.maxDepth!.nodeName, 'DIV id=\'child\''); | ||
assert.strictEqual(mainFrameData.maxChildren!.numChildren, 4); | ||
assert.strictEqual(mainFrameData.maxChildren!.nodeName, 'BODY'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2025 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import * as Platform from '../../../core/platform/platform.js'; | ||
import * as Types from '../types/types.js'; | ||
|
||
export interface DOMStatsData { | ||
domStatsByFrameId: Map<string, Types.Events.DOMStats[]>; | ||
} | ||
|
||
const domStatsByFrameId: DOMStatsData['domStatsByFrameId'] = new Map(); | ||
|
||
export function reset(): void { | ||
domStatsByFrameId.clear(); | ||
} | ||
|
||
export function handleEvent(event: Types.Events.Event): void { | ||
if (!Types.Events.isDOMStats(event)) { | ||
return; | ||
} | ||
const domStatEvents = Platform.MapUtilities.getWithDefault(domStatsByFrameId, event.args.data.frame, () => []); | ||
domStatEvents.push(event); | ||
} | ||
|
||
export async function finalize(): Promise<void> { | ||
} | ||
|
||
export function data(): DOMStatsData { | ||
return {domStatsByFrameId}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+746 KB
front_end/panels/timeline/fixtures/traces/multi-frame-dom-stats.json.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters