• Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[UNMAINTAINED] Node.js remote debugging client for Firefox

firefox-client

firefox-client is a node library for remote debugging Firefox. You can use it to make things like fxconsole, a remote JavaScript REPL.

var FirefoxClient = require("firefox-client");

var client = new FirefoxClient();

client.connect(6000, function() {
  client.listTabs(function(err, tabs) {
    console.log("first tab:", tabs[0].url);
  });
});

Install

With node.js npm package manager:

npm install firefox-client

Connecting

Desktop Firefox

  1. Enable remote debugging (You'll only have to do this once)

  2. Open the DevTools. Web Developer > Toggle Tools

  3. Visit the settings panel (gear icon)

  4. Check "Enable remote debugging" under Advanced Settings

  5. Listen for a connection

  6. Open the Firefox command line with Tools > Web Developer > Developer Toolbar.

  7. Start a server by entering this command: listen 6000 (where 6000 is the port number)

Firefox for Android

Follow the instructions in this Hacks video

Firefox OS 1.1 Simulator

A limited set of the API (Console, StyleSheets) is compatible with the Simulator 4.0. See the wiki instructions for connecting.

client.listTabs() will list the currently open apps in the Simulator.

Firefox OS 1.2+ Simulator and devices

client.getWebapps() will expose the webapps in the Simulator, where each app implements the Tab API.

client.getWebapps(function(err, webapps) {
  webapps.getApp("app://homescreen.gaiamobile.org/manifest.webapp", function (err, app) {
    console.log("homescreen:", actor.url);
    app.Console.evaluateJS("alert('foo')", function(err, resp) {
      console.log("alert dismissed");
    });
  });
});

Compatibility

This latest version of the library will stay compatible with Firefox Nightly. Almost all of it will be compatible with Firefox Aurora as well.

API

A FirefoxClient is the entry point to the API. After connecting, get a Tab object with listTabs() or selectedTab(). Once you have a Tab, you can call methods and listen to events from the tab's modules, Console or Network. There are also experimental DOM and StyleSheets tab modules, and an upcoming Debugger module.

Methods

Almost all API calls take a callback that will get called with an error as the first argument (or null if there is no error), and a return value as the second:

tab.Console.evaluateJS("6 + 7", function(err, resp) {
  if (err) throw err;

  console.log(resp.result);
});

Events

The modules are EventEmitters, listen for events with on or once, and stop listening with off:

tab.Console.on("page-error", function(event) {
  console.log("new error from tab:", event.errorMessage);
});

Summary of the offerings of the modules and objects:

FirefoxClient

Methods: connect(), disconnect(), listTabs(), selectedTab(), getWebapps(), getRoot()

Events: "error", "timeout", "end"

Tab

Properties: url, title

Methods: reload(), navigateTo(), attach(), detach()

Events: "navigate", "before-navigate"

Tab.Console

Methods: evaluateJS(), startListening(), stopListening(), getCachedLogs()

Events: "page-error", "console-api-call"

JSObject

Properties: class, name, displayName

Methods: ownPropertyNames(), ownPropertyDescriptor(), ownProperties(), prototype()

Tab.Network

Methods: startLogging(), stopLogging(), sendHTTPRequest()

Events: "network-event"

NetworkEvent

Properties: url, method, isXHR

Methods: getRequestHeaders(), getRequestCookies(), getRequestPostData(), getResponseHeaders(), getResponseCookies(), getResponseContent(), getEventTimings()

Events: "request-headers", "request-cookies", "request-postdata", "response-start", "response-headers", "response-cookies", "event-timings"

Tab.DOM

Methods: document(), documentElement(), querySelector(), querySelectorAll()

DOMNode

Properties: nodeValue, nodeName, namespaceURI

Methods: parentNode(), parents(), siblings(), nextSibling(), previousSibling(), querySelector(), querySelectorAll(), innerHTML(), outerHTML(), setAttribute(), remove(), release()

Tab.StyleSheets

Methods: getStyleSheets(), addStyleSheet()

StyleSheet

Properties: href, disabled, ruleCount

Methods: getText(), update(), toggleDisabled(), getOriginalSources()

Events: "disabled-changed", "ruleCount-changed"

Tab.Memory

Methods: measure()

Webapps

Methods: listRunningApps(), getInstalledApps(), watchApps(), unwatchApps(), launch(), close(), getApp(), installHosted(), installPackaged(), installPackagedWithADB(), uninstall()

Events: "appOpen", "appClose", "appInstall", "appUninstall"

Examples

fxconsole - a remote JavaScript console for Firefox

webapps test script - a sample usage of all webapps features

Feedback

What do you need from the API? File an issue.

More Repositories

1

brain

Simple feed-forward neural network in JavaScript
JavaScript
8,006
star
2

kittydar

Face detection for cats in JavaScript - demo for TXJS 2012 talk
JavaScript
1,419
star
3

replace

Command line search and replace utility
JavaScript
748
star
4

classifier

Bayesian classifier with Redis backend
JavaScript
625
star
5

clustering

K-means and hierarchical clustering
JavaScript
498
star
6

nomnom

Option parser for node with generated usage and commands
JavaScript
470
star
7

hog-descriptor

[UNMAINTAINED] Histogram of Oriented Gradients (HOG) descriptor extractor
JavaScript
169
star
8

glossary

[UNMAINTAINED] Extract terms and keywords from a piece of text
JavaScript
168
star
9

fxconsole

[UNMAINTAINED] Remote JavaScript console for Firefox
JavaScript
127
star
10

costco

UI for bulk editing CouchDB docs
JavaScript
56
star
11

js-select

[UNMAINTAINED] Traverse and modify objects using JSONSelect selectors
JavaScript
56
star
12

rainbow

Color tools for Firefox
JavaScript
39
star
13

txjs-slides

dzslides deck for my txjs talk
CSS
14
star
14

mac-sounds

Play default OS X sounds from node
JavaScript
9
star
15

bzhome

Bugzilla dashboard
JavaScript
8
star
16

passion-project-slides

Slides for my Passion Projects talk on Machine Learning and JS
JavaScript
7
star
17

tcm

Mozilla's new testcase manager
JavaScript
5
star
18

detect-indent

CSS
5
star
19

searchbugs

Search for Bugzilla bugs by component
JavaScript
4
star
20

test-pages

Testcase websites for devtools
JavaScript
3
star
21

devtools-guide

3
star
22

showsearch

Jetpack that shows search terms in Firefox's awesomebar
JavaScript
3
star
23

firefontfamily

A Firebug extension that highlights the rendered font-family
JavaScript
2
star
24

contextfont

Firefox addon to find fonts on websites
JavaScript
2
star
25

celestial-snips-app

Snips voice assistant that answers celestial questions
Python
2
star
26

mini-devtools

mini in-content devtools
JavaScript
2
star
27

artfulimage

The Artful Image fine printing
2
star
28

bztweaks

mirror of Bugzilla Tweaks Firefox addon (https://bitbucket.org/ehsan/bugzilla-tweaks)
JavaScript
2
star
29

fluent-talk

JavaScript
1
star
30

bugidhelper

Bugzilla bug id linkifier and tooltipifier extension
JavaScript
1
star
31

brooklynjs-slides

Write your own in-content devtools with web APIs
CSS
1
star
32

test-snips-calc

Test Snips Calc Action
Python
1
star
33

harth

harth's no.de code
1
star
34

wwcode

A small website for Women Who Code SF
JavaScript
1
star
35

celestial-jupyter

Jupyter Notebook
1
star
36

test.js

Whatever's in my ~/test.js
JavaScript
1
star