Skip to content
Using Firefox' Remote Debugger from Emacs
Emacs Lisp
Branch: master
Clone or download
Latest commit 599dbe8 Dec 28, 2013
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore .gitignore file. Mar 21, 2013
README.org Segv did it. Mar 22, 2013
firefox-remote.el Fix header line Dec 28, 2013
test.el test: fixed call to set-default-handler. Mar 21, 2013

README.org

I just found out that a similar project which also includes Chrome support exists: https://github.com/segv/jss

—-

Since version 15 Mozilla Firefox comes with a remote debugging protocol. This was introduced to support debugging for Firefox on Android and FirefoxOS. But it can also be activated for regular Firefox although it requires a bit of extra work at the moment (Firefox 19).

This Emacs package provides a basic implementation of the protocol for Emacs. So far only the lowlevel communication structure is done.

Configuring Firefox

Go to about:config and set the following paramters: devtools.debugger.remote-enabled to true and devtools.debugger.force-local to false and devtools.chrome.enabled to true and restarted firefox.

Open a Scratchpad (Shift+F4 or WebDeveloper menu entry) and select in the Environment menu the “Browser” option. Copy and paste the following script and eval it with C-r.

const Cu = Components.utils;

Cu.import("resource://gre/modules/devtools/dbg-server.jsm");

function startDebuggerServer()
{
  // Start the server.
  if (!DebuggerServer.initialized) {
    DebuggerServer.init();
    DebuggerServer.addBrowserActors();
  }
  // For an nsIServerSocket we do this:
  DebuggerServer.openListener(6000); // A connection on port 6000.
}
 
startDebuggerServer();

Information

Basic Usage

(let ((con (firefox-remote-connect "localhost" 6000)))
  (firefox-remote-send con '((to . root) (type . listTabs))
                       (lambda (data)
                         (let* ((selected (cdr (assq 'selected data)))
                                (tabs (cdr (assq 'tabs data)))
                                (current-tab (aref tabs selected))
                                (url (cdr (assq 'url current-tab)))
                                (title (cdr (assq 'title current-tab))))
                           (message "Current Tab \"%s\": \"%s\"" title url))))
  (sleep-for 10)
  (firefox-remote-disconnect con))

This should print the title and url of the currently selected tab to the *Messages* buffer.

You can’t perform that action at this time.