Last active
January 28, 2017 11:37
-
-
Save cat-in-136/5afab5cb704205d344c75a2902bbb820 to your computer and use it in GitHub Desktop.
Run firefox with remote debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by https://www.gitignore.io/api/node,vim,emacs | |
### Node ### | |
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
# Runtime data | |
pids | |
*.pid | |
*.seed | |
*.pid.lock | |
# Directory for instrumented libs generated by jscoverage/JSCover | |
lib-cov | |
# Coverage directory used by tools like istanbul | |
coverage | |
# nyc test coverage | |
.nyc_output | |
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | |
.grunt | |
# node-waf configuration | |
.lock-wscript | |
# Compiled binary addons (http://nodejs.org/api/addons.html) | |
build/Release | |
# Dependency directories | |
node_modules | |
jspm_packages | |
# Optional npm cache directory | |
.npm | |
# Optional eslint cache | |
.eslintcache | |
# Optional REPL history | |
.node_repl_history | |
# Output of 'npm pack' | |
*.tgz | |
# Yarn Integrity file | |
.yarn-integrity | |
### Vim ### | |
# swap | |
[._]*.s[a-v][a-z] | |
[._]*.sw[a-p] | |
[._]s[a-v][a-z] | |
[._]sw[a-p] | |
# session | |
Session.vim | |
# temporary | |
.netrwhist | |
*~ | |
# auto-generated tag files | |
tags | |
### Emacs ### | |
# -*- mode: gitignore; -*- | |
\#*\# | |
/.emacs.desktop | |
/.emacs.desktop.lock | |
*.elc | |
auto-save-list | |
tramp | |
.\#* | |
# Org-mode | |
.org-id-locations | |
*_archive | |
# flymake-mode | |
*_flymake.* | |
# eshell files | |
/eshell/history | |
/eshell/lastdir | |
# elpa packages | |
/elpa/ | |
# reftex files | |
*.rel | |
# AUCTeX auto folder | |
/auto/ | |
# cask packages | |
.cask/ | |
dist/ | |
# Flycheck | |
flycheck_*.el | |
# server auth directory | |
/server/ | |
# projectiles files | |
.projectile | |
# directory configuration | |
.dir-locals.el | |
# End of https://www.gitignore.io/api/node,vim,emacs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "runfx-with-remote-debugging", | |
"version": "0.0.0", | |
"description": "Run firefox with remote debugging", | |
"main": "runfx.js", | |
"dependencies": { | |
"firefox-client": "^0.3.0", | |
"firefox-profile": "^0.4.7", | |
"fx-runner": "^1.0.6" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "https://gist.github.com/5afab5cb704205d344c75a2902bbb820.git" | |
}, | |
"author": "@cat-in-136", | |
"license": "Zlib", | |
"bugs": { | |
"url": "https://gist.github.com/5afab5cb704205d344c75a2902bbb820" | |
}, | |
"homepage": "https://gist.github.com/5afab5cb704205d344c75a2902bbb820" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const Timer = require("timers"); | |
const FirefoxProfile = require("firefox-profile"); | |
const FxRunner = require("fx-runner/lib/run"); | |
const FirefoxClient = require("firefox-client"); | |
let fxclient = undefined; | |
(new Promise((resolve, reject) => { | |
let profile = new FirefoxProfile(); | |
profile.setPreference("devtools.debugger.remote-enabled", true); | |
profile.setPreference("devtools.chrome.enabled", true); | |
profile.setPreference("devtools.debugger.prompt-connection", false); | |
profile.updatePreferences(); | |
profile.encoded((zippedProfile) => { | |
resolve(profile, zippedProfile); | |
}); | |
})).then((profile, zippedProfile) => { | |
return FxRunner({ | |
"no-remote": true, | |
"profile": profile.profileDir, | |
"env": process.env, | |
"verbose": true, | |
"listen": 6000, | |
}); | |
}).then(() => new Promise((resolve, reject) => { | |
// HACK wait | |
Timer.setTimeout(() => resolve(), 3000); | |
})).then(() => new Promise((resolve, reject) => { | |
// remote access example | |
fxclient = new FirefoxClient(); | |
fxclient.connect(6000, () => resolve()); | |
})).then(() => new Promise((resolve, reject) => { | |
fxclient.request("listAddons", (error, response) => { | |
if (error) { | |
reject(new Error(error)); | |
} else { | |
console.log(response); | |
resolve(response.addons); | |
} | |
}); | |
})).then(() => new Promise((resolve, reject) => { | |
fxclient.request("getProcess", (error, response) => { | |
if (error) { | |
reject(new Error(error)); | |
} else { | |
console.log(response); | |
let fxconsole = Object.create(fxclient, {actor: {value: response.form.consoleActor}}); | |
fxconsole.request("evaluateJS", { | |
text: "`Firefox v${Services.appinfo.version} running (PID:${Services.appinfo.processID})`;" | |
}, (error, response) => { | |
if (error) { | |
reject(new Error(error)); | |
} else { | |
console.log(response.result); | |
} | |
}); | |
} | |
}); | |
})).then(() => { | |
console.log("."); | |
}).catch((ex) => { | |
console.error(ex); | |
process.exit(1); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment