Skip to content

Only analyze HTML belonging to the tested page#116

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

Only analyze HTML belonging to the tested page#116
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, Webperf-se/plugin-pagenotfound#156, Webperf-se/plugin-css#159, Webperf-se/plugin-html#130, Webperf-se/plugin-javascript#130 and Webperf-se/plugin-standard-files#16.

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 took the first HTML response in the whole HAR as the page to search for an accessibility statement — with a crossed-in recording where the foreign page is recorded first, it would search and rate another website's page.

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 and the existing no-network issue is reported instead of another website's data.

The statement-hunting flow (following candidate links, each as its own browsertime.har message) is unaffected since the check runs per message url. HARs without a pages array and entries without pageref behave exactly as before.

Validation

Synthetic crossed HARs, both directions: foreign-page-first yields the no-network path instead of analyzing the wrong page; own-page-first analyzes only the tested page; 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 took the first HTML response in the whole HAR as the
page to search for an accessibility statement, so a crossed-in
recording could make it search (and rate) another website's page.

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 and the
existing no-network issue is reported. HARs without a pages array and
entries without pageref behave as before.
@marcusosterberg
marcusosterberg merged commit bb5a9d0 into main Jul 15, 2026
1 check passed
@marcusosterberg
marcusosterberg deleted the fix/filter-har-to-first-page branch July 15, 2026 17:23
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