Last active
August 29, 2015 14:01
-
-
Save past/d92f80f147c06bfacf9c to your computer and use it in GitHub Desktop.
Revisions
-
past revised this gist
May 15, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ // -sp-context:browser // Open this file in scratchpad and run it. Output goes to the Browser Console (Cmd-Shift-J). Components.utils.import("resource://gre/modules/devtools/dbg-server.jsm"); Components.utils.import("resource://gre/modules/devtools/dbg-client.jsm"); let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -
past created this gist
May 15, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ // -sp-context:browser Components.utils.import("resource://gre/modules/devtools/dbg-server.jsm"); Components.utils.import("resource://gre/modules/devtools/dbg-client.jsm"); let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let { StyleSheetsFront } = devtools.require("devtools/server/actors/stylesheets"); let client; function startDebugger() { // Start the server. if (!DebuggerServer.initialized) { DebuggerServer.init(); DebuggerServer.addBrowserActors(); } // Listen to an nsIPipe let transport = DebuggerServer.connectPipe(); // Start the client. client = new DebuggerClient(transport); client.connect(onConnected); } function shutdownDebugger() { client.close(); } /** * Start debugging the current tab. */ function onConnected() { // Get the list of tabs to find the one to attach to. client.listTabs(function(response) { // Find the active tab. let tab = response.tabs[response.selected]; // Attach to the tab. client.attachTab(tab.actor, function(response, tabClient) { if (!tabClient) return; console.log("HTML:", tab.url); // Attach to the thread (context). client.attachThread(response.threadActor, function(response, threadClient) { if (!threadClient) return; // Fetch the JS sources. threadClient.getSources(function(response) { console.log("JS:", response.sources.map(s => s.url)); // Fetch the stylesheets. let ssf = StyleSheetsFront(client, tab); ssf.getStyleSheets().then((styleSheets) => { console.log("CSS:", styleSheets.map(s => s.href)); }); }); // Resume the thread. threadClient.resume(); // Debugger is now ready and debuggee is running. }); }); }); } startDebugger(); // shutdownDebugger();