Skip to content

fix(selectivity): script id matching on page change#1290

Open
KuznetsovRoman wants to merge 1 commit into
masterfrom
TESTPLANE-1061
Open

fix(selectivity): script id matching on page change#1290
KuznetsovRoman wants to merge 1 commit into
masterfrom
TESTPLANE-1061

Conversation

@KuznetsovRoman

@KuznetsovRoman KuznetsovRoman commented Jul 10, 2026

Copy link
Copy Markdown
Member

Fixes JS selectivity dependency collection when CDP reuses scriptId values across page navigations.

  • Capture and resolve coverage while the corresponding scripts are still available.
  • Pause coverage collection at beforeunload, new-document start, and BFCache restore boundaries.
  • Reset precise coverage and script mappings between pages.
  • Detect scriptId reuse using script content hashes.
  • Accumulate resolved dependencies across all pages visited by a test.

@KuznetsovRoman

Copy link
Copy Markdown
Member Author

@codex review

@github-actions

Copy link
Copy Markdown

✅ Testplane E2E run succeed

Report

@pkg-pr-new

pkg-pr-new Bot commented Jul 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1290

commit: 17c04a7

@github-actions

Copy link
Copy Markdown

✅ Testplane browser-env run succeed

Report

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17c04a78af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* Must run while the "scriptId -> source" maps still describe the scripts the coverage was taken from
* (i.e. before the page is navigated away and the maps are cleared).
*/
private async _resolveCoverageToDeps(coverageScripts: CDPScriptCoverage[]): Promise<void> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Pulled from L286 - L352


this._ensureScriptsAreLoading(coverageLastPart.result);

const totalDependingSourceFiles = new Set<string>();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved to _resolveCoverageToDeps method

const testplaneCoverageBreakScriptName = "__testplane_cdp_coverage_snapshot_pause";
const scriptToEvaluateOnNewDocument = `window.addEventListener("beforeunload", function ${testplaneCoverageBreakScriptName}() {debugger;});`;
const scriptToEvaluateOnNewDocument = [
"if (window.top === window) {",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

iframe guard

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