File: debug.js

package info (click to toggle)
conkeror 0.9~git080629-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,132 kB
  • ctags: 906
  • sloc: sh: 340; ansic: 246; xml: 105; makefile: 77
file content (84 lines) | stat: -rw-r--r-- 2,480 bytes parent folder | download
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
/**
 * (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(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); }";