Skip to content

Commit

Permalink
core(work-during-interaction): add INP savings (#15176)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Jun 15, 2023
1 parent 373c9c6 commit 0a32e6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/audits/work-during-interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,23 @@ class WorkDuringInteraction extends Audit {
const {settings} = context;
// TODO: responsiveness isn't yet supported by lantern.
if (settings.throttlingMethod === 'simulate') {
return {score: null, notApplicable: true};
return {
score: null,
notApplicable: true,
metricSavings: {INP: 0},
};
}

const trace = artifacts.traces[WorkDuringInteraction.DEFAULT_PASS];
const metricData = {trace, settings};
const interactionEvent = await Responsiveness.request(metricData, context);
// If no interaction, diagnostic audit is n/a.
if (interactionEvent === null) {
return {score: null, notApplicable: true};
return {
score: null,
notApplicable: true,
metricSavings: {INP: 0},
};
}
// TODO: remove workaround once 103.0.5052.0 is sufficiently released.
if (interactionEvent.name === 'FallbackTiming') {
Expand Down Expand Up @@ -271,6 +279,9 @@ class WorkDuringInteraction extends Audit {
type: 'list',
items: auditDetailsItems,
},
metricSavings: {
INP: duration,
},
};
}
}
Expand Down
5 changes: 5 additions & 0 deletions core/test/audits/work-during-interaction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ Object {
"timeInMs": 368,
},
},
"metricSavings": Object {
"INP": 368,
},
"score": 0,
}
`);
Expand All @@ -280,6 +283,7 @@ Object {
expect(result).toMatchObject({
score: null,
notApplicable: true,
metricSavings: {INP: 0},
});
});

Expand All @@ -290,6 +294,7 @@ Object {
expect(result).toMatchObject({
score: null,
notApplicable: true,
metricSavings: {INP: 0},
});
});
});

0 comments on commit 0a32e6c

Please sign in to comment.