Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Route webdriver-probe fallback through chrome.scripting.executeScript#132

Merged
twschiller merged 2 commits into
mainfrom
fix/webdriver-probe-csp-executeScript
Jun 4, 2026
Merged

Route webdriver-probe fallback through chrome.scripting.executeScript#132
twschiller merged 2 commits into
mainfrom
fix/webdriver-probe-csp-executeScript

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • The inline-<script> fallback in webdriver-probe-annotate's apply() was blocked on strict script-src origins, so the active tab got no probe until the next navigation. The fallback now sends an inject-webdriver-probe message to the background worker, which runs installProbe via chrome.scripting.executeScript with world: "MAIN" — same primitive as the primary registerContentScripts path, just on-demand and CSP-exempt.
  • Per the issue's follow-up comment, the request fires unconditionally on every apply() (not just when CSP would block); the probe's own __abs_webdriver_probe_installed flag handles dedupe. The background-side handler targets sender.frameId so subframes the registered probe already reached aren't re-invoked, and swallows executeScript rejections on restricted URLs (chrome://, Web Store, etc.) to match the registration's silent skip.

Closes #131

Test plan

  • bun run typecheck
  • bun run test (1002 passing)
  • bun run check (biome + eslint clean)
  • bun run buildbackground.js purity check still passes after pulling installProbe from lib/webdriver-probe-source into the worker bundle (no rule-file leak)
  • Manual: toggle webdriver-probe-annotate on at https://shield-dark-pattern-demo.vercel.app/ (strict-CSP repro from the issue), confirm no CSP console violation and that a navigator.webdriver read still stamps the landmark on the current tab
  • Manual: confirm restricted URLs (e.g. chrome://extensions) don't surface unhandled rejections in the background console

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 4, 2026 8:50pm

Request Review

twschiller and others added 2 commits June 4, 2026 16:49
The inline-<script> fallback in webdriver-probe-annotate's apply()
was blocked on strict script-src origins, so the active tab got no
probe until the next navigation. Replace it with a content→background
message that runs installProbe via chrome.scripting.executeScript with
world: "MAIN" — same primitive as the primary registration, just
on-demand and CSP-exempt.

Per #131's follow-up comment, the request fires unconditionally on
every apply() (not just when CSP would block); the probe's own
__abs_webdriver_probe_installed flag handles dedupe, and targeting
sender.frameId avoids re-invoking subframes the registered probe
already reached. Background-side executeScript rejections (chrome://,
Web Store, etc.) are swallowed to match the registration's silent
skip on those origins.

Closes #131

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
chrome.scripting.executeScript requires host_permissions for the
target origin even when world: "MAIN" — unlike registerContentScripts,
which honors the content_scripts.matches model. With only
api.openai.com declared, the #131 fallback rejected on every other
host with "Cannot access contents of the page."

The extension already declares content_scripts.matches: ["<all_urls>"],
so the install-time warning is unchanged; this just unblocks the
programmatic injection path the executeScript fallback needs. The
existing api.openai.com entry was redundant under <all_urls>.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Manifest permission diff

The extension's MV3 permission surface changed in this PR. Reviewer: confirm each addition is intentional and necessary.

host_permissions

  • <all_urls>
  • https://api.openai.com/*

@twschiller twschiller merged commit 9706e54 into main Jun 4, 2026
8 checks passed
@twschiller twschiller deleted the fix/webdriver-probe-csp-executeScript branch June 4, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webdriver-probe: route inline fallback through chrome.scripting.executeScript to bypass strict CSP

1 participant