Conversation
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.
Fixes #3193
The recorder's content script sends its screenshot request from the tab that produced an event, but
chrome.tabs.captureVisibleTab(windowId)captures whichever tab is active in that window. Because the recorder takes an after-action screenshot after a short event delay, switching tabs at that point could attach a different page's image to the event. A check immediately before capture alone would not cover a switch away and back while the capture is pending.I moved the capture decision into
captureTabScreenshot. It uses the tab ID supplied by the message sender to check the active tab in that window before callingcaptureVisibleTab. It then checks again before returning the image. AnonActivatedlistener spans that entire interval and marks the capture invalid if another tab becomes active in the same window, including the A→B→A case where both active-tab queries would otherwise see A. The listener is removed infinally, so it does not remain registered after a completed or rejected capture.The worker now sends
nullwhen the source tab is inactive or changes during capture. The recorder's existing empty-screenshot handling can then proceed without attaching another tab's image. Capture errors still returnnullthrough the worker's error path.The regression tests exercise four cases: a source tab that stays active, one that is already inactive, a switch to another tab during capture, and a switch away and back before capture completes. The latter specifically guards the gap left by checking only before and after the API call.
Validation completed:
pnpm run lintpnpm exec nx build chrome-extensionpnpm exec nx test chrome-extension— 58 tests passedpnpm exec tsc -p apps/chrome-extension/tsconfig.json --noEmit --pretty falseRecorded events now retain screenshots only when the image can be attributed to the tab that produced the event.