michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test various GCLI commands michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,gcli-commands"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: let subjectPromise = helpers.observeOnce("web-console-created"); michael@0: michael@0: helpers.audit(options, [ michael@0: { michael@0: setup: "console open", michael@0: exec: { } michael@0: } michael@0: ]); michael@0: michael@0: let subject = yield subjectPromise; michael@0: michael@0: subject.QueryInterface(Ci.nsISupportsString); michael@0: let hud = HUDService.getHudReferenceById(subject.data); michael@0: ok(hud, "console open"); michael@0: michael@0: let jstermExecute = helpers.promiseify(hud.jsterm.execute, hud.jsterm); michael@0: let msg = yield jstermExecute("pprint(window)"); michael@0: michael@0: ok(msg, "output for pprint(window)"); michael@0: michael@0: let oncePromise = hud.jsterm.once("messages-cleared"); michael@0: michael@0: helpers.audit(options, [ michael@0: { michael@0: setup: "console clear", michael@0: exec: { output: "" } michael@0: } michael@0: ]); michael@0: michael@0: yield oncePromise; michael@0: michael@0: let labels = hud.outputNode.querySelectorAll(".message"); michael@0: is(labels.length, 0, "no output in console"); michael@0: michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: "console close", michael@0: exec: { output: true } michael@0: } michael@0: ]); michael@0: michael@0: ok(!HUDService.getHudReferenceById(hud.hudId), "console closed"); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }