browser/devtools/profiler/test/browser_profiler_console_api_named.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 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>";
michael@0 5
michael@0 6 let gTab, gPanel;
michael@0 7
michael@0 8 function test() {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 setUp(URL, (tab, browser, panel) => {
michael@0 12 gTab = tab;
michael@0 13 gPanel = panel;
michael@0 14
michael@0 15 openConsole(tab, testConsoleProfile);
michael@0 16 });
michael@0 17 }
michael@0 18
michael@0 19 function testConsoleProfile(hud) {
michael@0 20 hud.jsterm.clearOutput(true);
michael@0 21
michael@0 22 // Here we start two named profiles and then end one of them.
michael@0 23
michael@0 24 let profilesStarted = 0;
michael@0 25
michael@0 26 function endProfile() {
michael@0 27 if (++profilesStarted < 2)
michael@0 28 return;
michael@0 29
michael@0 30 gPanel.controller.off("profileStart", endProfile);
michael@0 31 gPanel.controller.once("profileEnd", () => openProfiler(gTab, checkProfiles));
michael@0 32 hud.jsterm.execute("console.profileEnd('Second')");
michael@0 33 }
michael@0 34
michael@0 35 gPanel.controller.on("profileStart", endProfile);
michael@0 36 hud.jsterm.execute("console.profile('Second')");
michael@0 37 hud.jsterm.execute("console.profile('Third')");
michael@0 38 }
michael@0 39
michael@0 40 function checkProfiles(toolbox) {
michael@0 41 let panel = toolbox.getPanel("jsprofiler");
michael@0 42
michael@0 43 is(getSidebarItem(1, panel).attachment.name, "Second", "Name in sidebar is OK");
michael@0 44 is(getSidebarItem(1, panel).attachment.state, PROFILE_COMPLETED, "State in sidebar is OK");
michael@0 45
michael@0 46 // Make sure we can still stop profiles via the queue pop.
michael@0 47
michael@0 48 gPanel.controller.once("profileEnd", () => {
michael@0 49 openProfiler(gTab, () => {
michael@0 50 is(getSidebarItem(2, panel).attachment.state, PROFILE_COMPLETED, "State in sidebar is OK");
michael@0 51 tearDown(gTab, () => gTab = gPanel = null);
michael@0 52 });
michael@0 53 });
michael@0 54
michael@0 55 openConsole(gTab, (hud) => hud.jsterm.execute("console.profileEnd()"));
michael@0 56 }

mercurial