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