michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests that the calllog commands works as they should michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,gcli-calllog"; michael@0: michael@0: let tests = {}; michael@0: michael@0: function test() { michael@0: return Task.spawn(function() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: yield helpers.runTests(options, tests); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: tests.testCallLogStatus = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: "calllog", michael@0: check: { michael@0: input: 'calllog', michael@0: hints: '', michael@0: markup: 'IIIIIII', michael@0: status: 'ERROR' michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog start", michael@0: check: { michael@0: input: 'calllog start', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVV', michael@0: status: 'VALID' michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog stop", michael@0: check: { michael@0: input: 'calllog stop', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVV', michael@0: status: 'VALID' michael@0: } michael@0: }, michael@0: ]); michael@0: }; michael@0: michael@0: tests.testCallLogExec = function(options) { michael@0: var deferred = promise.defer(); michael@0: michael@0: var onWebConsoleOpen = function(subject) { michael@0: Services.obs.removeObserver(onWebConsoleOpen, "web-console-created"); 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: helpers.audit(options, [ michael@0: { michael@0: setup: "calllog stop", michael@0: exec: { michael@0: output: /Stopped call logging/, michael@0: } michael@0: }, michael@0: { michael@0: setup: "console clear", michael@0: exec: { michael@0: output: "", michael@0: }, michael@0: post: function() { michael@0: let labels = hud.outputNode.querySelectorAll(".webconsole-msg-output"); michael@0: is(labels.length, 0, "no output in console"); michael@0: } michael@0: }, michael@0: { michael@0: setup: "console close", michael@0: exec: { michael@0: output: "", michael@0: } michael@0: }, michael@0: ]).then(function() { michael@0: deferred.resolve(); michael@0: }); michael@0: }; michael@0: Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false); michael@0: michael@0: helpers.audit(options, [ michael@0: { michael@0: setup: "calllog stop", michael@0: exec: { michael@0: output: /No call logging/, michael@0: } michael@0: }, michael@0: { michael@0: name: "calllog start", michael@0: setup: function() { michael@0: // This test wants to be in a different event michael@0: var deferred = promise.defer(); michael@0: executeSoon(function() { michael@0: helpers.setInput(options, "calllog start").then(() => { michael@0: deferred.resolve(); michael@0: }); michael@0: }); michael@0: return deferred.promise; michael@0: }, michael@0: exec: { michael@0: output: /Call logging started/, michael@0: }, michael@0: }, michael@0: ]); michael@0: michael@0: return deferred.promise; michael@0: };