fix: align _iframe_shim with the canonical @percy/sdk-utils iframe helpers#734
Merged
Merged
Conversation
…lpers percy/cli#2319 made @percy/sdk-utils the single source of truth for the iframe helpers (resolveMaxFrameDepth, resolveIgnoreSelectors, normalizeIgnoreSelectors, isUnsupportedIframeSrc). Our shim already prefers those exports when the linked sdk-utils provides them, but the local fallbacks (and their tests) encoded a different contract, so the SDK regression run — which links sdk-utils from percy/cli master — failed: - resolveMaxFrameDepth: canonical reads `options.maxIframeDepth` (the public SnapshotOptions key) and treats invalid/<1 values as the default; the local copy read a made-up `maxFrameDepth` key and clamped negatives to 0. - normalizeIgnoreSelectors: canonical takes a raw value; the local copy aliased resolveIgnoreSelectors and took an options object. - The local fallbacks became dead code when the canonical exports were present, collapsing coverage below the 100% thresholds. Rewrite the fallbacks to be contract-identical to canonical (including the `percy.config.snapshot` fallback and the ws:/wss:/ftp: unsupported schemes), reusing the already-published `clampIframeDepth` for the shared clamping semantics. Expose the fallbacks as `_localFallbacks` and run the same contract test suite against both the public exports and the fallbacks, so behavior and 100% coverage hold whether the linked @percy/sdk-utils is the published 1.31.14 or percy/cli master. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
aryanku-dev
approved these changes
Jul 3, 2026
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.
Root cause
The PER-9772 SDK regression dispatches this repo's
test.ymlwith all@percy/*packages linked from a percy/cli master build. percy/cli#2319 made@percy/sdk-utilsthe single source of truth for the iframe helpers, so in that mode the shim'sutils.X || localXdelegation started picking the canonical implementations — whose contract differs from what the local fallbacks (and their tests) encoded:resolveMaxFrameDepth— canonical readsoptions.maxIframeDepth(the publicSnapshotOptionskey) and treats invalid/< 1values as the default (3); the local copy read a locally-inventedmaxFrameDepthkey and clamped negatives to 0. HenceExpected 3 to be 10(themaxFrameDepthkey was ignored → default) andExpected 3 to be 0(canonical returns the default for negatives).normalizeIgnoreSelectors— canonical takes a raw value (array | string | unset); the local copy aliasedresolveIgnoreSelectorsand took an options object. HenceExpected $.length = 0 to equal 1fornormalizeIgnoreSelectors({ ignoreIframeSelectors: ['.x'] })._iframe_shim.jsto ~13% and failing the 100% thresholds.Normal
pull_requestCI kept passing because the lockfile's published@percy/sdk-utils@1.31.14doesn't export these helpers yet, so the local fallbacks were always used.Failing run: https://github.com/percy/percy-protractor/actions/runs/28640552076
Fix
_iframe_shim.jsto be contract-identical to the canonical sdk-utils helpers:maxIframeDepthkey,percy.config.snapshot.*fallback, invalid/< 1→ default, floor + hard cap via the already-publishedclampIframeDepth, value-basednormalizeIgnoreSelectors, and thews:/wss:/ftp:additions to the unsupported-scheme list._localFallbacksfor tests.test/iframe-helpers.test.jsto assert the canonical contract, and to run the same contract suite against both the public exports and the local fallbacks — so the fallbacks can never silently drift from canonical behavior, and 100% coverage of the shim holds no matter which arm is active.Verification
Ran the
_iframe_shim/iframe-helpers suite (jasmine + nyc) in both dependency modes:@percy/sdk-utils@1.31.14(lockfile)@percy/sdk-utilslinked from percy/cli master (yarn build+yarn link)yarn lintpasses.index.jsis untouched, so its coverage profile in the full protractor run is unchanged.🤖 Generated with Claude Code