diff options
Diffstat (limited to 'browser/devtools/commandline/test/browser_cmd_commands.js')
-rw-r--r-- | browser/devtools/commandline/test/browser_cmd_commands.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/browser/devtools/commandline/test/browser_cmd_commands.js b/browser/devtools/commandline/test/browser_cmd_commands.js new file mode 100644 index 000000000..4b8bc8203 --- /dev/null +++ b/browser/devtools/commandline/test/browser_cmd_commands.js @@ -0,0 +1,71 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test various GCLI commands + +let HUDService = (Cu.import("resource:///modules/HUDService.jsm", {})).HUDService; + +const TEST_URI = "data:text/html;charset=utf-8,gcli-commands"; + +let tests = {}; + +function test() { + helpers.addTabWithToolbar(TEST_URI, function(options) { + return helpers.runTests(options, tests); + }).then(finish); +} + +tests.testConsole = function(options) { + let deferred = Promise.defer(); + let hud = null; + + let onWebConsoleOpen = function(subject) { + Services.obs.removeObserver(onWebConsoleOpen, "web-console-created"); + + subject.QueryInterface(Ci.nsISupportsString); + hud = HUDService.getHudReferenceById(subject.data); + ok(hud.hudId in HUDService.hudReferences, "console open"); + + hud.jsterm.execute("pprint(window)", onExecute); + } + Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false); + + let onExecute = function() { + let labels = hud.outputNode.querySelectorAll(".webconsole-msg-output"); + ok(labels.length > 0, "output for pprint(window)"); + + helpers.audit(options, [ + { + setup: "console clear", + exec: { + output: "" + }, + post: function() { + let labels = hud.outputNode.querySelectorAll(".webconsole-msg-output"); + // Bug 845827 - The GCLI "console clear" command doesn't always work + // is(labels.length, 0, "no output in console"); + } + }, + { + setup: "console close", + exec: { + output: "" + }, + post: function() { + ok(!(hud.hudId in HUDService.hudReferences), "console closed"); + } + } + ]).then(function() { + deferred.resolve(); + }); + }; + + helpers.audit(options, [ + { + setup: "console open", + exec: { } + } + ]); + + return deferred.promise; +}; |