Factor out mime.js matching logic to predicate_alist_match
[conkeror.git] / modules / debug.js
blob3c7d706223fbf49ff12d81fed6f308c683962400
1 var MAX_DUMP_DEPTH = 1;
2 function dump_obj_r(obj, name, indent, depth) {
3     if (depth > MAX_DUMP_DEPTH) {
4         return indent + name + ": <Maximum Depth Reached>\n";
5     }
6     if (typeof obj == "object") {
7         var child = null;
8         var output = indent + name + "\n";
9         indent += "\t";
10         for (var item in obj)
11         {
12             try {
13                 child = obj[item];
14             } catch (e) {
15                 child = "<Unable to Evaluate>";
16             }
17             if (typeof child == "object") {
18                 output += dump_obj(child, item, indent, depth + 1);
19             } else {
20                 output += indent + item + ": " + child + "\n";
21             }
22         }
23         return output;
24     } else {
25         return obj;
26     }
29 function dump_obj (obj, name) {
30     if (typeof obj == "object") {
31         var child = null;
32         var output = name + "\n";
33         for (var item in obj)
34         {
35             try {
36                 child = obj[item];
37             } catch (e) {
38                 child = "<Unable to Evaluate>";
39             }
40             output += item + ": " + child + "\n";
41         }
42         return output;
43     } else {
44         return obj;
45     }
48 /**
49  * This simple facility can be used to execute arbitrary expression in the context of some point that you'd like to debug.
50  * At that point, simply set some global variable to the result of: eval(DEBUG_HERE);
51  * For example:  conkeror.my_debug_ref = eval(DEBUG_HERE);
52  * Then if you call:  conkeror.my_debug_ref("some expression"), the specified expression is evaluated in the context
53  * at which eval(DEBUG_HERE) was called.
54  *
55  * Note that the unusual identifier __DEBUG_HERE is simply used to
56  * avoid clobbering any identifiers that you might want to examine in
57  * the local context.
58  */
59 const DEBUG_HERE = "function (__DEBUG_HERE) { return eval(__DEBUG_HERE); }";