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 21 Jun 2006 20:57:58 -0000 @@ -131,12 +131,13 @@ function initCommands() ["save-breakpoints", cmdSaveBreakpoints, CMD_CONSOLE], ["save-layout", cmdSaveLayout, CMD_CONSOLE], ["save-profile", cmdSaveProfile, CMD_CONSOLE], ["save-settings", cmdSaveSettings, CMD_CONSOLE], ["scan-source", cmdScanSource, 0], ["scope", cmdScope, CMD_CONSOLE | CMD_NEED_STACK], + ["show-profile", cmdShowProfile, CMD_CONSOLE], ["this-expr", cmdThisExpr, CMD_CONSOLE], ["toggle-float", cmdToggleFloat, CMD_CONSOLE], ["toggle-view", cmdToggleView, CMD_CONSOLE], ["toggle-pref", cmdTogglePref, CMD_CONSOLE], ["startup-init", cmdStartupInit, CMD_CONSOLE], ["step", cmdStep, CMD_CONSOLE | CMD_NEED_STACK], @@ -1674,66 +1675,22 @@ function cmdSaveProfile (e) return null; e.targetFile = rv.file; } var file = fopen (e.targetFile, ">"); - var templateName; var ary = file.localFile.path.match(/\.([^.]+)$/); if (ary) ext = ary[1].toLowerCase(); else ext = "txt"; - templateName = templatePfx + ext; - var templateFile; - if (templateName in console.prefs) - templateFile = console.prefs[templateName]; - else - templateFile = console.prefs[templatePfx + "txt"]; - - var reportTemplate = console.profiler.loadTemplate(templateFile); - - var scriptInstanceList = new Array(); - - var j; + var rv = writeProfile(e, file, ext, onComplete); - if (!("urlList" in e) || e.urlList.length == 0) - { - if ("url" in e && e.url) - e.urlList = [e.url]; - else - e.urlList = keys(console.scriptManagers); - } - - e.urlList = e.urlList.sort(); - - for (i = 0; i < e.urlList.length; ++i) - { - var url = e.urlList[i]; - if (!ASSERT (url in console.scriptManagers, "url not loaded")) - continue; - var manager = console.scriptManagers[url]; - for (j in manager.instances) - scriptInstanceList.push (manager.instances[j]); - } - - var rangeList; - if (("profile.ranges." + ext) in console.prefs) - rangeList = console.prefs["profile.ranges." + ext].split(","); - else - rangeList = console.prefs["profile.ranges.default"].split(","); - - var profileReport = new ProfileReport (reportTemplate, file, rangeList, - scriptInstanceList); - profileReport.onComplete = onComplete; - - console.profiler.generateReport (profileReport); - - return file.localFile; + return rv.localFile; } function cmdSaveSettings(e) { if (!e.settingsFile || e.settingsFile == "?") { @@ -1767,12 +1724,89 @@ function cmdScope () else displayProperties (getCurrentFrame().scope); return true; } +function cmdShowProfile(e) +{ + function onComplete (i) + { + // We need a window since the current browserwindow could be disabled + // by us if a script in it is stopped, so we can't do anything there. + var w = window.open("about:blank"); + w.wrappedJSObject.document.open(); + w.wrappedJSObject.document.write(fileString.str); + w.wrappedJSObject.document.close(); + }; + + // In order not to create files, we hack in a small wrapper around a big string: + var fileString = { + str: "", + write: function _write(_str) { this.str += _str; } + }; + + writeProfile(e, fileString, "html", onComplete); +} + +function writeProfile(e, file, type, onComplete) +{ + // Get us a template + if (!type) + type = "txt"; + + var templatePfx = "profile.template."; + var templateName; + templateName = templatePfx + type; + var templateFile; + if (templateName in console.prefs) + templateFile = console.prefs[templateName]; + else + templateFile = console.prefs[templatePfx + "txt"]; + + var reportTemplate = console.profiler.loadTemplate(templateFile); + + // Get a list of scripts we profiled. + var scriptInstanceList = new Array(); + + if (!("urlList" in e) || e.urlList.length == 0) + { + if ("url" in e && e.url) + e.urlList = [e.url]; + else + e.urlList = keys(console.scriptManagers); + } + + e.urlList = e.urlList.sort(); + + var i, j; + for (i = 0; i < e.urlList.length; ++i) + { + var url = e.urlList[i]; + if (!ASSERT (url in console.scriptManagers, "url not loaded")) + continue; + var manager = console.scriptManagers[url]; + for (j in manager.instances) + scriptInstanceList.push (manager.instances[j]); + } + + var rangeList; + if (("profile.ranges." + type) in console.prefs) + rangeList = console.prefs["profile.ranges." + type].split(","); + else + rangeList = console.prefs["profile.ranges.default"].split(","); + + var profileReport = new ProfileReport (reportTemplate, file, rangeList, + scriptInstanceList); + profileReport.onComplete = onComplete; + + console.profiler.generateReport(profileReport); + + return file; +} + function cmdThisExpr(e) { if (e.expression == "debugger") { rv = console.jsdConsole; } Index: mozilla/extensions/venkman/resources/content/venkman-menus.js =================================================================== RCS file: /cvsroot/mozilla/extensions/venkman/resources/content/venkman-menus.js,v retrieving revision 1.18 diff -p -u -6 -r1.18 venkman-menus.js --- mozilla/extensions/venkman/resources/content/venkman-menus.js 7 Nov 2005 23:58:46 -0000 1.18 +++ mozilla/extensions/venkman/resources/content/venkman-menus.js 21 Jun 2006 20:57:58 -0000 @@ -181,13 +181,14 @@ function initMenus() items: [ ["toggle-profile", {type: "checkbox", checkedif: "console.jsds.flags & COLLECT_PROFILE_DATA"}], ["clear-profile"], - ["save-profile"] + ["save-profile"], + ["show-profile"] ] }; /* Mac expects a help menu with this ID, and there is nothing we can do * about it. */ console.menuSpecs["mainmenu:help"] = { 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 21 Jun 2006 20:58:00 -0000 @@ -851,12 +851,16 @@ cmd.show-constants.help = Controls whe cmd.toggle-show-most-recent.label = E&xclude Duplicates cmd.show-most-recent.params = [] cmd.show-most-recent.help = Controls whether the Loaded Scripts view should show only the most recent script from a given URL, or all of them. With this off, you may notice duplicate entries in the Loaded Scripts view. The value of can be |true|, |on|, |yes|, or |1| to turn the flag on; |false|, |off|, |no|, or |0| to turn it off; or |toggle| to invert the current state. If is not provided, the current state will be displayed. +cmd.show-profile.label = &Display Profile Data +cmd.show-profile.params = [ [<...>]] +cmd.show-profile.help = Displays the profile data collected for one or more source files specified by . If is not provided, all profile data is saved. + cmd.startup-init.label = Initialize at &Startup cmd.startup-init.params = [] cmd.startup-init.help = Sets the state of the "Initialize at Startup" feature. With this feature enabled, the debugger will begin tracking scripts when the browser is first started, instead of waiting until the user interface is launched. This will allow the script list to display files that were loaded before you started the debugger user interface. This feature incurs a *slight* performance hit. The value of can be |true|, |on|, |yes|, or |1| to turn the flag on; |false|, |off|, |no|, or |0| to turn it off; or |toggle| to invert the current state. If is not provided, the current state will be displayed. cmd.source-coloring.label = Colori&ze Source cmd.source-coloring.params = []