browser/devtools/webconsole/test/browser_webconsole_bug_658368_time_methods.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /*
michael@0 3 * Any copyright is dedicated to the Public Domain.
michael@0 4 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 5 */
michael@0 6
michael@0 7 // Tests that the Console API implements the time() and timeEnd() methods.
michael@0 8
michael@0 9 function test() {
michael@0 10 addTab("http://example.com/browser/browser/devtools/webconsole/" +
michael@0 11 "test/test-bug-658368-time-methods.html");
michael@0 12 browser.addEventListener("load", function onLoad() {
michael@0 13 browser.removeEventListener("load", onLoad, true);
michael@0 14 Task.spawn(runner);
michael@0 15 }, true);
michael@0 16
michael@0 17 function* runner() {
michael@0 18 let hud1 = yield openConsole();
michael@0 19
michael@0 20 yield waitForMessages({
michael@0 21 webconsole: hud1,
michael@0 22 messages: [{
michael@0 23 name: "aTimer started",
michael@0 24 consoleTime: "aTimer",
michael@0 25 }, {
michael@0 26 name: "aTimer end",
michael@0 27 consoleTimeEnd: "aTimer",
michael@0 28 }],
michael@0 29 });
michael@0 30
michael@0 31 let deferred = promise.defer();
michael@0 32
michael@0 33 // The next test makes sure that timers with the same name but in separate
michael@0 34 // tabs, do not contain the same value.
michael@0 35 addTab("data:text/html;charset=utf-8,<script>" +
michael@0 36 "console.timeEnd('bTimer');</script>");
michael@0 37 browser.addEventListener("load", function onLoad() {
michael@0 38 browser.removeEventListener("load", onLoad, true);
michael@0 39 openConsole().then((hud) => {
michael@0 40 deferred.resolve(hud);
michael@0 41 });
michael@0 42 }, true);
michael@0 43
michael@0 44 let hud2 = yield deferred.promise;
michael@0 45
michael@0 46 testLogEntry(hud2.outputNode, "bTimer: timer started",
michael@0 47 "bTimer was not started", false, true);
michael@0 48
michael@0 49 // The next test makes sure that timers with the same name but in separate
michael@0 50 // pages, do not contain the same value.
michael@0 51 content.location = "data:text/html;charset=utf-8,<script>" +
michael@0 52 "console.time('bTimer');</script>";
michael@0 53
michael@0 54 yield waitForMessages({
michael@0 55 webconsole: hud2,
michael@0 56 messages: [{
michael@0 57 name: "bTimer started",
michael@0 58 consoleTime: "bTimer",
michael@0 59 }],
michael@0 60 });
michael@0 61
michael@0 62 hud2.jsterm.clearOutput();
michael@0 63
michael@0 64 deferred = promise.defer();
michael@0 65
michael@0 66 // Now the following console.timeEnd() call shouldn't display anything,
michael@0 67 // if the timers in different pages are not related.
michael@0 68 browser.addEventListener("load", function onLoad() {
michael@0 69 browser.removeEventListener("load", onLoad, true);
michael@0 70 deferred.resolve(null);
michael@0 71 }, true);
michael@0 72
michael@0 73 content.location = "data:text/html;charset=utf-8," +
michael@0 74 "<script>console.timeEnd('bTimer');</script>";
michael@0 75
michael@0 76 yield deferred.promise;
michael@0 77
michael@0 78 testLogEntry(hud2.outputNode, "bTimer: timer started",
michael@0 79 "bTimer was not started", false, true);
michael@0 80
michael@0 81 yield closeConsole(gBrowser.selectedTab);
michael@0 82
michael@0 83 gBrowser.removeCurrentTab();
michael@0 84
michael@0 85 executeSoon(finishTest);
michael@0 86 }
michael@0 87 }

mercurial