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,cmd-calllog-chrome"; 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: status: "ERROR", michael@0: emptyParameters: [ " " ] michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog chromestop", michael@0: check: { michael@0: status: "VALID", michael@0: emptyParameters: [ " " ] michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog chromestart content-variable window", michael@0: check: { michael@0: status: "VALID", michael@0: emptyParameters: [ " " ] michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"", michael@0: check: { michael@0: status: "VALID", michael@0: emptyParameters: [ " " ] michael@0: } michael@0: }, michael@0: ]); michael@0: }; michael@0: michael@0: tests.testCallLogExec = function(options) { michael@0: let deferred = promise.defer(); michael@0: michael@0: function onWebConsoleOpen(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 chromestop", michael@0: exec: { michael@0: output: /Stopped call logging/, michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog chromestart javascript XXX", michael@0: exec: { michael@0: output: /following exception/, 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.jsterm.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 chromestop", michael@0: exec: { michael@0: output: /No call logging/ michael@0: } michael@0: }, michael@0: { michael@0: setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"", michael@0: exec: { michael@0: output: /Call logging started/, michael@0: } michael@0: }, michael@0: ]); michael@0: michael@0: return deferred.promise; michael@0: };