1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Mozilla Public License
4
* Version 1.1 (the "License"); you may not use this file except in
5
* compliance with the License. You may obtain a copy of the License at
6
* http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS IS" basis,
9
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10
* for the specific language governing rights and limitations under the
13
* The Original Code is The JavaScript Debugger
15
* The Initial Developer of the Original Code is
16
* Netscape Communications Corporation
17
* Portions created by Netscape are
18
* Copyright (C) 1998 Netscape Communications Corporation.
20
* Alternatively, the contents of this file may be used under the
21
* terms of the GNU Public License (the "GPL"), in which case the
22
* provisions of the GPL are applicable instead of those above.
23
* If you wish to allow use of your version of this file only
24
* under the terms of the GPL and not to allow others to use your
25
* version of this file under the MPL, indicate your decision by
26
* deleting the provisions above and replace them with the notice
27
* and other provisions required by the GPL. If you do not delete
28
* the provisions above, a recipient may use your version of this
29
* file under either the MPL or the GPL.
32
* Robert Ginda, <rginda@netscape.com>, original author
39
[["dumpcontexts", cmdDumpContexts, CMD_CONSOLE | CMD_NO_HELP],
40
["dumpfilters", cmdDumpFilters, CMD_CONSOLE | CMD_NO_HELP],
41
["dumpprofile", cmdDumpProfile, CMD_CONSOLE | CMD_NO_HELP],
42
["dumptree", cmdDumpTree, CMD_CONSOLE | CMD_NO_HELP],
43
["dumpscripts", cmdDumpScripts, CMD_CONSOLE | CMD_NO_HELP],
44
["reloadui", cmdReloadUI, CMD_CONSOLE | CMD_NO_HELP],
45
["sync-debug", cmdSyncDebug, CMD_CONSOLE | CMD_NO_HELP],
46
["test", cmdTest, CMD_CONSOLE | CMD_NO_HELP],
47
["testargs", cmdTestArgs, CMD_CONSOLE | CMD_NO_HELP],
48
["testargs1", cmdTestArgs, CMD_CONSOLE | CMD_NO_HELP],
49
["testfilters", cmdTestFilters, CMD_CONSOLE | CMD_NO_HELP],
50
["treetest", cmdTreeTest, CMD_CONSOLE | CMD_NO_HELP],
52
["multialias", "help pref; help props", CMD_CONSOLE | CMD_NO_HELP]];
55
console.commandManager.defineCommands (cmdary);
57
if (!("devState" in console.pluginState))
59
console.prefManager.addPref ("dbgContexts", false);
60
console.prefManager.addPref ("dbgDispatch", false);
61
console.prefManager.addPref ("dbgRealize", false);
64
console.pluginState.devState = true;
66
dispatch ("sync-debug");
68
return "Venkman development functions loaded OK.";
71
function cmdDumpContexts()
73
console.contexts = new Array();
77
enumerateContext: function _ec (context) {
80
dd("enumerate got invalid context");
84
var v = context.globalObject.getWrappedValue();
86
if (v instanceof Object &&
89
title = v.document.title;
92
dd ("enumerateContext: Index " + i +
93
", Version " + context.version +
94
", Options " + context.options +
95
", Private " + context.privateData +
96
", Tag " + context.tag +
98
", Scripts Enabled " +
99
context.scriptsEnabled);
101
console.contexts[i++] = context;
105
console.jsds.enumerateContexts(enumer);
109
function cmdDumpFilters()
111
console.filters = new Array();
115
enumerateFilter: function enum_f (filter) {
116
dd (i + ": " + filter.globalObject +
117
" '" + filter.urlPattern + "' " + filter.flags);
118
console.filters[i++] = filter;
122
console.jsds.enumerateFilters (enumer);
125
function cmdDumpProfile(e)
127
var list = console.getProfileSummary();
128
for (var i = 0; i < list.length; ++i)
132
function cmdDumpTree(e)
136
dd(e.tree + ":\n" + tov_formatBranch (eval(e.tree), "", e.depth));
139
function cmdDumpScripts(e)
143
if ("frames" in console)
145
frame = getCurrentFrame();
146
var targetWindow = frame.executionContext.globalObject.getWrappedValue();
147
nl = targetWindow.document.getElementsByTagName("script");
151
nl = document.getElementsByTagName("script");
154
for (var i = 0; i < nl.length; ++i)
155
dd("src: " + nl.item(i).getAttribute ("src"));
158
function cmdReloadUI()
160
if ("frames" in console)
162
display (MSG_NOTE_NOSTACK, MT_ERROR);
166
var bs = Components.classes["@mozilla.org/intl/stringbundle;1"];
167
bs = bs.createInstance(Components.interfaces.nsIStringBundleService);
169
window.location.href = window.location.href;
172
function cmdSyncDebug()
174
if (eval(console.prefs["dbgContexts"]))
175
console.dbgContexts = true;
177
delete console.dbgContexts;
179
if (eval(console.prefs["dbgDispatch"]))
180
console.dbgDispatch = true;
182
delete console.dbgDispatch;
184
if (eval(console.prefs["dbgRealize"]))
185
console.dbgRealize = true;
187
delete console.dbgRealize;
202
for (var i = 0; i < 50000; ++i)
208
function cmdTestArgs (e)
210
display (dumpObjectTree(e));
213
function cmdTestFilters ()
217
flags: jsdIFilter.FLAG_ENABLED,
224
flags: jsdIFilter.FLAG_ENABLED,
231
flags: jsdIFilter.FLAG_ENABLED,
238
flags: jsdIFilter.FLAG_ENABLED,
244
dd ("append f3 into an empty list.");
245
console.jsds.appendFilter (filter3);
247
dd("insert f1 at the top");
248
console.jsds.insertFilter (filter1, null);
250
dd("insert f2 after f1");
251
console.jsds.insertFilter (filter2, filter1);
253
dd("swap f4 in, f3 out");
254
console.jsds.swapFilters (filter3, filter4);
257
console.jsds.appendFilter (filter3);
259
dd("swap f4 and f3");
260
console.jsds.swapFilters (filter3, filter4);
267
function cmdTreeTest()
269
var w = openDialog("chrome://venkman/content/tests/tree.xul", "", "");