Repository navigation
perf(ego-browser): stop re-validating snapshot stable locators - #813
Merged
Merged
Conversation
page.snapshot() queried every advertised locator again over CDP and dropped the ones that did not resolve uniquely to their own node. The browser now prints a locator only when it matches exactly that node, so the check removed nothing and cost more than the native snapshot on pages with many locators (GitHub repo page, full page: 150 ms -> 24 ms). Locators are passed through as advertised. Backfilling a missing frameId for iframe refs still uses validateLocatorBackendNodes, and the loc=unstable / loc=ambiguous sentinels of earlier browsers are still omitted. With a browser that predates the native check, inaccurate locators are no longer filtered by the SDK. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n href A browser that verifies locators gives each of two links with the same href its own role-and-name locator. The case required those links to carry no locator at all, so it failed on such a browser with or without the SDK-side check. It now rejects only the shared href locator and resolves the other locator to confirm it matches one element. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
🤖 Codex Review ·
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
page.snapshot()queried every stable locator the browser advertised again over CDP, and removed the ones that did not resolve to exactly their own node. The browser now does this check itself and prints a locator only when it matches exactly the node that produced it, so the SDK check repeated work and removed nothing.This PR removes the SDK-side check. Locators are passed through as the browser advertises them.
Why
On pages with many locators the check cost more than the native snapshot. Measured on ego lite 0.6.4.20, median of 7 runs, with the check on and off in the same process:
Across these pages the check removed none of about 2,300 advertised locators.
What changed
preparePageSnapshotResultno longer validates locators.validateSnapshotLocator,sanitizeSnapshotLocatorsand their two text-rewriting helpers are removed.frameIdfor refs inside iframes, which still usesvalidateLocatorBackendNodes, and omitting theloc=unstable/loc=ambiguoussentinels that earlier browsers print.validateLocatorBackendNodesdirectly.Page snapshot locator qualitycase required two links sharing an href to carry no locator at all. The current browser gives each of them a uniquerole:link[name="…"]locator, so the case failed with or without this change. It now rejects only the sharedhref:locator and resolves the other locator to confirm it matches one element.docs/native-snapshot-ref-requirement.mdno longer says the JS runtime validates locators.Reviewer notes
includeStableLocator: false. That time is spent in the browser and is unchanged by this PR.Tests
npm test: 712 pass.npm run e2e(pre-push hook): passes on ego lite 0.6.4.20.🤖 Generated with Claude Code