feat: record popup window interactions with correct statement ordering#308
feat: record popup window interactions with correct statement ordering#308cx-pedro-nascimento wants to merge 2 commits intozaproxy:mainfrom
Conversation
|
New Issues (2)Checkmarx found the following issues in this Pull Request
Use @Checkmarx to interact with Checkmarx PR Assistant. |
Detect popup windows via window.opener in the content script and register them with the background service worker (ZAP_REGISTER_POPUP). The background assigns a new windowHandle, emits ZestActionSleep(10000) **before** ZestClientWindowHandle so ZAP waits for the popup to load before trying to locate it. All recorder statements in popup windows use the assigned handle. Adds ZestStatementWindowHandle and ZestStatementActionSleep types, bumps version to 0.1.9, adds the tabs permission to the recorder manifest, and includes unit tests verifying the sleep-before-window-handle ordering. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: CxPedroNascimento <174706762+cx-pedro-nascimento@users.noreply.github.com>
001ad14 to
0ebbff8
Compare
|
Review from Claude: PR Review: feat: record popup window interactions with correct statement ordering Summary: This PR detects window.opener !== null in the content script to identify popups, registers them with the background worker (ZAP_REGISTER_POPUP), assigns Issues
source/utils/constants.ts exports ZAP_GET_WINDOW_HANDLE and source/Background/index.ts handles it, but nothing in the codebase ever sends this message. The
Background/index.ts:369-383:
new ZestStatementActionSleep(10000) is a magic number. Fast popups will block replay unnecessarily; slow popups (or those over a slow network) could still fail.
ContentScript/index.ts:358-360:
Background/index.ts:296:
The new tests validate ZestStatementWindowHandle/ZestStatementActionSleep serialization and that ZestScript.addStatement preserves order — but there are no tests Minor notes
Summary The core idea is sound and the ordering fix (sleep before windowHandle) is correct. The main actionable issues are: remove ZAP_GET_WINDOW_HANDLE dead code, guard |
|
Review from me 😁 |
- Remove dead ZAP_GET_WINDOW_HANDLE constant and its unreachable handler - Add IS_FULL_EXTENSION guard to tabs.onRemoved so recorder variant does not make ZAP API calls when a popup tab closes - Extract magic 10000 into POPUP_WINDOW_SLEEP_MS named constant - Replace type-unsafe double cast with typed RegisterPopupMessage interface - Remove non-null assertion; use explicit undefined check instead - Remove unreachable message.windowHandle branch in ZAP_START_RECORDING handler - Fix long lines in recorder.ts to satisfy prettier line-length rule - Fix prefer-destructuring lint error in content script unit test - Add unit tests for ZAP_REGISTER_POPUP handler covering: new tab assignment, same-tab caching, multi-tab handles, missing tab id, and invalid URL fallback
|
Hi Simon, thanks for the review! Pushed a fix addressing the feedback:
The one thing still outstanding is the integration test HTML page that launches a popup — I will work on that next. |


Detect popup windows via window.opener in the content script and register them with the background service worker (ZAP_REGISTER_POPUP). The background assigns a new windowHandle, emits ZestActionSleep(10000) before ZestClientWindowHandle so ZAP waits for the popup to load before trying to locate it. All recorder statements in popup windows use the assigned handle.
Adds ZestStatementWindowHandle and ZestStatementActionSleep types, bumps version to 0.1.9, adds the tabs permission to the recorder manifest, and includes unit tests verifying the sleep-before-window-handle ordering.