Getting started
Firefox Remote Debugging Protocol TypeScript SDK documentation
Install the package from npmjs:
npm install @openpolyfill/firefox-rdpStart a separate Firefox profile with remote debugging enabled:
firefox --no-remote --profile /path/to/debug-profile --start-debugger-server 6000Enable 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.