Index: mozilla/extensions/venkman/resources/content/venkman-commands.js =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/content/venkman-commands.js,v retrieving revision 1.41 diff -p -u -6 -r1.41 venkman-commands.js --- mozilla/extensions/venkman/resources/content/venkman-commands.js 7 Nov 2005 23:58:46 -0000 1.41 +++ mozilla/extensions/venkman/resources/content/venkman-commands.js 24 Jun 2006 23:47:07 -0000 @@ -105,12 +105,13 @@ function initCommands() ["find-url-soft", cmdFindURL, 0], ["finish", cmdFinish, CMD_CONSOLE | CMD_NEED_STACK], ["focus-input", cmdHook, 0], ["frame", cmdFrame, CMD_CONSOLE | CMD_NEED_STACK], ["gc", cmdGC, CMD_CONSOLE], ["help", cmdHelp, CMD_CONSOLE], + ["inspect", cmdInspect, CMD_CONSOLE], ["loadd", cmdLoadd, CMD_CONSOLE], ["move-view", cmdMoveView, CMD_CONSOLE], ["mozilla-help", cmdMozillaHelp, 0], ["next", cmdNext, CMD_CONSOLE | CMD_NEED_STACK], ["open-dialog", cmdOpenDialog, CMD_CONSOLE], ["open-url", cmdOpenURL, 0], @@ -1203,12 +1204,34 @@ function cmdHelp (e) function cmdHook(e) { /* empty function used for "hook" commands. */ } +function cmdInspect(e) +{ + var key, value; + if ("jsdValue" in e) + { + key = e.propertyName; + value = e.jsdValue.getWrappedValue(); + } + else if ("expression" in e) + { + key = e.expression; + value = evalInTargetScope(e.expression, true).getWrappedValue(); + } + if (!value || !isDOMThing(value)) + { + display(getMsg(MSN_ERR_NOT_A_DOM_NODE, key), MT_ERROR); + return; + } + window.openDialog("chrome://inspector/content/", "_blank", + "chrome,all,dialog=no", value); +} + function cmdLoadd (e) { var ex; if (!("_loader" in console)) { Index: mozilla/extensions/venkman/resources/content/venkman-static.js =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/content/venkman-static.js,v retrieving revision 1.69 diff -p -u -6 -r1.69 venkman-static.js --- mozilla/extensions/venkman/resources/content/venkman-static.js 12 Apr 2006 23:23:06 -0000 1.69 +++ mozilla/extensions/venkman/resources/content/venkman-static.js 24 Jun 2006 23:47:08 -0000 @@ -128,12 +128,44 @@ function disableDebugCommands() cmds = console.commandManager.list ("", CMD_NO_STACK); for (i in cmds) cmds[i].enabled = true; } + +function isDOMIInstalled() +{ + const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1"; + const nsIIOService = Components.interfaces.nsIIOService; + const CHROMEREG_CTRID = "@mozilla.org/chrome/chrome-registry;1"; + const nsIChromeReg = Components.interfaces.nsIChromeRegistry; + + var iosvc = Components.classes[IOSERVICE_CTRID].getService(nsIIOService); + var uri = iosvc.newURI("chrome://inspector/content/inspector.xul", + null, null); + // Evil hack: check if the chrome registry knows about Inspector. + // If it does, it's installed, otherwise it isn't. + try + { + var cr = Components.classes[CHROMEREG_CTRID].getService(nsIChromeReg); + var realURI = cr.convertChromeURL(uri); + } + catch (ex) + { + return false; + } + return true; +} + +function isDOMThing(o) +{ + const nsIDOMNode = Components.interfaces.nsIDOMNode; + const nsIDOMDocument = Components.interfaces.nsIDOMDocument; + return (isinstance(o, nsIDOMNode) || isinstance(o, nsIDOMDocument)); +} + function isURLVenkman (url) { return (url.search (/^chrome:\/\/venkman/) == 0 && url.search (/test/) == -1); } Index: mozilla/extensions/venkman/resources/content/venkman-utils.js =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/content/venkman-utils.js,v retrieving revision 1.30 diff -p -u -6 -r1.30 venkman-utils.js --- mozilla/extensions/venkman/resources/content/venkman-utils.js 16 May 2006 19:28:32 -0000 1.30 +++ mozilla/extensions/venkman/resources/content/venkman-utils.js 24 Jun 2006 23:47:09 -0000 @@ -1025,6 +1025,18 @@ function makeExpression (items) for (var i = 1; i < items.length; i++) expression += escapeItem(items[i], false); return expression; } + +function isinstance(inst, base) +{ + /* Returns |true| if |inst| was constructed by |base|. Not 100% accurate, + * but plenty good enough for us. This is to work around the fix for bug + * 254067 which makes instanceof fail if the two sides are 'from' + * different windows (something we don't care about). + */ + return (inst && base && + ((inst instanceof base) || + (inst.constructor && (inst.constructor.name == base.name)))); +} Index: mozilla/extensions/venkman/resources/content/venkman-views.js =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/content/venkman-views.js,v retrieving revision 1.29 diff -p -u -6 -r1.29 venkman-views.js --- mozilla/extensions/venkman/resources/content/venkman-views.js 25 Mar 2006 22:03:44 -0000 1.29 +++ mozilla/extensions/venkman/resources/content/venkman-views.js 24 Jun 2006 23:47:11 -0000 @@ -543,12 +543,15 @@ function lv_init () checkedif: "has('jsdValue') && " + "cx.jsdValue.getWrappedValue() == " + "console.currentEvalObject", enabledif: "has('jsdValue') && " + "cx.jsdValue.jsType == TYPE_OBJECT"}], ["-"], + ["inspect", {visibleif: "isDOMIInstalled()", + enabledif: "has('jsdValue') && " + + "isDOMThing(cx.jsdValue.getWrappedValue())"}], ["find-creator", {enabledif: "cx.target instanceof ValueRecord && " + "cx.target.jsType == jsdIValue.TYPE_OBJECT && " + "cx.target.value.objectValue.creatorURL"}], ["find-ctor", {enabledif: "cx.target instanceof ValueRecord && " + @@ -4096,12 +4099,15 @@ function wv_init() checkedif: "has('jsdValue') && " + "cx.jsdValue.getWrappedValue() == " + "console.currentEvalObject", enabledif: "has('jsdValue') && " + "cx.jsdValue.jsType == TYPE_OBJECT"}], ["-"], + ["inspect", {visibleif: "isDOMIInstalled()", + enabledif: "has('jsdValue') && " + + "isDOMThing(cx.jsdValue.getWrappedValue())"}], ["find-creator", {enabledif: "cx.target instanceof ValueRecord && " + "cx.target.jsType == jsdIValue.TYPE_OBJECT && " + "cx.target.value.objectValue.creatorURL"}], ["find-ctor", {enabledif: "cx.target instanceof ValueRecord && " + Index: mozilla/extensions/venkman/resources/locale/en-US/venkman.properties =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/locale/en-US/venkman.properties,v retrieving revision 1.62 diff -p -u -6 -r1.62 venkman.properties --- mozilla/extensions/venkman/resources/locale/en-US/venkman.properties 6 Apr 2006 11:34:11 -0000 1.62 +++ mozilla/extensions/venkman/resources/locale/en-US/venkman.properties 24 Jun 2006 23:47:13 -0000 @@ -94,12 +94,13 @@ msn.err.startup = An exception o msn.err.cant.match = Error loading template: Can't match ``%1$S''. msg.err.internal.bpt = Internal error handling breakpoint. msn.err.internal.hook = Internal error processing hook ``%1$S''. msn.err.failure = Operation Failed: %1$S msn.err.no.section = Missing section before ``%1$S'' in <%2$S>. msn.err.no.template = No pref for template named ``%1$S''. +msn.err.not.a.dom.node = Expression ``%1$S'' is not a DOM Node. msn.err.internal.dispatch = Internal error dispatching command ``%1$S''. msn.err.source.load.failed = Error loading URL <%1$S>: %2$S. msn.err.no.such.container = No such container ``%1$S''. msg.err.condition.failed = Error evaluating breakpoint condition. msg.err.format.not.available = Source not available in requested format. msn.err.no.function = Line %1$S in <%2$S> is not part of an executable function. @@ -696,12 +697,16 @@ cmd.frame.help = Sets the current fram cmd.gc.help = Force the JavaScript garbage collector to run. This may force unloaded scripts to be removed from the Loaded Scripts view. cmd.help.label = &Command Reference cmd.help.params = [] cmd.help.help = Displays help on , which can be a full command name, or the first few characters of the command name. If matches more than one command, help on all matching commands will be displayed. If is not provided, a command reference will be loaded in a browser window. +cmd.inspect.label = &Inspect in DOM Inspector +cmd.inspect.params = [] +cmd.inspect.help = Inspects (the result of) the expression as in DOM inspector. + cmd.loadd.label = Load Script in Debugger Scope cmd.loadd.params = cmd.loadd.help = Executes the contents of the url specified by in the context of the debugger. Useful for loading debugger plugins. See also: The |initialScripts| pref. cmd.move-view.params = cmd.move-view.help = Moves the view associated with to the location specified by .