Skip to content

fix: avoid stale injected script installs after navigation#41788

Open
coopjyoung wants to merge 1 commit into
microsoft:mainfrom
coopjyoung:fix-extend-injected-script-navigation
Open

fix: avoid stale injected script installs after navigation#41788
coopjyoung wants to merge 1 commit into
microsoft:mainfrom
coopjyoung:fix-extend-injected-script-navigation

Conversation

@coopjyoung

@coopjyoung coopjyoung commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #41773

Problem

Frame.extendInjectedScript() could continue after a navigation if the main world context promise was still pending.

A stale injection request from the previous document could resolve using the new document's context, causing duplicate injected scripts.

Solution

Capture the current document before awaiting the main world context. If the frame navigated while waiting, the stale operation exits without injecting.

Testing

Added a regression test that deterministically reproduces the navigation race.

Verified:

  • regression test fails before the fix
  • regression test passes after the fix
  • existing selector-generator tests continue passing

@coopjyoung

Copy link
Copy Markdown
Author

@coopjyoung please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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.

[Bug]: Codegen can install duplicate recorders after a frame navigates

1 participant