michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests that the Console API implements the time() and timeEnd() methods. michael@0: michael@0: function test() { michael@0: addTab("http://example.com/browser/browser/devtools/webconsole/" + michael@0: "test/test-bug-658368-time-methods.html"); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: Task.spawn(runner); michael@0: }, true); michael@0: michael@0: function* runner() { michael@0: let hud1 = yield openConsole(); michael@0: michael@0: yield waitForMessages({ michael@0: webconsole: hud1, michael@0: messages: [{ michael@0: name: "aTimer started", michael@0: consoleTime: "aTimer", michael@0: }, { michael@0: name: "aTimer end", michael@0: consoleTimeEnd: "aTimer", michael@0: }], michael@0: }); michael@0: michael@0: let deferred = promise.defer(); michael@0: michael@0: // The next test makes sure that timers with the same name but in separate michael@0: // tabs, do not contain the same value. michael@0: addTab("data:text/html;charset=utf-8,"); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole().then((hud) => { michael@0: deferred.resolve(hud); michael@0: }); michael@0: }, true); michael@0: michael@0: let hud2 = yield deferred.promise; michael@0: michael@0: testLogEntry(hud2.outputNode, "bTimer: timer started", michael@0: "bTimer was not started", false, true); michael@0: michael@0: // The next test makes sure that timers with the same name but in separate michael@0: // pages, do not contain the same value. michael@0: content.location = "data:text/html;charset=utf-8,"; michael@0: michael@0: yield waitForMessages({ michael@0: webconsole: hud2, michael@0: messages: [{ michael@0: name: "bTimer started", michael@0: consoleTime: "bTimer", michael@0: }], michael@0: }); michael@0: michael@0: hud2.jsterm.clearOutput(); michael@0: michael@0: deferred = promise.defer(); michael@0: michael@0: // Now the following console.timeEnd() call shouldn't display anything, michael@0: // if the timers in different pages are not related. michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: deferred.resolve(null); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html;charset=utf-8," + michael@0: ""; michael@0: michael@0: yield deferred.promise; michael@0: michael@0: testLogEntry(hud2.outputNode, "bTimer: timer started", michael@0: "bTimer was not started", false, true); michael@0: michael@0: yield closeConsole(gBrowser.selectedTab); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: michael@0: executeSoon(finishTest); michael@0: } michael@0: }