Firefox RDP
Esc

Start typing to search the docs

Getting started

Firefox Remote Debugging Protocol TypeScript SDK documentation

1 min read · 115 words

View as Markdown

Install the package from npmjs:

npm install @openpolyfill/firefox-rdp

Start a separate Firefox profile with remote debugging enabled:

firefox --no-remote --profile /path/to/debug-profile --start-debugger-server 6000

Enable devtools.debugger.remote-enabled / devtools.chrome.enabled if your build requires them, and approve the remote-debugging prompt. Bind/access the debugging endpoint only on trusted localhost. See connection security.

First program

import { FirefoxRDP } from '@openpolyfill/firefox-rdp'
const rdp = await FirefoxRDP.connect({ port: 6000 })
try {
  const tabs = await rdp.root.listTabs()
  const tab = tabs.find((t) => t.selected) ?? tabs[0]
  if (!tab) throw new Error('Open a Firefox tab first')
  const target = await tab.getTarget()
  const evaluation = await target.console().evaluateJS('document.title')
  if (evaluation.hasException) throw new Error(String(evaluation.exceptionMessage))
  console.log(evaluation.result)
} finally {
  rdp.close()
}

Run it with a TypeScript runtime of your choice, or compile with tsc. Open an ordinary web tab first. The script closes the connection in finally.

Where next?

Read tabs & targets, events & resources, and the API reference. The runtime includes generated actor bindings from a recorded Firefox source revision; regenerate them when targeting a different revision.