rename browser-follow-next/previous to follow-next/previous
[conkeror.git] / modules / debug.js
blob46ea3a2b4c6ef01b76e9386b73c8e3f42760a196
1 /**
2  * (C) Copyright 2007 John J. Foerch
3  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
4  *
5  * Use, modification, and distribution are subject to the terms specified in the
6  * COPYING file.
7 **/
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";
13     }
14     if (typeof obj == "object") {
15         var child = null;
16         var output = indent + name + "\n";
17         indent += "\t";
18         for (var item in obj)
19         {
20             try {
21                 child = obj[item];
22             } catch (e) {
23                 child = "<Unable to Evaluate>";
24             }
25             if (typeof child == "object") {
26                 output += dump_obj(child, item, indent, depth + 1);
27             } else {
28                 output += indent + item + ": " + child + "\n";
29             }
30         }
31         return output;
32     } else {
33         return obj;
34     }
37 function dump_obj (obj, name) {
38     if (typeof obj == "object") {
39         var child = null;
40         var output = name + "\n";
41         for (var item in obj)
42         {
43             try {
44                 child = obj[item];
45             } catch (e) {
46                 child = "<Unable to Evaluate>";
47             }
48             output += item + ": " + child + "\n";
49         }
50         return output;
51     } else {
52         return obj;
53     }
56 /**
57  * This simple facility can be used to execute arbitrary expression in the context of some point that you'd like to debug.
58  * At that point, simply set some global variable to the result of: eval(DEBUG_HERE);
59  * For example:  conkeror.my_debug_ref = eval(DEBUG_HERE);
60  * Then if you call:  conkeror.my_debug_ref("some expression"), the specified expression is evaluated in the context
61  * at which eval(DEBUG_HERE) was called.
62  *
63  * Note that the unusual identifier __DEBUG_HERE is simply used to
64  * avoid clobbering any identifiers that you might want to examine in
65  * the local context.
66  */
67 const DEBUG_HERE = "function (__DEBUG_HERE) { return eval(__DEBUG_HERE); }";