hardening: namespace snapshot cache keys to avoid sentinel collisions
Use 'page' and 'locator:' prefixed keys instead of raw '__page__' sentinel, preventing theoretical collision if a CSS selector equals '__page__'.
This commit is contained in:
@@ -26,9 +26,9 @@ function isRegExp(value: any): value is RegExp {
|
||||
|
||||
function getSnapshotKey(locator: Locator | Page): string {
|
||||
if (isPage(locator)) {
|
||||
return '__page__'
|
||||
return 'page'
|
||||
}
|
||||
return locator.selector()
|
||||
return `locator:${locator.selector()}`
|
||||
}
|
||||
|
||||
export async function getCleanHTML(options: GetCleanHTMLOptions): Promise<string> {
|
||||
|
||||
@@ -790,7 +790,7 @@ export class PlaywrightExecutor {
|
||||
const shouldCacheSnapshot = !frame
|
||||
// Cache keyed by locator selector so full-page and locator-scoped snapshots
|
||||
// don't pollute each other's diff baselines
|
||||
const snapshotKey = locator ? locator.selector() : '__page__'
|
||||
const snapshotKey = locator ? `locator:${locator.selector()}` : 'page'
|
||||
let pageSnapshots = this.lastSnapshots.get(resolvedPage)
|
||||
if (!pageSnapshots) {
|
||||
pageSnapshots = new Map()
|
||||
|
||||
Reference in New Issue
Block a user