Repository navigation
Conversation
Two independent per-device preview toggles, exposed both in the toolbar and over MCP: - set_javascript_enabled / Disable JS: fully disables the JS engine for that device's guest via the CDP debugger (Emulation.setScriptExecutionDisabled). Nothing on the page runs, including inline scripts. - set_network_scripts_blocked / Block JS Network: cancels script network requests (webRequest.onBeforeRequest, resourceType script) for that device's guest while leaving the JS engine on. Inline and already-loaded scripts keep running; only new network-fetched <script src> requests are blocked. Distinct failure mode from the JS-disable toggle: closer to an ad-blocker, corporate firewall, or a dead CDN than a no-JS browser. Both toggles reload the affected preview so the change takes visible effect, and persist across further reloads/navigation until changed again or the device leaves the active preview. Also fixes a pre-existing bug in the MCP bridge's device lookup: McpBridge/commands.ts resolved a device's <webview> by document.getElementById(device.name), which is fragile once names contain spaces or slashes. Both new toggles need a reliable id-based lookup, so this adds a small webviewRegistry (registered on mount, unregistered on unmount) and switches the existing navigate/ getCaptureTargets lookups over to it as well. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
aks240295
force-pushed
the
feature/js-disable-and-network-block-toggle
branch
from
September 24, 2026 07:00
5299808 to
3201424
Compare
The lists-the-available-tools test in both mcp-server.spec.ts and mcp-bridge-stdio.spec.ts hardcodes the full tool list, so it broke once set_javascript_enabled and set_network_scripts_blocked were registered. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The event-mirroring transport (BrowserSync) is injected into every preview as a network-fetched script, indistinguishable from a page's own scripts by resourceType alone. Blocking it silently dropped a device out of scroll/click mirroring with the rest of the previews whenever network-script-blocking was armed, instead of just blocking the site's own scripts as intended. Verified by temporarily logging every cancel/exempt decision: the browser-sync-client.js request switched from cancelled to exempted after this fix, while the site's own scripts stayed correctly blocked. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Found while live-testing the arm-a-toggle-then-navigate-then-read workflow these toggles exist for, against a real site across all 8 device/condition screens. - set_network_scripts_blocked's forced reload (reloadIgnoringCache(), needed to bypass the HTTP cache so the network filter can actually see the request) resolved before the reload had started or committed. A caller's very next action — a navigate() call, most realistically — could race that in-flight reload on the same webContents: two competing navigations, and whichever happened to commit last (not necessarily the one requested last) won. Now waits for the reload to genuinely settle (did-stop-loading/did-fail-load) before resolving, so a device is reliably idle again by the time the promise returns. - navigate() only waited for the primary device to finish loading before returning. A slower non-primary device could still be showing the previous page when a caller read every device right after navigate() returned — exactly what happens when a script arms a toggle on one device, navigates, then reads all of them. Now waits for every active device to settle, plus a short buffer for async-mounted content, before returning. Verified live against a real 8-screen device setup (JS-enabled, JS-disabled, network-blocked, and Googlebot-UA, each on mobile and desktop): 0 mismatches across repeated rapid navigations with both toggles explicitly armed, versus reproducible device desyncs before the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
Two independent per-device preview toggles, exposed both in the toolbar and over MCP:
set_javascript_enabled): fully disables the JS engine for that device's guest via the CDP debugger (Emulation.setScriptExecutionDisabled). Nothing on the page runs, including inline scripts.set_network_scripts_blocked): cancels script network requests (webRequest.onBeforeRequest,resourceType: "script") for that device's guest while leaving the JS engine on. Inline and already-loaded scripts keep running; only new network-fetched<script src>requests are blocked. This is a distinct failure mode from the JS-disable toggle -- closer to an ad-blocker, corporate firewall, or a dead CDN than a no-JS browser.Both toggles reload the affected preview so the change takes visible effect, and persist across further reloads/navigation until changed again or the device leaves the active preview.
Also fixes a pre-existing bug in the MCP bridge's device lookup:
McpBridge/commands.tsresolved a device's<webview>bydocument.getElementById(device.name), which is fragile once names contain spaces or slashes. Both new toggles need a reliable id-based lookup, so this adds a smallwebviewRegistry(registered on mount, unregistered on unmount) and switches the existingnavigate/getCaptureTargetslookups over to it as well.Test plan
set_javascript_enabled/set_network_scripts_blockedwork via MCP (list_devices, then the two new tools)