2 * (C) Copyright 2007 John J. Foerch
3 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
5 * Use, modification, and distribution are subject to the terms specified in the
9 var MAX_DUMP_DEPTH = 1;
10 function dump_obj_r (obj, name, indent, depth) {
11 if (depth > MAX_DUMP_DEPTH) {
12 return indent + name + ": <Maximum Depth Reached>\n";
14 if (typeof obj == "object") {
16 var output = indent + name + "\n";
18 for (var item in obj) {
22 child = "<Unable to Evaluate>";
24 if (typeof child == "object") {
25 output += dump_obj_r(child, item, indent, depth + 1);
27 output += indent + item + ": " + child + "\n";
36 function dump_obj (obj, name) {
37 if (typeof obj == "object") {
39 var output = name + "\n";
40 for (var item in obj) {
44 child = "<Unable to Evaluate>";
46 output += item + ": " + child + "\n";
54 function get_interface_info (o) {
58 o.QueryInterface(Ci[x]);
62 o.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci[x]);
63 output += x + " (getInterface)\n";
72 * This simple facility can be used to execute arbitrary expression in the context of some point that you'd like to debug.
73 * At that point, simply set some global variable to the result of: eval(DEBUG_HERE);
74 * For example: conkeror.my_debug_ref = eval(DEBUG_HERE);
75 * Then if you call: conkeror.my_debug_ref("some expression"), the specified expression is evaluated in the context
76 * at which eval(DEBUG_HERE) was called.
78 * Note that the unusual identifier __DEBUG_HERE is simply used to
79 * avoid clobbering any identifiers that you might want to examine in
82 const DEBUG_HERE = "function (__DEBUG_HERE) { return eval(__DEBUG_HERE); }";
86 let (console = Cc["@mozilla.org/consoleservice;1"]
87 .getService(Ci.nsIConsoleService)) {
88 console.registerListener({
89 observe: function (msg) {
90 if (msg instanceof Ci.nsIScriptError) {
91 switch (msg.category) {
93 case "content javascript":
96 msg.QueryInterface(Ci.nsIScriptError);
97 dumpln("Console error: " + msg.message);
98 dumpln(" Category: " + msg.category);