1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is The JavaScript Debugger.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
24 * Robert Ginda, <rginda@netscape.com>, original author
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 const CMD_CONSOLE = 0x01; // command is available via the console
41 const CMD_NEED_STACK = 0x02; // command only works if we're stopped
42 const CMD_NO_STACK = 0x04; // command only works if we're *not* stopped
43 const CMD_NO_HELP = 0x08; // don't whine if there is no help for this command
45 function initCommands()
47 console.commandManager = new CommandManager(console.defaultBundle);
50 [/* "real" commands */
51 ["about-mozilla", cmdAboutMozilla, 0],
52 ["break", cmdBreak, CMD_CONSOLE],
53 ["break-props", cmdBreakProps, CMD_CONSOLE],
54 ["change-container", cmdChangeContainer, CMD_CONSOLE],
55 ["change-value", cmdChangeValue, 0],
56 ["chrome-filter", cmdChromeFilter, CMD_CONSOLE],
57 ["clear", cmdClear, CMD_CONSOLE],
58 ["clear-all", cmdClearAll, CMD_CONSOLE],
59 ["clear-break", cmdClearBreak, 0],
60 ["clear-fbreak", cmdClearFBreak, 0],
61 ["clear-profile", cmdClearProfile, CMD_CONSOLE],
62 ["clear-session", cmdHook, CMD_CONSOLE],
63 ["clear-script", cmdClearScript, 0],
64 ["clear-instance", cmdClearInstance, 0],
65 ["close", cmdClose, CMD_CONSOLE],
66 ["cmd-undo", "cmd-docommand cmd_undo", 0],
67 ["cmd-redo", "cmd-docommand cmd_redo", 0],
68 ["cmd-cut", "cmd-docommand cmd_cut", 0],
69 ["cmd-copy", "cmd-docommand cmd_copy", 0],
70 ["cmd-paste", "cmd-docommand cmd_paste", 0],
71 ["cmd-delete", "cmd-docommand cmd_delete", 0],
72 ["cmd-selectall", "cmd-docommand cmd_selectAll", 0],
73 ["cmd-copy-link-url", "cmd-docommand cmd_copyLink", 0],
74 ["cmd-mozilla-prefs", "cmd-docommand cmd_mozillaPrefs", 0],
75 ["cmd-prefs", "cmd-docommand cmd_venkmanPrefs", 0],
76 ["cmd-venkman-prefs", "cmd-docommand cmd_venkmanPrefs", 0],
77 ["cmd-venkman-opts", "cmd-docommand cmd_venkmanPrefs", 0],
78 ["cmd-docommand", cmdDoCommand, 0],
79 ["commands", cmdCommands, CMD_CONSOLE],
80 ["cont", cmdCont, CMD_CONSOLE | CMD_NEED_STACK],
81 ["debug-script", cmdSetScriptFlag, 0],
82 ["debug-instance-on", cmdToggleSomething, 0],
83 ["debug-instance-off", cmdToggleSomething, 0],
84 ["debug-instance", cmdSetScriptFlag, 0],
85 ["debug-transient", cmdSetTransientFlag, 0],
86 ["emode", cmdEMode, CMD_CONSOLE],
87 ["eval", cmdEval, CMD_CONSOLE],
88 ["evald", cmdEvald, CMD_CONSOLE],
89 ["fbreak", cmdFBreak, CMD_CONSOLE],
90 ["set-eval-obj", cmdSetEvalObj, 0],
91 ["set-break", cmdBreak, 0],
92 ["set-fbreak", cmdFBreak, 0],
93 ["fclear", cmdFClear, CMD_CONSOLE],
94 ["fclear-all", cmdFClearAll, CMD_CONSOLE],
95 ["find-bp", cmdFindBp, 0],
96 ["find-creator", cmdFindCreatorOrCtor, 0],
97 ["find-ctor", cmdFindCreatorOrCtor, 0],
98 ["find-file", cmdFindFile, CMD_CONSOLE],
99 ["find-frame", cmdFindFrame, CMD_NEED_STACK],
100 ["find-sourcetext", cmdFindSourceText, 0],
101 ["find-sourcetext-soft", cmdFindSourceText, 0],
102 ["find-script", cmdFindScript, 0],
103 ["find-scriptinstance", cmdFindScriptInstance, 0],
104 ["find-url", cmdFindURL, CMD_CONSOLE],
105 ["find-url-soft", cmdFindURL, 0],
106 ["finish", cmdFinish, CMD_CONSOLE | CMD_NEED_STACK],
107 ["focus-input", cmdHook, 0],
108 ["frame", cmdFrame, CMD_CONSOLE | CMD_NEED_STACK],
109 ["gc", cmdGC, CMD_CONSOLE],
110 ["help", cmdHelp, CMD_CONSOLE],
111 ["inspect", cmdInspect, CMD_CONSOLE],
112 ["loadd", cmdLoadd, CMD_CONSOLE],
113 ["move-view", cmdMoveView, CMD_CONSOLE],
114 ["mozilla-help", cmdMozillaHelp, 0],
115 ["next", cmdNext, CMD_CONSOLE | CMD_NEED_STACK],
116 ["open-dialog", cmdOpenDialog, CMD_CONSOLE],
117 ["open-url", cmdOpenURL, 0],
118 ["pprint", cmdPPrint, CMD_CONSOLE],
119 ["pref", cmdPref, CMD_CONSOLE],
120 ["profile", cmdProfile, CMD_CONSOLE],
121 ["profile-script", cmdSetScriptFlag, 0],
122 ["profile-instance", cmdSetScriptFlag, 0],
123 ["profile-instance-on", cmdSetScriptFlag, 0],
124 ["profile-instance-off", cmdSetScriptFlag, 0],
125 ["props", cmdProps, CMD_CONSOLE],
126 ["propsd", cmdProps, CMD_CONSOLE],
127 ["quit", cmdQuit, CMD_CONSOLE],
128 ["restore-layout", cmdRestoreLayout, CMD_CONSOLE],
129 ["restore-settings", cmdRestoreSettings, CMD_CONSOLE],
130 ["release-notes", cmdReleaseNotes, 0],
131 ["run-to", cmdRunTo, CMD_NEED_STACK],
132 ["save-breakpoints", cmdSaveBreakpoints, CMD_CONSOLE],
133 ["save-layout", cmdSaveLayout, CMD_CONSOLE],
134 ["save-profile", cmdSaveProfile, CMD_CONSOLE],
135 ["save-settings", cmdSaveSettings, CMD_CONSOLE],
136 ["scan-source", cmdScanSource, 0],
137 ["scope", cmdScope, CMD_CONSOLE | CMD_NEED_STACK],
138 ["show-profile", cmdShowProfile, CMD_CONSOLE],
139 ["this-expr", cmdThisExpr, CMD_CONSOLE],
140 ["toggle-float", cmdToggleFloat, CMD_CONSOLE],
141 ["toggle-view", cmdToggleView, CMD_CONSOLE],
142 ["toggle-pref", cmdTogglePref, CMD_CONSOLE],
143 ["startup-init", cmdStartupInit, CMD_CONSOLE],
144 ["step", cmdStep, CMD_CONSOLE | CMD_NEED_STACK],
145 ["stop", cmdStop, CMD_CONSOLE | CMD_NO_STACK],
146 ["tmode", cmdTMode, CMD_CONSOLE],
147 ["version", cmdVersion, CMD_CONSOLE],
148 ["where", cmdWhere, CMD_CONSOLE | CMD_NEED_STACK],
152 ["save-default-layout", "save-layout default", 0],
153 ["profile-tb", "profile toggle", 0],
154 ["this", "props this", CMD_CONSOLE],
155 ["toggle-chrome", "chrome-filter toggle", 0],
156 ["toggle-forcescriptload", "toggle-pref profile.forceScriptLoad", 0],
157 ["toggle-ias", "startup-init toggle", 0],
158 ["toggle-pprint", "pprint toggle", 0],
159 ["toggle-profile", "profile toggle", 0],
160 ["toggle-save-layout", "toggle-pref saveLayoutOnExit", 0],
161 ["toggle-save-settings", "toggle-pref saveSettingsOnExit", 0],
162 ["em-cycle", "emode cycle", 0],
163 ["em-ignore", "emode ignore", 0],
164 ["em-trace", "emode trace", 0],
165 ["em-break", "emode break", 0],
166 ["tm-cycle", "tmode cycle", 0],
167 ["tm-ignore", "tmode ignore", 0],
168 ["tm-trace", "tmode trace", 0],
169 ["tm-break", "tmode break", 0],
172 ["hook-break-set", cmdHook, 0],
173 ["hook-break-clear", cmdHook, 0],
174 ["hook-debug-stop", cmdHook, 0],
175 ["hook-debug-continue", cmdHook, 0],
176 ["hook-display-sourcetext", cmdHook, 0],
177 ["hook-display-sourcetext-soft", cmdHook, 0],
178 ["hook-eval-done", cmdHook, 0],
179 ["hook-fbreak-clear", cmdHook, 0],
180 ["hook-fbreak-set", cmdHook, 0],
181 ["hook-guess-complete", cmdHook, 0],
182 ["hook-transient-script", cmdHook, 0],
183 ["hook-script-manager-created", cmdHook, 0],
184 ["hook-script-manager-destroyed", cmdHook, 0],
185 ["hook-script-instance-created", cmdHook, 0],
186 ["hook-script-instance-sealed", cmdHook, 0],
187 ["hook-script-instance-destroyed", cmdHook, 0],
188 ["hook-session-display", cmdHook, 0],
189 ["hook-source-load-complete", cmdHook, 0],
190 ["hook-window-closed", cmdHook, 0],
191 ["hook-window-loaded", cmdHook, 0],
192 ["hook-window-opened", cmdHook, 0],
193 ["hook-window-resized", cmdHook, 0],
194 ["hook-window-unloaded", cmdHook, 0],
195 ["hook-venkman-exit", cmdHook, 0],
196 ["hook-venkman-query-exit", cmdHook, 0],
197 ["hook-venkman-started", cmdHook, 0]
200 cmdary.stringBundle = console.defaultBundle;
201 console.commandManager.defineCommands (cmdary);
203 console.commandManager.argTypes.__aliasTypes__ (["index", "breakpointIndex",
204 "lineNumber"], "int");
205 console.commandManager.argTypes.__aliasTypes__ (["windowFlags",
209 console.commandManager.argTypes.__aliasTypes__ (["deletePref"],
212 console.commandManager.installKeys(console.mainWindow.document,
213 console.commandManager.commands);
217 * Used as a callback for CommandRecord.getDocumentation() to format the command
218 * flags for the "Notes:" field.
220 function formatCommandFlags (f)
222 var ary = new Array();
224 ary.push(MSG_NOTE_CONSOLE);
225 if (f & CMD_NEED_STACK)
226 ary.push(MSG_NOTE_NEEDSTACK);
227 if (f & CMD_NO_STACK)
228 ary.push(MSG_NOTE_NOSTACK);
230 return ary.length ? ary.join ("\n") : MSG_VAL_NA;
233 function getToggle (toggle, currentState)
235 if (toggle == "toggle")
236 toggle = !currentState;
241 /*******************************************************************************
242 * Command implementations from here on down...
243 ******************************************************************************/
245 function cmdAboutMozilla ()
247 openTopWin ("about:mozilla");
250 function cmdBreak (e)
252 if (!("isInteractive" in e))
253 e.isInteractive = false;
257 /* if no input data, just list the breakpoints */
260 for (var b in console.breaks)
262 var brk = console.breaks[b];
263 display (getMsg(MSN_BP_LINE, [++i, brk.url, brk.lineNumber]));
267 display (MSG_NO_BREAKS_SET);
274 for (var url in console.scriptManagers)
276 var manager = console.scriptManagers[url];
278 if (url.search(e.urlPattern) != -1 &&
279 manager.isLineExecutable(e.lineNumber))
282 if (manager.hasBreakpoint (e.lineNumber))
284 feedback (e, getMsg(MSN_BP_EXISTS, [url, e.lineNumber]));
288 var props = e.properties;
293 fbreak = getFutureBreakpoint(url, e.lineNumber);
296 dispatch ("fbreak", { isInteractive: e.isInteractive,
298 lineNumber: e.lineNumber,
300 fbreak = getFutureBreakpoint(url, e.lineNumber);
301 // hard breakpoint properties will be inherited
305 console.scriptManagers[url].setBreakpoint (e.lineNumber, fbreak,
307 feedback (e, getMsg(MSN_BP_CREATED, [url, e.lineNumber]));
314 feedback (e, getMsg(MSN_ERR_BP_NOLINE, [e.urlPattern, e.lineNumber]),
319 function cmdBreakProps (e)
321 if ("propsWindow" in e.breakWrapper)
323 e.breakWrapper.propsWindow.focus();
327 e.breakWrapper.propsWindow =
328 openDialog ("chrome://venkman/content/venkman-bpprops.xul", "",
329 "chrome,extrachrome,menubar,resizable", e.breakWrapper);
332 function cmdChangeContainer(e)
334 if (!(e.viewId in console.views))
336 display(getMsg(MSN_ERR_NO_SUCH_VIEW, e.viewId), MT_ERROR);
340 var view = console.views[e.viewId];
342 if (!view.currentContent)
344 display(getMsg(MSN_ERR_INVALID_PARAM, ["<view-id>", e.viewId]),
349 e.newType = e.newType.toLowerCase();
351 if (e.newType.search(/^(horizontal|vertical|tab)$/) != 0)
353 display(getMsg(MSN_ERR_INVALID_PARAM, ["<new-type>", e.newType]),
358 console.viewManager.changeContainer(view.currentContent.parentNode,
362 function cmdChangeValue(e)
364 var obj = e.parentValue.getWrappedValue();
370 var current = obj[e.propertyName];
371 if (typeof current == "string")
372 current = current.quote();
373 else if (typeof current == "object")
376 current = String(current);
381 var expr = prompt(getMsg(MSN_ENTER_EXPRESSION, e.propertyName),
383 if (expr == null || expr == "")
388 if ("frames" in console)
390 e.newValue = evalInTargetScope(expr, true);
391 e.newValue = e.newValue.getWrappedValue();
395 var parent = e.parentValue.jsParent.getWrappedValue();
396 e.newValue = eval(expr, parent);
402 if (ex instanceof jsdIValue)
403 alert (String(ex.getWrappedValue));
412 obj[e.propertyName] = e.newValue;
413 dispatch ("hook-eval-done");
416 function cmdChromeFilter(e)
418 const FLAGS = SCRIPT_NODEBUG | SCRIPT_NOPROFILE;
420 function setFlag (scriptWrapper)
422 if (!scriptWrapper.jsdScript.isValid)
427 scriptWrapper.lastFlags = scriptWrapper.jsdScript.flags;
428 scriptWrapper.jsdScript.flags |= FLAGS;
432 if ("lastFlags" in scriptWrapper)
434 scriptWrapper.jsdScript.flags = scriptWrapper.lastFlags;
435 delete scriptWrapper.lastFlags;
437 else if (isURLVenkman(scriptWrapper.jsdScript.fileName))
439 scriptWrapper.jsdScript.flags |= FLAGS;
443 scriptWrapper.jsdScript.flags &= ~(FLAGS);
447 if (scriptWrapper.jsdScript.flags & SCRIPT_NODEBUG)
448 ++scriptWrapper.scriptInstance.disabledScripts;
451 var currentState = console.prefs["enableChromeFilter"];
453 if (e.toggle != null)
455 currentState = console.prefs["enableChromeFilter"];
456 e.toggle = getToggle (e.toggle, currentState);
457 console.prefs["enableChromeFilter"] = e.toggle;
460 if (e.toggle != currentState)
462 for (var url in console.scriptManagers)
464 if (url.search (/^chrome:/) == -1 &&
465 (!("componentPath" in console) ||
466 url.indexOf(console.componentPath) == -1))
471 //dd ("setting chrome filter " + e.toggle + " for " + url);
473 var mgr = console.scriptManagers[url];
476 mgr.lastDisableTransients = mgr.disableTransients;
477 mgr.disableTransients = true;
481 if ("lastDisableTransients" in mgr)
483 mgr.disableTransients = mgr.lastDisableTransients;
484 delete mgr.lastDisableTransients;
488 mgr.disableTransients = false;
492 for (var i in mgr.instances)
494 var instance = mgr.instances[i];
495 instance.disabledScripts = 0;
496 if (instance.topLevel)
497 setFlag (instance.topLevel);
499 for (var f in instance.functions)
500 setFlag(instance.functions[f]);
506 feedback (e, getMsg(MSN_CHROME_FILTER,
507 currentState ? MSG_VAL_ON : MSG_VAL_OFF));
510 function cmdClear (e)
514 for (var b in console.breaks)
516 var brk = console.breaks[b];
517 if ((!e.lineNumber ||
518 "lineNumber" in brk && e.lineNumber == brk.lineNumber) &&
519 brk.scriptWrapper.jsdScript.fileName.search(e.urlPattern) != -1)
522 brk.scriptWrapper.clearBreakpoint(brk.pc);
523 feedback (e, getMsg(MSN_BP_CLEARED,
524 [brk.scriptWrapper.jsdScript.fileName,
531 feedback (e, getMsg(MSN_ERR_BP_NODICE, [e.urlPattern, e.lineNumber]),
536 function cmdClearAll (e)
538 if (!("isInteractive" in e))
539 e.isInteractive = false;
541 var breakWrapperList = new Array()
542 for (var i in console.breaks)
543 breakWrapperList.push (console.breaks[i]);
545 if (breakWrapperList.length)
547 dispatch ("clear-break", { isInteractive: e.isInteractive,
548 breakWrapper: breakWrapperList[0],
549 breakWrapperList: breakWrapperList });
553 function cmdClearBreak (e)
555 if (!("isInteractive" in e))
556 e.isInteractive = false;
558 function clear (wrapper)
560 if (wrapper instanceof BreakInstance)
562 wrapper.scriptWrapper.clearBreakpoint(wrapper.pc);
564 else if (wrapper instanceof FutureBreakpoint)
566 for (var b in wrapper.childrenBP)
567 clear (wrapper.childrenBP[b]);
571 if ("breakWrapperList" in e)
573 for (var i = 0; i < e.breakWrapperList.length; ++i)
574 clear(e.breakWrapperList[i]);
578 clear (e.breakWrapper);
582 function cmdClearFBreak (e)
584 if (!("isInteractive" in e))
585 e.isInteractive = false;
587 function clear (wrapper)
589 if (wrapper instanceof FutureBreakpoint)
592 isInteractive: e.isInteractive,
593 urlPattern: wrapper.url,
594 lineNumber: wrapper.lineNumber
597 dispatch ("fclear", params);
599 else if (wrapper instanceof BreakInstance && wrapper.parentBP)
601 clear (wrapper.parentBP);
605 if ("breakWrapperList" in e)
607 for (var i = 0; i < e.breakWrapperList.length; ++i)
608 clear(e.breakWrapperList[i]);
612 clear (e.breakWrapper);
616 function cmdClearProfile (e)
618 if ("scriptRecList" in e)
620 for (var i = 0; i < e.scriptRecList.length; ++i)
621 e.scriptRecList[i].script.clearProfileData();
623 else if ("scriptRec" in e)
625 e.scriptRec.script.clearProfileData();
629 console.jsds.clearProfileData();
632 feedback (e, MSG_PROFILE_CLEARED);
635 function cmdClearInstance (e)
637 if ("scriptInstanceList" in e)
639 for (var i = 0; i < e.scriptInstanceList.length; ++i)
640 cmdClearInstance ({ scriptInstance: e.scriptInstanceList[i] });
645 if (e.scriptInstance.topLevel)
646 e.scriptInstance.topLevel.clearBreakpoints();
648 for (var w in e.scriptInstance.functions)
649 e.scriptInstance.functions[w].clearBreakpoints();
654 function cmdClearScript (e)
658 if ("scriptWrapperList" in e)
660 for (i = 0; i < e.scriptWrapperList.length; ++i)
661 cmdClearScript ({scriptWrapper: e.scriptWrapperList[i]});
665 e.scriptWrapper.clearBreakpoints();
672 if ("sourceWindow" in e)
673 e.sourceWindow.close();
678 function cmdCommands (e)
680 display (getMsg(MSN_TIP1_HELP,
681 console.prefs["sessionView.requireSlash"] ? "/" : ""));
682 display (MSG_TIP2_HELP);
684 var names = console.commandManager.listNames(e.pattern, CMD_CONSOLE);
687 display (getMsg(MSN_NO_CMDMATCH, e.pattern), MT_ERROR);
691 names = names.join(MSG_COMMASP);
694 display (getMsg(MSN_CMDMATCH, [e.pattern, "[" + names + "]"]));
696 display (getMsg(MSN_CMDMATCH_ALL, "[" + names + "]"));
702 disableDebugCommands();
703 console.jsds.exitNestedEventLoop();
706 function cmdDoCommand(e)
708 if (e.cmdName == "cmd_mozillaPrefs")
710 goPreferences('navigator',
711 'chrome://communicator/content/pref/pref-navigator.xul',
716 doCommand(e.cmdName);
720 function cmdEMode (e)
724 e.mode = e.mode.toLowerCase();
726 if (e.mode == "cycle")
728 switch (console.errorMode)
745 console.errorMode = EMODE_IGNORE;
748 console.errorMode = EMODE_TRACE;
751 console.errorMode = EMODE_BREAK;
754 display (getMsg(MSN_ERR_INVALID_PARAM, ["mode", e.mode]),
759 console.prefs["lastErrorMode"] = e.mode;
762 switch (console.errorMode)
765 feedback (e, MSG_EMODE_IGNORE);
768 feedback (e, MSG_EMODE_TRACE);
771 feedback (e, MSG_EMODE_BREAK);
784 if (!("currentEvalObject" in console))
786 display (MSG_ERR_NO_EVAL_OBJECT, MT_ERROR);
790 display(getMsg(MSN_EVAL_IN, [leftPadString(console.evalCount, 3, "0"),
794 if (console.currentEvalObject instanceof jsdIStackFrame)
796 rv = evalInTargetScope (e.expression);
797 if (typeof rv != "undefined")
804 display (getMsg(MSN_FMT_TMP_ASSIGN, [l, formatValue (rv)]),
808 dd ("evalInTargetScope returned null");
814 var jsdValue = console.jsds.wrapValue (console.currentEvalObject);
815 if (jsdValue.jsParent)
816 parent = jsdValue.jsParent.getWrappedValue();
818 parent = console.currentEvalObject;
819 if ("location" in parent)
820 urlFile = getFileFromPath(parent.location.href);
822 urlFile = MSG_VAL_UNKNOWN;
826 rv = console.doEval.apply(console.currentEvalObject,
827 [e.expression, parent]);
828 display (String(rv), MT_FEVAL_OUT);
832 display (formatException(ex), MT_ERROR);
836 dispatch ("hook-eval-done");
840 function cmdEvald (e)
842 display (e.expression, MT_EVAL_IN);
843 var rv = evalInDebuggerScope (e.expression);
844 if (typeof rv != "undefined")
845 display (String(rv), MT_EVAL_OUT);
847 dispatch ("hook-eval-done");
851 function cmdFBreak(e)
855 /* if no input data, just list the breakpoints */
858 for (var f in console.fbreaks)
860 var brk = console.fbreaks[f];
861 display (getMsg(MSN_FBP_LINE, [++i, brk.url, brk.lineNumber]));
865 display (MSG_NO_FBREAKS_SET);
871 var fbreak = setFutureBreakpoint (e.urlPattern, e.lineNumber,
875 feedback (e, getMsg(MSN_FBP_CREATED, [e.urlPattern, e.lineNumber]));
879 feedback (e, getMsg(MSN_FBP_EXISTS, [e.urlPattern, e.lineNumber]),
886 function cmdFinish (e)
888 if (console.frames.length == 1)
891 console._stepOverDepth = console.frames.length - 1;
893 console.jsds.functionHook = console.callHook;
894 disableDebugCommands()
895 console.jsds.exitNestedEventLoop();
899 function cmdFindBp (e)
901 if ("scriptWrapper" in e.breakpoint)
903 dispatch ("find-script",
904 { scriptWrapper: e.breakpoint.scriptWrapper,
905 targetPc: e.breakpoint.pc });
909 dispatch ("find-url", {url: e.breakpoint.url,
910 rangeStart: e.breakpoint.lineNumber,
911 rangeEnd: e.breakpoint.lineNumber});
915 function cmdFindCreatorOrCtor (e)
917 var objVal = e.jsdValue.objectValue;
920 display (MSG_NOT_AN_OBJECT, MT_ERROR);
924 var name = e.command.name;
927 if (name == "find-creator")
929 url = objVal.creatorURL;
930 line = objVal.creatorLine;
934 url = objVal.constructorURL;
935 line = objVal.constructorLine;
938 return dispatch ("find-url",
939 {url: url, rangeStart: line, rangeEnd: line});
942 function cmdFindFile (e)
944 if (!e.fileName || e.fileName == "?")
946 var rv = pickOpen(MSG_OPEN_FILE, "$all");
947 if (rv.reason == PICK_CANCEL)
949 e.fileName = rv.file;
952 return dispatch ("find-url", {url: getURLSpecFromFile (e.fileName)});
955 function cmdFindFrame (e)
957 var jsdFrame = console.frames[e.frameIndex];
959 if ("isInteractive" in e && e.isInteractive)
960 displayFrame (jsdFrame, e.frameIndex, true);
962 if (jsdFrame.isNative)
965 var scriptWrapper = console.scriptWrappers[jsdFrame.script.tag]
966 return dispatch ("find-script",
967 { scriptWrapper: scriptWrapper, targetPc: jsdFrame.pc });
970 function cmdFindScript (e)
972 var jsdScript = e.scriptWrapper.jsdScript;
976 if (console.prefs["prettyprint"] && jsdScript.isValid)
978 if (e.targetPc != null)
979 targetLine = jsdScript.pcToLine(e.targetPc, PCMAP_PRETTYPRINT);
981 console.currentDetails = e.scriptWrapper;
984 sourceText: e.scriptWrapper.sourceText,
987 targetLine: targetLine,
988 details: e.scriptWrapper
990 dispatch ("hook-display-sourcetext-soft", params);
991 rv = jsdScript.fileName;
995 if (e.targetPc != null && jsdScript.isValid)
996 targetLine = jsdScript.pcToLine(e.targetPc, PCMAP_SOURCETEXT);
998 targetLine = jsdScript.baseLineNumber;
1001 sourceText: e.scriptWrapper.scriptInstance.sourceText,
1002 rangeStart: jsdScript.baseLineNumber,
1003 rangeEnd: jsdScript.baseLineNumber +
1004 jsdScript.lineExtent - 1,
1005 targetLine: targetLine,
1006 details: e.scriptWrapper
1008 rv = dispatch("find-sourcetext-soft", params);
1014 function cmdFindScriptInstance (e)
1016 var params = Clone(e);
1017 params.sourceText = e.scriptInstance.sourceText;
1018 dispatch ("find-sourcetext", params);
1021 function cmdFindSourceText (e)
1025 if (status != Components.results.NS_OK)
1027 display (getMsg (MSN_ERR_SOURCE_LOAD_FAILED,
1028 [e.sourceText.url, status], MT_ERROR));
1033 sourceText: e.sourceText,
1034 rangeStart: e.rangeStart,
1035 rangeEnd: e.rangeEnd,
1036 targetLine: (e.targetLine != null) ? e.targetLine : e.rangeStart,
1040 if (e.command.name.indexOf("soft") != -1)
1041 dispatch ("hook-display-sourcetext-soft", params);
1043 dispatch ("hook-display-sourcetext", params);
1046 console.currentSourceText = e.sourceText;
1047 console.currentDetails = e.details;
1049 if (!e.sourceText || e.sourceText.isLoaded)
1050 cb(Components.results.NS_OK);
1052 e.sourceText.loadSource(cb);
1055 function cmdFindURL (e)
1059 dispatch ("find-sourcetext", { sourceText: null });
1065 if (e.url.indexOf("x-jsd:") == 0)
1070 sourceText = console.sourceText;
1074 display (getMsg(MSN_ERR_INVALID_PARAM, ["url", e.url]),
1079 else if (e.url in console.scriptManagers)
1081 sourceText = console.scriptManagers[e.url].sourceText;
1083 else if (e.url in console.files)
1085 sourceText = console.files[e.url];
1089 sourceText = console.files[e.url] = new SourceText (e.url);
1093 sourceText: sourceText,
1094 rangeStart: e.rangeStart,
1095 rangeEnd: e.rangeEnd,
1096 targetLine: e.targetLine,
1100 if (e.command.name.indexOf("soft") == -1)
1101 dispatch ("find-sourcetext", params);
1103 dispatch ("find-sourcetext-soft", params);
1106 function cmdFClear (e)
1110 for (var b in console.fbreaks)
1112 var brk = console.fbreaks[b];
1113 if (!e.lineNumber || e.lineNumber == brk.lineNumber &&
1114 brk.url.search(e.urlPattern) != -1)
1117 clearFutureBreakpoint (brk.url, e.lineNumber);
1118 feedback (e, getMsg(MSN_FBP_CLEARED, [brk.url, e.lineNumber]));
1124 feedback (e, getMsg(MSN_ERR_BP_NODICE, [e.urlPattern, e.lineNumber]),
1129 function cmdFClearAll (e)
1131 if (!("isInteractive" in e))
1132 e.isInteractive = false;
1134 var breakWrapperList = new Array();
1136 for (var i in console.fbreaks)
1137 breakWrapperList.push (console.fbreaks[i]);
1139 if (breakWrapperList.length)
1141 dispatch ("clear-fbreak", { isInteractive: e.isInteractive,
1142 breakWrapper: breakWrapperList[0],
1143 breakWrapperList: breakWrapperList });
1147 function cmdFrame (e)
1149 if (e.frameIndex != null)
1151 if (e.frameIndex < 0 || e.frameIndex >= console.frames.length)
1153 display (getMsg(MSN_ERR_INVALID_PARAM,
1154 ["frameIndex", e.frameIndex]),
1158 setCurrentFrameByIndex(e.frameIndex);
1162 e.frameIndex = getCurrentFrameIndex();
1165 if (!("isInteractive" in e))
1166 e.isInteractive = false;
1168 dispatch ("find-frame", { frameIndex: e.frameIndex,
1169 isInteractive: e.isInteractive });
1178 function cmdHelp (e)
1183 openTopWin ("x-jsd:help", "venkman-help");
1188 ary = console.commandManager.list (e.pattern, CMD_CONSOLE);
1190 if (ary.length == 0)
1192 display (getMsg(MSN_ERR_NO_COMMAND, e.pattern), MT_ERROR);
1198 display (getMsg(MSN_FMT_USAGE, [ary[i].name, ary[i].usage]),
1200 display (ary[i].help, MT_HELP);
1209 /* empty function used for "hook" commands. */
1212 function cmdInspect(e)
1215 if ("jsdValue" in e)
1217 key = e.propertyName;
1218 value = e.jsdValue.getWrappedValue();
1220 else if ("expression" in e)
1223 value = evalInTargetScope(e.expression, true).getWrappedValue();
1225 if (!value || !isDOMThing(value))
1227 display(getMsg(MSN_ERR_NOT_A_DOM_NODE, key), MT_ERROR);
1230 window.openDialog("chrome://inspector/content/", "_blank",
1231 "chrome,all,dialog=no", value);
1234 function cmdLoadd (e)
1238 if (!("_loader" in console))
1240 const LOADER_CTRID = "@mozilla.org/moz/jssubscript-loader;1";
1241 const mozIJSSubScriptLoader =
1242 Components.interfaces.mozIJSSubScriptLoader;
1245 if ((cls = Components.classes[LOADER_CTRID]))
1246 console._loader = cls.getService(mozIJSSubScriptLoader);
1249 var obj = ("scope" in e) ? e.scope : null;
1253 var rv = rvStr = console._loader.loadSubScript(e.url, obj);
1254 if (typeof rv == "function")
1255 rvStr = MSG_TYPE_FUNCTION;
1256 feedback(e, getMsg(MSN_SUBSCRIPT_LOADED, [e.url, rvStr]), MT_INFO);
1261 display (getMsg(MSN_ERR_SCRIPTLOAD, e.url));
1262 display (formatException(ex), MT_ERROR);
1268 function cmdMoveView (e)
1270 if (!e.viewId || !(e.viewId in console.views))
1272 display (getMsg(MSN_ERR_INVALID_PARAM, ["viewId", e.viewId]), MT_ERROR);
1276 var parsedLocation = console.viewManager.parseLocation (e.locationUrl);
1277 if (!parsedLocation)
1279 display (getMsg(MSN_ERR_INVALID_PARAM, ["locationURL", e.locationURL]),
1284 console.viewManager.moveView (parsedLocation, e.viewId);
1287 function cmdMozillaHelp ()
1289 if (typeof openHelp == "undefined")
1290 toOpenWindowByType('mozilla:help', 'chrome://help/content/help.xul');
1297 // we don't setStopState(false) here because if the line we're at
1298 // doesn't call out to a function, /next is the same as /step.
1299 console._stepOverDepth = console.frames.length;
1301 console.jsds.functionHook = console.callHook;
1305 function cmdOpenDialog (e)
1308 e.windowFlags = "chrome,menubar,toolbar,resizable,dialog=no";
1310 return openDialog (e.url, e.windowName, e.windowFlags);
1313 function cmdOpenURL (e)
1315 var url = prompt (MSG_OPEN_URL, "http://");
1316 if (url && url != "http://")
1317 return dispatch ("find-url", { url: url });
1322 function cmdPPrint (e)
1326 if (e.toggle != null)
1328 e.toggle = getToggle (e.toggle, console.prefs["prettyprint"]);
1329 console.prefs["prettyprint"] = e.toggle;
1331 var tb = document.getElementById("maintoolbar:toggle-pprint");
1334 tb.setAttribute("state", "true");
1338 tb.removeAttribute("state");
1341 if ("currentDetails" in console &&
1342 console.currentDetails instanceof ScriptWrapper)
1344 dispatch ("find-script", { scriptWrapper: console.currentDetails });
1348 feedback (e, getMsg(MSN_FMT_PPRINT, console.prefs["prettyprint"] ?
1349 MSG_VAL_ON : MSG_VAL_OFF));
1354 function cmdPref (e)
1356 if (e.prefName && e.prefName[0] == "-")
1358 e.prefName = e.prefName.substr(1);
1359 e.deletePref = true;
1366 console.prefManager.prefBranch.clearUserPref(e.prefName);
1367 console.prefManager.dirtyPrefs[e.prefName] = true;
1368 console.prefManager.prefService.savePrefFile(null);
1372 // ignore exception generated by clear of nonexistant pref
1373 if (!("result" in ex) ||
1374 ex.result != Components.results.NS_ERROR_UNEXPECTED)
1380 var prefValue = console.prefs[e.prefName];
1381 feedback (e, getMsg(MSN_FMT_PREFVALUE,
1382 [e.prefName, console.prefs[e.prefName]]));
1388 var type = typeof console.prefs[e.prefName];
1392 e.prefValue = Number(e.prefValue);
1395 e.prefValue = (e.prefValue.toLowerCase() == "true");
1400 e.prefValue = String(e.prefValue);
1404 console.prefs[e.prefName] = e.prefValue;
1405 feedback (e, getMsg(MSN_FMT_PREFVALUE, [e.prefName, e.prefValue]));
1409 var ary = console.prefManager.listPrefs(e.prefName);
1410 if (ary.length == 0)
1412 display (getMsg(MSN_ERR_UNKNOWN_PREF, [e.prefName]),
1417 for (var i = 0; i < ary.length; ++i)
1419 feedback (e, getMsg(MSN_FMT_PREFVALUE,
1420 [ary[i], console.prefs[ary[i]]]));
1427 function cmdProfile(e)
1429 var currentState = console.jsds.flags & COLLECT_PROFILE_DATA;
1431 if (e.toggle != null)
1433 e.toggle = getToggle (e.toggle, currentState);
1434 setProfileState(e.toggle);
1438 e.toggle = currentState;
1441 feedback (e, getMsg(MSN_PROFILE_STATE,
1442 [e.toggle ? MSG_VAL_ON : MSG_VAL_OFF]));
1445 function cmdProps (e)
1448 var debuggerScope = (e.command.name == "propsd");
1452 v = console.jsds.wrapValue(evalInDebuggerScope (e.expression));
1456 if (!("currentEvalObject" in console))
1458 display (MSG_ERR_NO_EVAL_OBJECT, MT_ERROR);
1462 if (console.currentEvalObject instanceof jsdIStackFrame)
1464 v = evalInTargetScope (e.expression);
1468 v = console.doEval.apply(console.currentEvalObject,
1469 [e.expression, parent]);
1470 v = console.jsds.wrapValue(v);
1474 if (!(v instanceof jsdIValue) || v.jsType != jsdIValue.TYPE_OBJECT)
1476 var str = (v instanceof jsdIValue) ? formatValue(v) : String(v)
1477 display (getMsg(MSN_ERR_INVALID_PARAM, [MSG_VAL_EXPRESSION, str]),
1482 display (getMsg(debuggerScope ? MSN_PROPSD_HEADER : MSN_PROPS_HEADER,
1484 displayProperties(v);
1490 goQuitApplication();
1493 function cmdRestoreLayout (e)
1497 var list = console.prefManager.listPrefs("layoutState.");
1498 for (var i = 0; i < list.length; ++i)
1499 list[i] = list[i].substr(12);
1500 list.push("factory");
1501 display (getMsg(MSN_LAYOUT_LIST, list.sort().join(MSG_COMMASP)));
1506 e.name = e.name.toLowerCase();
1507 if (e.name == "factory")
1509 layout = DEFAULT_VURLS;
1513 var prefName = "layoutState." + e.name;
1514 if (!(prefName in console.prefs))
1516 display (getMsg(MSN_ERR_INVALID_PARAM, ["name", e.name]), MT_ERROR);
1521 layout = console.prefs[prefName];
1523 layout = DEFAULT_VURLS;
1527 console.viewManager.destroyWindows();
1528 console.viewManager.reconstituteVURLs (layout.split (/\s*;\s*/));
1531 function cmdRestoreSettings(e)
1533 if (!e.settingsFile || e.settingsFile == "?")
1535 var rv = pickOpen(MSG_OPEN_FILE, "*.js");
1536 if (rv.reason == PICK_CANCEL)
1538 e.settingsFile = getURLSpecFromFile(rv.file);
1540 else if (e.settingsFile.indexOf("file:") != 0)
1542 e.settingsFile = getURLSpecFromFile(e.settingsFile);
1545 dispatch("loadd", { url: e.settingsFile });
1548 function cmdReleaseNotes (e)
1550 openTopWin(MSG_RELEASE_URL);
1553 function cmdRunTo (e)
1555 if (!e.scriptWrapper.jsdScript.isValid)
1558 var breakpoint = e.scriptWrapper.setBreakpoint(e.pc);
1560 breakpoint.oneTime = true;
1564 function cmdSaveBreakpoints(e)
1566 var needClose = false;
1567 var file = e.settingsFile;
1569 if (!file || file == "?")
1571 var rv = pickSaveAs(MSG_SAVE_FILE, "*.js");
1572 if (rv.reason == PICK_CANCEL)
1574 e.settingsFile = file = fopen(rv.file, ">");
1577 else if (typeof file == "string")
1579 e.settingsFile = file = fopen(file, ">");
1586 file.write ("\n//Breakpoint settings start...\n");
1588 for (i in console.fbreaks)
1592 fbp = console.fbreaks[i];
1594 urlPattern: fbp.url,
1595 lineNumber: fbp.lineNumber,
1596 properties: fbp.getProperties()
1599 if (keys(fbp.childrenBP).length)
1603 file.write ("var fbreak;\n\n");
1606 file.write("fbreak = ");
1609 file.write("dispatch('fbreak', " + params.toSource() + ");\n\n");
1611 for (i in fbp.childrenBP)
1613 bp = fbp.childrenBP[i];
1615 file.write("dispatch('break', {" +
1616 "urlPattern:" + bp.url.quote() + ", " +
1617 "lineNumber:" + bp.lineNumber + ", " +
1619 "properties:" + bp.getProperties().toSource() +
1626 for (i in console.breaks)
1628 bp = console.breaks[i];
1633 lineNumber: bp.lineNumber,
1634 properties: bp.getProperties()
1637 file.write("dispatch('break', " + params.toSource() + ");\n");
1641 file.write (MSG_BREAKPOINTS_RESTORED.quote() + ";\n");
1647 function cmdSaveLayout(e)
1651 var list = console.prefManager.listPrefs("layoutState.");
1652 for (var i = 0; i < list.length; ++i)
1653 list[i] = list[i].substr(12);
1654 list.push("factory");
1655 display (getMsg(MSN_LAYOUT_LIST, list.sort().join(MSG_COMMASP)));
1659 e.name = e.name.toLowerCase();
1660 if (e.name == "factory")
1662 display (getMsg(MSN_ERR_INVALID_PARAM, ["name", e.name]), MT_ERROR);
1666 var ary = console.viewManager.getLayoutState ();
1667 var prefName = "layoutState." + e.name;
1668 console.prefManager.addPref(prefName, "");
1669 console.prefs[prefName] = ary.join ("; ");
1672 function cmdSaveProfile (e)
1674 function onComplete (i)
1676 var msg = getMsg(MSN_PROFILE_SAVED, getURLSpecFromFile(file.localFile));
1678 console.status = msg;
1682 var templatePfx = "profile.template.";
1686 if (!e.targetFile || e.targetFile == "?")
1688 var list = console.prefManager.listPrefs(templatePfx);
1690 for (i = 0; i < list.length; ++i)
1692 ext = list[i].substr(templatePfx.length);
1693 if (list[i].search(/html|htm|xml|txt/i) == -1)
1694 extList += "*." + ext + " ";
1696 var rv = pickSaveAs(MSG_SAVE_PROFILE, "$html $xml $text " +
1698 if (rv.reason == PICK_CANCEL)
1700 e.targetFile = rv.file;
1703 var file = fopen (e.targetFile, ">");
1705 var ary = file.localFile.path.match(/\.([^.]+)$/);
1708 ext = ary[1].toLowerCase();
1712 var rv = writeProfile(e, file, ext, onComplete);
1714 return rv.localFile;
1717 function cmdSaveSettings(e)
1719 if (!e.settingsFile || e.settingsFile == "?")
1721 var rv = pickSaveAs(MSG_SAVE_FILE, "*.js");
1722 if (rv.reason == PICK_CANCEL)
1724 e.settingsFile = fopen(rv.file, ">");
1726 else if (typeof e.settingsFile == "string")
1728 e.settingsFile = fopen(e.settingsFile, ">");
1731 dispatch ("save-breakpoints", { settingsFile: e.settingsFile });
1732 dispatch ("save-watches", { settingsFile: e.settingsFile });
1734 e.settingsFile.write("\n" + MSG_SETTINGS_RESTORED.quote() + ";\n");
1736 e.settingsFile.close();
1739 function cmdScanSource (e)
1741 e.scriptInstance.scanForMetaComments();
1744 function cmdScope ()
1746 if (getCurrentFrame().scope.propertyCount == 0)
1747 display (getMsg (MSN_NO_PROPERTIES, MSG_VAL_SCOPE));
1749 displayProperties (getCurrentFrame().scope);
1754 function cmdShowProfile(e)
1756 function onComplete(i)
1758 // We need a window since the current browserwindow could be disabled
1759 // by us if a script in it is stopped, so we can't do anything there.
1760 var w = window.open("about:blank");
1761 w.wrappedJSObject.document.open();
1762 w.wrappedJSObject.document.write(fileString.str);
1763 w.wrappedJSObject.document.close();
1766 // In order not to create files, we hack in a small wrapper around a big string:
1769 write: function _write(_str) { this.str += _str; }
1772 writeProfile(e, fileString, "html", onComplete);
1775 function writeProfile(e, file, type, onComplete)
1777 // Get us a template
1781 var templatePfx = "profile.template.";
1782 var templateName = templatePfx + type;
1784 if (templateName in console.prefs)
1785 templateFile = console.prefs[templateName];
1787 templateFile = console.prefs[templatePfx + "txt"];
1789 var reportTemplate = console.profiler.loadTemplate(templateFile);
1791 // Get a list of scripts we profiled.
1792 var scriptInstanceList = new Array();
1794 if (!("urlList" in e) || e.urlList.length == 0)
1796 if ("url" in e && e.url)
1797 e.urlList = [e.url];
1799 e.urlList = keys(console.scriptManagers);
1802 e.urlList = e.urlList.sort();
1805 for (i = 0; i < e.urlList.length; ++i)
1807 var url = e.urlList[i];
1808 if (!ASSERT(url in console.scriptManagers, "url not loaded"))
1810 var manager = console.scriptManagers[url];
1811 for (j in manager.instances)
1812 scriptInstanceList.push(manager.instances[j]);
1816 if (("profile.ranges." + type) in console.prefs)
1817 rangeList = console.prefs["profile.ranges." + type].split(",");
1819 rangeList = console.prefs["profile.ranges.default"].split(",");
1821 var profileReport = new ProfileReport(reportTemplate, file, rangeList,
1822 scriptInstanceList);
1823 profileReport.onComplete = onComplete;
1825 console.profiler.generateReport(profileReport);
1830 function cmdThisExpr(e)
1832 if (e.expression == "debugger")
1834 rv = console.jsdConsole;
1836 else if (console.currentEvalObject instanceof jsdIStackFrame)
1838 rv = evalInTargetScope (e.expression);
1842 rv = console.doEval.apply(console.currentEvalObject,
1843 [e.expression, parent]);
1846 if (!(rv instanceof jsdIValue))
1847 rv = console.jsds.wrapValue(rv);
1849 if (rv.jsType != TYPE_OBJECT)
1851 display (MSG_ERR_THIS_NOT_OBJECT, MT_ERROR);
1855 dispatch ("set-eval-obj", { jsdValue: rv });
1856 dispatch ("hook-eval-done");
1860 function cmdToggleSomething (e)
1862 var ary = e.command.name.match (/(.*)-(on|off|toggle)$/);
1866 var newEvent = Clone(e);
1869 newEvent.toggle = true;
1870 else if (ary[2] == "off")
1871 newEvent.toggle = false;
1873 newEvent.toggle = "toggle";
1875 dispatch (ary[1], newEvent);
1878 function cmdSetEvalObj (e)
1880 if (!(e.jsdValue instanceof jsdIStackFrame))
1882 e.jsdValue = e.jsdValue.getWrappedValue();
1885 if (e.jsdValue == console.currentEvalObject)
1887 var frame = getCurrentFrame();
1891 e.jsdValue = console;
1894 console.currentEvalObject = e.jsdValue;
1897 function cmdSetScriptFlag (e)
1899 function setFlag (scriptWrapper)
1901 var jsdScript = scriptWrapper.jsdScript;
1903 if (!jsdScript.isValid)
1906 if (e.toggle == "toggle")
1908 jsdScript.flags ^= flag;
1909 if (flag == SCRIPT_NODEBUG)
1911 if (jsdScript.flags & flag)
1912 ++scriptWrapper.scriptInstance.disabledScripts;
1914 --scriptWrapper.scriptInstance.disabledScripts;
1919 jsdScript.flags |= flag;
1920 if (flag == SCRIPT_NODEBUG)
1921 ++scriptWrapper.scriptInstance.disabledScripts;
1925 jsdScript.flags &= ~flag;
1926 if (flag == SCRIPT_NODEBUG)
1927 --scriptWrapper.scriptInstance.disabledScripts;
1931 function setFlagInstance (scriptInstance)
1933 if (scriptInstance.topLevel)
1934 setFlag (scriptInstance.topLevel);
1936 for (var f in scriptInstance.functions)
1937 setFlag (scriptInstance.functions[f]);
1943 if (e.command.name.search(/^profile/) == 0)
1944 flag = SCRIPT_NOPROFILE;
1946 flag = SCRIPT_NODEBUG;
1948 if (e.command.name.search (/script$/) != -1)
1950 if ("scriptWrapperList" in e)
1952 for (i = 0; i < e.scriptWrapperList.length; ++i)
1953 setFlag(e.scriptWrapperList[i]);
1957 setFlag(e.scriptWrapper);
1962 if ("scriptInstanceList" in e)
1964 for (i = 0; i < e.scriptInstanceList.length; ++i)
1965 setFlagInstance(e.scriptInstanceList[i]);
1969 setFlagInstance(e.scriptInstance);
1974 function cmdSetTransientFlag (e)
1976 function setFlag (url)
1978 if (!(url in console.scriptManagers))
1981 var scriptManager = console.scriptManagers[url];
1982 if (e.toggle == "toggle")
1983 scriptManager.disableTransients = !scriptManager.disableTransients;
1985 scriptManager.disableTransients = e.toggle;
1990 for (var i = 0; i < e.urlList.length; ++i)
1991 setFlag (e.urlList[i]);
1999 function cmdStartupInit (e)
2001 dd ("startup-init " + e.toggle);
2003 if (e.toggle != null)
2005 e.toggle = getToggle (e.toggle, console.jsds.initAtStartup);
2006 console.jsds.initAtStartup = e.toggle;
2009 display (getMsg(MSN_IASMODE,
2010 console.jsds.initAtStartup ? MSG_VAL_ON : MSG_VAL_OFF));
2017 var topFrame = console.frames[0];
2018 console._stepPast = console.frames.length + topFrame.script.fileName;
2020 if (console.prefs["prettyprint"])
2022 console._stepPast +=
2023 topFrame.script.pcToLine(topFrame.pc, PCMAP_PRETTYPRINT);
2027 console._stepPast += topFrame.line;
2029 disableDebugCommands()
2030 console.jsds.exitNestedEventLoop();
2034 function cmdStop (e)
2036 if (console.jsds.interruptHook)
2037 setStopState(false);
2042 function cmdTMode (e)
2046 e.mode = e.mode.toLowerCase();
2048 if (e.mode == "cycle")
2050 switch (console.throwMode)
2064 switch (e.mode.toLowerCase())
2067 console.jsds.throwHook = null;
2068 console.throwMode = TMODE_IGNORE;
2071 console.jsds.throwHook = console.executionHook;
2072 console.throwMode = TMODE_TRACE;
2075 console.jsds.throwHook = console.executionHook;
2076 console.throwMode = TMODE_BREAK;
2079 display (getMsg(MSN_ERR_INVALID_PARAM, ["mode", e.mode]),
2084 console.prefs["lastThrowMode"] = e.mode;
2087 switch (console.throwMode)
2090 feedback (e, MSG_TMODE_IGNORE);
2093 feedback (e, MSG_TMODE_TRACE);
2096 feedback (e, MSG_TMODE_BREAK);
2103 function cmdToggleFloat (e)
2105 if (!e.viewId in console.views ||
2106 typeof console.views[e.viewId] != "object")
2108 display (getMsg(MSN_ERR_NO_SUCH_VIEW, e.viewId), MT_ERROR);
2113 var view = console.views[e.viewId];
2114 var parsedLocation =
2115 console.viewManager.computeLocation(view.currentContent);
2117 if (parsedLocation.windowId == VMGR_MAINWINDOW)
2119 /* already in the main window, float the view. */
2120 locationUrl = VMGR_VURL_NEW
2124 /* already floated, put it back. */
2125 if ("previousLocation" in view)
2126 locationUrl = view.previousLocation;
2128 locationUrl = VMGR_VURL_GUTTER;
2131 dispatch ("move-view", { viewId: e.viewId, locationUrl: locationUrl });
2134 function cmdTogglePref (e)
2136 var state = !console.prefs[e.prefName];
2137 console.prefs[e.prefName] = state;
2138 feedback (e, getMsg (MSN_FMT_PREFVALUE,
2139 [e.prefName, state ? MSG_VAL_ON : MSG_VAL_OFF]));
2142 function cmdToggleView (e)
2144 if (!e.viewId in console.views || typeof console.views[e.viewId] != "object")
2146 display (getMsg(MSN_ERR_NO_SUCH_VIEW, e.viewId), MT_ERROR);
2150 var view = console.views[e.viewId];
2153 if ("currentContent" in view)
2155 url = VMGR_VURL_HIDDEN;
2159 if ("previousLocation" in view)
2160 url = view.previousLocation;
2162 url = VMGR_VURL_GUTTER;
2165 console.viewManager.moveViewURL (url, e.viewId);
2168 function cmdVersion ()
2170 display(MSG_HELLO, MT_HELLO);
2171 display(getMsg(MSN_VERSION, __vnk_version + __vnk_versionSuffix), MT_HELLO);
2174 function cmdWhere ()