Skip to content

Add Page.getEventListenersForNode to the Juggler protocol #591

Description

@baixianger

Describe the feature:

Add a new Juggler Page domain method that enumerates the event listeners attached to a DOM node, by wrapping the existing nsIEventListenerService.getListenerInfoFor(node) XPCOM service:

Page.getEventListenersForNode({ frameId, objectId })
  → { listeners: [
        { type, capturing, allowsUntrusted, inSystemEventGroup },
        ...
      ]
    }

Field names mirror Firefox's nsIEventListenerInfo interface (dom/events/nsIEventListenerService.idl) verbatim so the mapping from the underlying XPCOM service is unambiguous. The DOM-level passive flag is intentionally omitted because Firefox does not expose it through this interface.

The patch is purely additive — no existing methods or types are touched. ~60 lines across three files in additions/juggler/:

  • protocol/Protocol.js — declare the method + add pageTypes.EventListenerInfo
  • protocol/PageHandler.js — one-line dispatch to the content side
  • content/PageAgent.js — register + implement via nsIEventListenerService

I have a working patch (verified locally on Camoufox 146.0.1-beta.25 — Protocol.js validation accepts the new schema, the build runs cleanly, and the wire stack accepts Juggler messages with the patch in place) and will open a PR linking this issue.

Is your feature request related to a problem? Please describe.

The recent surge of LLM-agent browser tooling — Browser-Use, chrome-devtools-mcp, Vercel's agent-browser, browserbase, and others — all need to discover non-ARIA interactive elements like <div onclick> or <span data-action> to drive realistic agent ↔ web interactions. Pure accessibility-tree walks miss these elements: the AX tree marks them as role=generic, so the agent sees a static page when the user sees a clickable surface.

Chrome's DevTools Runtime context has long exposed a getEventListeners(el) helper for exactly this case; bringing parity to Firefox-flavored automation through Juggler closes the gap and makes Camoufox a viable backend for agent stacks that today only target Chromium.

The XPCOM service this wraps is stable since 2008 (https://bugzilla.mozilla.org/show_bug.cgi?id=524674). Adding the binding is a thin, low-risk change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions