Skip to content

ruediger/emacs-firefox-remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Using Firefox' Remote Debugger from Emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published