Skip to content

Instantly share code, notes, and snippets.

View robcee's full-sized avatar
🌶️
one million scovilles

Rob Campbell robcee

🌶️
one million scovilles
View GitHub Profile
// GCLI Browser Scratchpad
// via https://bugzilla.mozilla.org/show_bug.cgi?id=724055#c7
// gBrowser.ownerDocument.defaultView.Scratchpad.openScratchpad()
Cu.import("resource:///modules/devtools/gcli.jsm");
gcli.addCommand({
name: "scratchpad",
description: "Commands to open a Scratchpad"
});
@robcee
robcee / remote.js
Created August 16, 2012 15:27
Creating a remote debugger server
/**
* Creating a remote debugger server.
*/
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
if (!DebuggerServer.initialized) {
DebuggerServer.init(function() true);
DebuggerServer.addBrowserActors();
}
DebuggerServer.closeListener();
@robcee
robcee / postToAppNet.js
Created October 1, 2012 15:35
Scratch-kit Scratchpad to post to App.net
var currentTab = require('tabs').activeTab;
var url = currentTab.url; // get the location.
var title = currentTab.title;
var appscript = "self.port.on('update', function _update() {" +
" console.log('hi');" +
" document.querySelector('div.navbar').setAttribute('hidden', 'true'); " +
" document.querySelector('div.hero-unit').setAttribute('hidden', 'true'); " +
" document.querySelector('div.post-stream').setAttribute('hidden', 'true'); " +
" let newPost = document.querySelector('textarea.editable.input-flex');" +
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text (Ctrl+R),
* 2. Inspect to bring up an Object Inspector on the result (Ctrl+I), or,
* 3. Display to insert the result in a comment after the selection. (Ctrl+L)
*/
Components.utils.import("resource://gre/modules/osfile.jsm");
/*
* This Scratchpad will poll the Google Play Store every hour and
* look for the words "Sold Out" in their banner div. If they're
* not there, you'll get an alert that it's in!
*
* This Scratchpad needs to run in Browser Context!
* https://developer.mozilla.org/en-US/docs/Tools/Scratchpad#Using_Scratchpad_to_access_Firefox_internals
*/
var duration = 1000 * 60 * 60; // ms * sec * min = 1 hour
diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js
--- a/browser/devtools/scratchpad/scratchpad.js
+++ b/browser/devtools/scratchpad/scratchpad.js
@@ -23,19 +23,22 @@ Cu.import("resource://gre/modules/Servic
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource:///modules/PropertyPanel.jsm");
Cu.import("resource:///modules/source-editor.jsm");
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource:///modules/devtools/scratchpad-manager.jsm");
Cu.import("resource://gre/modules/jsdebugger.jsm");

Web Console output rewrite, bug 778766

This document describes the ongoing work for the Web Console output rewrite / reimplementation. Feedback is requested.

WORK IN PROGRESS!

Current issues

Issues currently affecting the Web Console output:

  • page navigation/reload issues:

This interface is partly implemented in Firefox Nightly builds. Some parts are not implemented, some APIs may yet change, and anything marked "(future plan)" is a long way off. You can [https://github.com/jimblandy/DebuggerDocs fork this specification on github] to draft and discuss revisions.

The Debugger constructor makes objects with methods for debugging code running in global objects in other compartments. Given a Debugger instance, you can:

  • add debuggee global objects to its purview using its addDebuggee method;
  • request notification of basic debugging events like stack frame entry and debugger statement execution by providing appropriate handler functions;
  • set breakpoints in scripts;
  • set watchpoints on objects and their properties;
  • examine the debuggee's stack frames and lexical enviroments; inspect and manipulate its objects;

Writing an Actor

A Simple Hello World

Here's a simple Hello World actor. It is a global actor (not associated with a given browser tab).

let protocol = require("devtools/server/protocol");

let {method, Arg, Option, RetVal} = protocol;

// open a web console
let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
// console.profile();
let targét = devtools.TargetFactory.forTab(gBrowser.selectedTab);
let startTime = Date.now();
let endTime;
gDevTools.showToolbox(targét, "inspector").then(() => {