Bug 834069 - Create a command to list sources in the debugger; r=past

This commit is contained in:
Rob Campbell 2013-01-23 17:16:00 -05:00
Родитель 07e4ec3a66
Коммит f1836eb833
3 изменённых файлов: 50 добавлений и 2 удалений

Просмотреть файл

@ -1259,6 +1259,41 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
}
});
/**
* 'dbg list' command
*/
gcli.addCommand({
name: "dbg list",
description: gcli.lookup("dbgListSourcesDesc"),
params: [],
returnType: "html",
exec: function(args, context) {
let dbg = getPanel(context, "jsdebugger");
let doc = context.environment.chromeDocument;
if (!dbg) {
return gcli.lookup("debuggerClosed");
}
let sources = dbg._view.Sources.values;
let div = createXHTMLElement(doc, "div");
let ol = createXHTMLElement(doc, "ol");
sources.forEach(function(src) {
let li = createXHTMLElement(doc, "li");
li.textContent = src;
ol.appendChild(li);
});
div.appendChild(ol);
return div;
}
});
/**
* A helper to create xhtml namespaced elements
*/
function createXHTMLElement(document, tagname) {
return document.createElementNS("http://www.w3.org/1999/xhtml", tagname);
}
/**
* A helper to go from a command context to a debugger panel
*/

Просмотреть файл

@ -18,12 +18,17 @@ function test() {
function testCommands(dbg, cmd) {
// Wait for the initial resume...
dbg._controller.activeThread.addOneTimeListener("resumed", function () {
info("Starting tests.");
info("Starting tests");
let contentDoc = content.window.document;
let output = contentDoc.querySelector("input[type=text]");
let btnDoit = contentDoc.querySelector("input[type=button]");
DeveloperToolbarTest.exec({
typed: "dbg list",
outputMatch: /browser_dbg_cmd.html/
});
cmd("dbg interrupt", function() {
ok(true, "debugger is paused");
dbg._controller.activeThread.addOneTimeListener("resumed", function () {

Просмотреть файл

@ -303,8 +303,12 @@ tiltCloseDesc=Close the visualization if open
# command, displayed when the user asks for help on what it does.
tiltCloseManual=Close the visualization and switch back to the Inspector's default highlighter
# LOCALIZATION NOTE (debuggerStopped) Used in the output of several commands
# LOCALIZATION NOTE (debuggerClosed) Used in the output of several commands
# to explain that the debugger must be opened first.
debuggerClosed=The debugger must be opened before using this command
# LOCALIZATION NOTE (debuggerStopped) Used in the output of several commands
# to explain that the debugger must be opened first before setting breakpoints.
debuggerStopped=The debugger must be opened before setting breakpoints
# LOCALIZATION NOTE (breakDesc) A very short string used to describe the
@ -420,6 +424,10 @@ dbgStepInDesc=Executes the current statement and then stops at the next statemen
# function of the dbg step out command.
dbgStepOutDesc=Steps out of the current function and up one level if the function is nested. If in the main body, the script is executed to the end, or to the next breakpoint. The skipped statements are executed, but not stepped through
# LOCALIZATION NOTE (dbgListSourcesDesc) A very short string used to describe the
# function of the dbg list command.
dbgListSourcesDesc=List the source URLs loaded in the debugger
# LOCALIZATION NOTE (consolecloseDesc) A very short description of the
# 'console close' command. This string is designed to be shown in a menu
# alongside the command name, which is why it should be as short as possible.