Skip to content

Only lint styles belonging to the tested page#159

Merged
marcusosterberg merged 1 commit into
mainfrom
fix/filter-har-to-first-page
Jul 15, 2026
Merged

Only lint styles belonging to the tested page#159
marcusosterberg merged 1 commit into
mainfrom
fix/filter-har-to-first-page

Conversation

@marcusosterberg

Copy link
Copy Markdown
Contributor

Part of a sweep across the HAR-consuming plugins; same problem class as Webperf-se/webperf_core#1557 / #1558 and Webperf-se/plugin-pagenotfound#156.

Problem

Concurrent browsertime runs on one host can race for the same Chrome DevTools port; the crossed CDP session records the other run's page navigation into this run's HAR, so the HAR can contain more than one page.

transform2SimplifiedData linted every HTML and CSS response body in the whole HAR — and missingCssUrls would even refetch another website's stylesheets — so a crossed-in recording attributes the other site's CSS issues (and score impact) to the tested website.

Fix

New getFirstPageEntries(url, harData):

  1. keeps only entries whose pageref belongs to the first page in the HAR's pages array;
  2. verifies the first recorded request's hostname matches the tested URL's hostname (new URL(...) punycodes IDN hostnames on both sides) — on mismatch nothing is analyzed.

Cross-domain stylesheets loaded by the tested page are still linted (pageref groups by initiating page, not by domain). HARs without a pages array and entries without pageref behave exactly as before.

Validation

Synthetic crossed HAR: only the tested page's HTML/CSS are collected, foreign stylesheets excluded; origin mismatch yields an empty analysis; legacy HAR without pages unchanged; eslint clean.

A browsertime HAR can contain more than one page, for example when a
concurrent browsertime run on the same host races for the same Chrome
DevTools port and its crossed CDP session records another website's
page load into this run's recording (see
Webperf-se/webperf_core#1557).

This analyzer linted every HTML and CSS response body in the whole HAR
(and refetched missing CSS files from any domain in it), so a
crossed-in recording could attribute another website's CSS issues to
the tested website.

Filter entries to the ones belonging to the first page in the HAR's
pages array, and verify that the recording's first request matches the
tested URL's hostname (the URL API normalizes IDN hostnames to
punycode on both sides). On mismatch nothing is analyzed. HARs without
a pages array and entries without pageref behave as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant