Skip to content

Commit 9b36dc2

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Mark LCP/INP breakdown insights failing based on score
That way these are given the appropriate scores in Lighthouse. CLS Culprits was already doing this. Bug: 445864761 Change-Id: I47e4ac2518955d565d201be8756c9ac4d1c2e798 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7004564 Commit-Queue: Connor Clark <[email protected]> Auto-Submit: Connor Clark <[email protected]> Reviewed-by: Jack Franklin <[email protected]>
1 parent a565499 commit 9b36dc2

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

front_end/models/trace/insights/INPBreakdown.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import * as i18n from '../../../core/i18n/i18n.js';
6-
import type * as Handlers from '../handlers/handlers.js';
6+
import * as Handlers from '../handlers/handlers.js';
77
import * as Helpers from '../helpers/helpers.js';
88
import type {SyntheticInteractionPair} from '../types/TraceEvents.js';
99
import type * as Types from '../types/types.js';
@@ -67,13 +67,24 @@ export function isINPBreakdownInsight(insight: InsightModel): insight is INPBrea
6767
}
6868

6969
function finalize(partialModel: PartialInsightModel<INPBreakdownInsightModel>): INPBreakdownInsightModel {
70+
let state: INPBreakdownInsightModel['state'] = 'pass';
71+
if (partialModel.longestInteractionEvent) {
72+
const classification = Handlers.ModelHandlers.UserInteractions.scoreClassificationForInteractionToNextPaint(
73+
partialModel.longestInteractionEvent.dur);
74+
if (classification === Handlers.ModelHandlers.PageLoadMetrics.ScoreClassification.GOOD) {
75+
state = 'informative';
76+
} else {
77+
state = 'fail';
78+
}
79+
}
80+
7081
return {
7182
insightKey: InsightKeys.INP_BREAKDOWN,
7283
strings: UIStrings,
7384
title: i18nString(UIStrings.title),
7485
description: i18nString(UIStrings.description),
7586
category: InsightCategory.INP,
76-
state: partialModel.longestInteractionEvent ? 'informative' : 'pass',
87+
state,
7788
...partialModel,
7889
};
7990
}

front_end/models/trace/insights/LCPBreakdown.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,25 @@ function finalize(partialModel: PartialInsightModel<LCPBreakdownInsightModel>):
180180
if (partialModel.lcpRequest) {
181181
relatedEvents.push(partialModel.lcpRequest);
182182
}
183+
184+
let state: LCPBreakdownInsightModel['state'] = 'pass';
185+
if (partialModel.lcpMs !== undefined) {
186+
const classification = Handlers.ModelHandlers.PageLoadMetrics.scoreClassificationForLargestContentfulPaint(
187+
Helpers.Timing.milliToMicro(partialModel.lcpMs));
188+
if (classification === Handlers.ModelHandlers.PageLoadMetrics.ScoreClassification.GOOD) {
189+
state = 'informative';
190+
} else {
191+
state = 'fail';
192+
}
193+
}
194+
183195
return {
184196
insightKey: InsightKeys.LCP_BREAKDOWN,
185197
strings: UIStrings,
186198
title: i18nString(UIStrings.title),
187199
description: i18nString(UIStrings.description),
188200
category: InsightCategory.LCP,
189-
state: partialModel.lcpEvent || partialModel.lcpRequest ? 'informative' : 'pass',
201+
state,
190202
...partialModel,
191203
relatedEvents,
192204
};

0 commit comments

Comments
 (0)