|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>"; |
|
5 const BASE = "http://example.com/browser/browser/devtools/profiler/test/"; |
|
6 const PAGE = BASE + "mock_console_api.html"; |
|
7 |
|
8 let gTab, gPanel, gToolbox; |
|
9 |
|
10 function test() { |
|
11 waitForExplicitFinish(); |
|
12 |
|
13 setUp(URL, (tab, browser, panel) => { |
|
14 gTab = tab; |
|
15 gPanel = panel; |
|
16 |
|
17 openProfiler(tab, (toolbox) => { |
|
18 gToolbox = toolbox; |
|
19 loadUrl(PAGE, tab, () => { |
|
20 gPanel.sidebar.on("stateChanged", (_, item) => { |
|
21 if (item.attachment.state !== PROFILE_COMPLETED) |
|
22 return; |
|
23 |
|
24 runTests(); |
|
25 }); |
|
26 }); |
|
27 }); |
|
28 }); |
|
29 } |
|
30 |
|
31 function runTests() { |
|
32 is(getSidebarItem(1).attachment.state, PROFILE_COMPLETED); |
|
33 |
|
34 gPanel.once("parsed", () => { |
|
35 function assertSampleAndFinish() { |
|
36 let [win,doc] = getProfileInternals(); |
|
37 let sample = doc.getElementsByClassName("samplePercentage"); |
|
38 |
|
39 if (sample.length <= 0) |
|
40 return void setTimeout(assertSampleAndFinish, 100); |
|
41 |
|
42 ok(sample.length > 0, "We have Cleopatra UI displayed"); |
|
43 tearDown(gTab, () => { |
|
44 gTab = null; |
|
45 gPanel = null; |
|
46 gToolbox = null; |
|
47 }); |
|
48 } |
|
49 |
|
50 assertSampleAndFinish(); |
|
51 }); |
|
52 |
|
53 let profile = gPanel.profiles.get(1); |
|
54 gPanel.sidebar.selectedItem = gPanel.sidebar.getItemByProfile(profile); |
|
55 } |