test: distinguish captured trim from live String.prototype.trim - #20
Conversation
Poison String.prototype.trim to an empty string so a live value.trim() lookup fails the seed hostname check instead of still parsing the original padded URL. Co-authored-by: Tomasz Janusz <TomaszJanusz@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe test now models ChangesSame-origin seed validation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This test-only change makes the iframe navigation-seed test reliably distinguish captured native trimming from a poisoned live trim method without changing production behavior. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. Full details: Description checkExplanation The description includes the required Summary, Validation, and Changelog sections. It explains the test change, records the focused test result, and marks the change as internal with no changelog entry required. The full validation checklist remains unchecked, but this is not critical because the focused test result is documented. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The iframe navigation-seed test poisoned
String.prototype.trimwith a non-empty tracker URL, so both a captured trim and a livevalue.trim()still parsed the original padded/framepath.This follow-up makes the stub return
"". A live lookup now fails the empty-string check, while the captured native trim still yieldsexample.test.Follow-up to #19 / CodeRabbit on the trim assertion.
Validation
pnpm task lintpnpm task checkpnpm task test:unitpnpm task build:chrome,pnpm task build:firefox)packages/refract-corechanged(
pnpm task generate:worker-source)Focused:
pnpm exec vitest run --config config/vitest.config.app.neutral.ts src/injection/main/iframe-navigation-seed.test.ts(4 passed).Changelog
CHANGELOG.mdin## [Unreleased]for user-facing changes.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Distinguish captured
String.prototype.trimfrom live method in iframe navigation seed testUpdates the test in iframe-navigation-seed.test.ts so the monkey-patched
String.prototype.trimreturns an empty string instead of a cross-origin URL. This verifies the function under test uses the captured trim snapshot rather than the live prototype method. The assertion still expects"example.test".Macroscope summarized 10e9412.
Summary by CodeRabbit