1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/commandline/test/browser_cmd_commands.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Test various GCLI commands 1.8 + 1.9 +const TEST_URI = "data:text/html;charset=utf-8,gcli-commands"; 1.10 + 1.11 +function test() { 1.12 + return Task.spawn(spawnTest).then(finish, helpers.handleError); 1.13 +} 1.14 + 1.15 +function spawnTest() { 1.16 + let options = yield helpers.openTab(TEST_URI); 1.17 + yield helpers.openToolbar(options); 1.18 + 1.19 + let subjectPromise = helpers.observeOnce("web-console-created"); 1.20 + 1.21 + helpers.audit(options, [ 1.22 + { 1.23 + setup: "console open", 1.24 + exec: { } 1.25 + } 1.26 + ]); 1.27 + 1.28 + let subject = yield subjectPromise; 1.29 + 1.30 + subject.QueryInterface(Ci.nsISupportsString); 1.31 + let hud = HUDService.getHudReferenceById(subject.data); 1.32 + ok(hud, "console open"); 1.33 + 1.34 + let jstermExecute = helpers.promiseify(hud.jsterm.execute, hud.jsterm); 1.35 + let msg = yield jstermExecute("pprint(window)"); 1.36 + 1.37 + ok(msg, "output for pprint(window)"); 1.38 + 1.39 + let oncePromise = hud.jsterm.once("messages-cleared"); 1.40 + 1.41 + helpers.audit(options, [ 1.42 + { 1.43 + setup: "console clear", 1.44 + exec: { output: "" } 1.45 + } 1.46 + ]); 1.47 + 1.48 + yield oncePromise; 1.49 + 1.50 + let labels = hud.outputNode.querySelectorAll(".message"); 1.51 + is(labels.length, 0, "no output in console"); 1.52 + 1.53 + yield helpers.audit(options, [ 1.54 + { 1.55 + setup: "console close", 1.56 + exec: { output: true } 1.57 + } 1.58 + ]); 1.59 + 1.60 + ok(!HUDService.getHudReferenceById(hud.hudId), "console closed"); 1.61 + 1.62 + yield helpers.closeToolbar(options); 1.63 + yield helpers.closeTab(options); 1.64 +}