Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>";
6 let gTab, gPanel;
8 function test() {
9 waitForExplicitFinish();
11 setUp(URL, (tab, browser, panel) => {
12 gTab = tab;
13 gPanel = panel;
15 openConsole(tab, testConsoleProfile);
16 });
17 }
19 function testConsoleProfile(hud) {
20 hud.jsterm.clearOutput(true);
22 // Here we start two named profiles and then end one of them.
24 let profilesStarted = 0;
26 function endProfile() {
27 if (++profilesStarted < 2)
28 return;
30 gPanel.controller.off("profileStart", endProfile);
31 gPanel.controller.once("profileEnd", () => openProfiler(gTab, checkProfiles));
32 hud.jsterm.execute("console.profileEnd('Second')");
33 }
35 gPanel.controller.on("profileStart", endProfile);
36 hud.jsterm.execute("console.profile('Second')");
37 hud.jsterm.execute("console.profile('Third')");
38 }
40 function checkProfiles(toolbox) {
41 let panel = toolbox.getPanel("jsprofiler");
43 is(getSidebarItem(1, panel).attachment.name, "Second", "Name in sidebar is OK");
44 is(getSidebarItem(1, panel).attachment.state, PROFILE_COMPLETED, "State in sidebar is OK");
46 // Make sure we can still stop profiles via the queue pop.
48 gPanel.controller.once("profileEnd", () => {
49 openProfiler(gTab, () => {
50 is(getSidebarItem(2, panel).attachment.state, PROFILE_COMPLETED, "State in sidebar is OK");
51 tearDown(gTab, () => gTab = gPanel = null);
52 });
53 });
55 openConsole(gTab, (hud) => hud.jsterm.execute("console.profileEnd()"));
56 }