Skip to content
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

Using activationStart if available #73

Merged
merged 12 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
env:
browser: true
rules:
'@typescript-eslint/ban-ts-comment': 'off'
8 changes: 8 additions & 0 deletions src/visuallyCompleteCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ class VisuallyCompleteCalculator {
this.activeMeasurementIndex = navigationIndex;
Logger.info('VisuallyCompleteCalculator.start()', '::', 'index =', navigationIndex);

const activationStart: number =
// @ts-ignore
(performance?.getEntriesByType?.('navigation')[0]?.activationStart as number) || 0;

if (activationStart > 0) {
start = activationStart;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably check if activationStart > start. The reason being, if someone does an SPA navigation on a page that was prerendered, start should still be the manually supplied value, correct?

I think it would be nice if we can add one or two puppeteer test cases for this. We can pair on that sometime if you like.


// setup
const cancel = () => {
if (this.activeMeasurementIndex === navigationIndex) {
Expand Down