codex - 💡(How to fix) Fix Support trusted page-context hooks for local preview browser automation

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Many local dev previews intentionally expose debug/test hooks for fast verification. This is common for games, WebGL apps, design tools, dashboards, canvas editors, and complex single-page apps.

Without a supported page-context hook, Codex can still do visual/manual-style testing, but it cannot use the same structured preview bridge that a project already built for deterministic QA. That makes Codex less capable than preview environments that can call app-owned debug hooks directly.

Code Example

window.unityInstance
window.b

---

b('SetLevel', '2')
b('EnterLevel')
b('HoldCard', 'Cow,0,5')
b('PlaceCard', 'Cow,0,5')
RAW_BUFFERClick to expand / collapse

Feature request

Please provide a safe way for Codex browser automation to execute/evaluate JavaScript in the actual page context for local/dev preview workflows, or otherwise expose selected page globals intentionally.

Problem

Codex's in-app browser automation can navigate pages, click, drag, screenshot, and run a read-oriented evaluator. However, the evaluator appears isolated from the page's real JavaScript global scope. This means page-defined globals are not visible even when they are intentionally exposed by a local preview page.

From Codex's point of view, this creates a gap for development previews that deliberately expose test/debug hooks on window.

For example, a Unity WebGL local preview page exposes helpers like:

window.unityInstance
window.b

Those hooks allow automated testing/debugging actions such as setting a level, entering a scene, holding a card for visual QA, or placing a card through the same game bridge used by preview tooling. In another preview environment, an agent can call those hooks directly. In Codex's in-app browser, tab.playwright.evaluate() reports those globals as undefined, because it is not evaluating in the same page world.

Trying to route through a javascript: URL is blocked by browser security policy, which is understandable, but there does not appear to be a supported alternative for trusted local preview pages.

Desired capability

Codex should have a supported, safe mechanism for local/dev preview pages to expose automation hooks to the agent. Possible designs:

  • a page-context evaluate mode gated to localhost / explicitly trusted preview origins
  • an allowlisted bridge where a page can register named debug methods for Codex to call
  • a way for Codex preview tooling to call specific exposed page globals without broad unrestricted script execution
  • a documented app/plugin manifest mechanism for trusted local preview hooks

Why this matters

Many local dev previews intentionally expose debug/test hooks for fast verification. This is common for games, WebGL apps, design tools, dashboards, canvas editors, and complex single-page apps.

Without a supported page-context hook, Codex can still do visual/manual-style testing, but it cannot use the same structured preview bridge that a project already built for deterministic QA. That makes Codex less capable than preview environments that can call app-owned debug hooks directly.

Concrete example

A Unity WebGL game has a preview bridge for QA:

b('SetLevel', '2')
b('EnterLevel')
b('HoldCard', 'Cow,0,5')
b('PlaceCard', 'Cow,0,5')

These calls are intentionally exposed by the local WebGL template for development/testing. Codex can see and interact with the rendered canvas, but cannot call the bridge because the evaluator cannot access the page globals.

Impact

A supported page-context or registered-hook mechanism would let Codex perform deterministic local preview QA while still preserving browser safety boundaries.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Support trusted page-context hooks for local preview browser automation