Skip to content

feat: add opt-in allowMultiPage so new root documents start new HAR pages - #174

Open
sanketpatel32 wants to merge 1 commit into
sitespeedio:mainfrom
sanketpatel32:devin/1795802072-issue-65-multipage-har
Open

sanketpatel32 wants to merge 1 commit into
sitespeedio:mainfrom
sanketpatel32:devin/1795802072-issue-65-multipage-har

Conversation

@sanketpatel32

Copy link
Copy Markdown

Closes #65.

Adds an opt-in allowMultiPage option to harFromMessages. When enabled, each new main-document load in the root frame starts a new HAR page, matching how Chrome DevTools exports a multi-page HAR.

How it works

  • Pages track the loaderId of the document that produced them. Each document navigation gets a new loaderId, so a Network.requestWillBeSent for a Document with an unseen loader starts a new page.
  • Non-document requests are routed to the page of the loader that issued them, so late resources of the previous document (e.g. an image finishing after the redirect) stay attached to their own page instead of leaking into the new one.
  • A page pre-created by a Page.* navigation event gets bound to its real loader when the document request arrives.
  • Network.responseReceived now resolves the page via the entry's pageref rather than the frame, so a response lands on the page its request belongs to.
  • Default behavior is unchanged (allowMultiPage: false): one page per measurement, which is what Browsertime expects.

Tests

npm test — 44 passed, including a new multi-page-navigation.json perflog fixture covering:

  • a script-triggered redirect to a second document produces two pages,
  • late resources of the first document keep pageref of page 1,
  • the default (option off) still yields a single page.

Authored by Devin (Cognition AI) + Claude Opus.

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.

Redirects in main document are not detected as new page (explicit redirect or navigation)

1 participant