feat: recorder open modes (new tab/window/incognito) + close-on-stop#88
Open
su-usman wants to merge 2 commits into
Open
feat: recorder open modes (new tab/window/incognito) + close-on-stop#88su-usman wants to merge 2 commits into
su-usman wants to merge 2 commits into
Conversation
Config-driven "open recording in" modes for the network recorder, all fields optional/additive on the startNetworkRecording config: - openMode: "tab" (existing default) | "window" | "incognito"; window/incognito open via chrome.windows.create, preserving the about:blank -> register -> navigate sequence and the synchronous sidePanel.open user gesture. - closeOnStop: on a user stop, close the recording tab (tab mode) or window (window/incognito), then refocus the originating LTS context (focus applied AFTER the removal so it wins Chrome's post-close focus shuffle). - Incognito gating via chrome.extension.isAllowedIncognitoAccess (seeded at init and re-seeded on each getExtensionMetadata); start rejects with a typed code (INCOGNITO_NOT_ALLOWED / INCOGNITO_DISABLED_BY_POLICY) rather than silently downgrading to a normal window. - getExtensionMetadata exposes incognitoAllowed + a supportsOpenModes capability flag; startNetworkRecording echoes the resolved openedMode. - Manifests: explicit "incognito": "spanning" (chrome/edge/firefox). - Robustness: defensive frameId guard on the SDK body-capture path (keeps requestScope "top-level" honest); re-assert body-recorder registration on windows.onCreated (works around Chromium 1393762 incognito injection loss).
|
|
nafees87n
reviewed
Jul 23, 2026
nafees87n
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Just one minor caveat
Comment on lines
+60
to
+63
| // Capability flag: this build honours config.openMode (tab/window/incognito). LTS | ||
| // gates New window / New incognito on this instead of a version check, so an older | ||
| // build that omits it stays on "New tab" (no silent downgrade). | ||
| supportsOpenModes: true, |
Contributor
There was a problem hiding this comment.
Why do we need to hardcode the compatibility flag here? Can't the consumer check this based on version
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.
Closes issue: n/a (BrowserStack LTS-4294 — internal)
📜 Summary of changes:
Adds config-driven "Open recording in" modes to the network recorder, driven by Load Testing (LTS) via the
startNetworkRecordingconfig. All fields are optional/additive, so existing callers are unaffected.openMode:"tab"(existing default) |"window"|"incognito". Window/incognito open viachrome.windows.create, preserving theabout:blank → register body-recorder → navigatesequence and the synchronoussidePanel.open()user gesture.closeOnStop: on a user-initiated stop, close the recording tab (tab mode) or window (window/incognito), then refocus the originating LTS context. Focus is applied after the removal resolves so it wins Chrome's post-close focus shuffle (matters when multiple profiles are open).chrome.extension.isAllowedIncognitoAccess()(seeded at SW init, re-seeded on everygetExtensionMetadata) is surfaced asincognitoAllowed. Start rejects with a typedcode(INCOGNITO_NOT_ALLOWED/INCOGNITO_DISABLED_BY_POLICY) instead of silently downgrading to a normal window.getExtensionMetadatanow returnsincognitoAllowed+ asupportsOpenModescapability flag (consumers gate on capability, not a version check);startNetworkRecordingechoes the resolvedopenedMode."incognito": "spanning"(chrome/edge/firefox) — neversplit(which would fork the SW and break the external port).frameIdguard on the SDK body-capture path (keepsrequestScope: "top-level"honest ifallFramesis ever added); re-assert body-recorder registration onwindows.onCreated(works around Chromium 1393762, where dynamically-registered content scripts stop injecting into incognito after an extension toggle).🎥 Demo Video:
Recorded booking.com in a New incognito window — the side panel opens inside the incognito window, capture streams to LTS (235 requests / 57 XHR), and LTS auto-correlation extracts tokens from the captured response bodies. (Screenshots / Loom to attach.)
✅ Checklist:
mv3/test/network-recording-test.html+ Playwright e2e.🧪 Test instructions:
config.openMode=windoworincognito(incognito requires "Allow in Incognito" enabled for the extension atchrome://extensions).INCOGNITO_NOT_ALLOWED(no silent downgrade to a normal window).🔗 Other references:
BrowserStack LTS-4294. Contract mirrored in the LTS-side handoff doc (
RECORDER_OPEN_MODES_AND_SCOPE_HANDOFF.md).