1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/**
* (C) Copyright 2007 John J. Foerch
* (C) Copyright 2007-2008 Jeremy Maitin-Shepard
*
* Use, modification, and distribution are subject to the terms specified in the
* COPYING file.
**/
var MAX_DUMP_DEPTH = 1;
function dump_obj_r (obj, name, indent, depth) {
if (depth > MAX_DUMP_DEPTH) {
return indent + name + ": <Maximum Depth Reached>\n";
}
if (typeof obj == "object") {
var child = null;
var output = indent + name + "\n";
indent += "\t";
for (var item in obj) {
try {
child = obj[item];
} catch (e) {
child = "<Unable to Evaluate>";
}
if (typeof child == "object") {
output += dump_obj_r(child, item, indent, depth + 1);
} else {
output += indent + item + ": " + child + "\n";
}
}
return output;
} else {
return obj;
}
}
function dump_obj (obj, name) {
if (typeof obj == "object") {
var child = null;
var output = name + "\n";
for (var item in obj) {
try {
child = obj[item];
} catch (e) {
child = "<Unable to Evaluate>";
}
output += item + ": " + child + "\n";
}
return output;
} else {
return obj;
}
}
function get_interface_info (o) {
var output = "";
for (let x in Ci) {
try {
o.QueryInterface(Ci[x]);
output += x + "\n";
} catch (e) {
try {
o.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci[x]);
output += x + " (getInterface)\n";
} catch (e2) {
}
}
}
return output;
}
/**
* This simple facility can be used to execute arbitrary expression in the context of some point that you'd like to debug.
* At that point, simply set some global variable to the result of: eval(DEBUG_HERE);
* For example: conkeror.my_debug_ref = eval(DEBUG_HERE);
* Then if you call: conkeror.my_debug_ref("some expression"), the specified expression is evaluated in the context
* at which eval(DEBUG_HERE) was called.
*
* Note that the unusual identifier __DEBUG_HERE is simply used to
* avoid clobbering any identifiers that you might want to examine in
* the local context.
*/
const DEBUG_HERE = "function (__DEBUG_HERE) { return eval(__DEBUG_HERE); }";
{
let console = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
console.registerListener({
observe: function (msg) {
if (msg instanceof Ci.nsIScriptError) {
switch (msg.category) {
case "CSS Parser":
case "content javascript":
return;
}
msg.QueryInterface(Ci.nsIScriptError);
dumpln("Console error: " + msg.message);
dumpln(" Category: " + msg.category);
}
}});
}
provide("debug");
|