michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const URL = "data:text/html;charset=utf8,

JavaScript Profiler test

"; michael@0: const BASE = "http://example.com/browser/browser/devtools/profiler/test/"; michael@0: const PAGE = BASE + "mock_console_api.html"; michael@0: michael@0: let gTab, gPanel, gToolbox; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: setUp(URL, (tab, browser, panel) => { michael@0: gTab = tab; michael@0: gPanel = panel; michael@0: michael@0: openProfiler(tab, (toolbox) => { michael@0: gToolbox = toolbox; michael@0: loadUrl(PAGE, tab, () => { michael@0: gPanel.sidebar.on("stateChanged", (_, item) => { michael@0: if (item.attachment.state !== PROFILE_COMPLETED) michael@0: return; michael@0: michael@0: runTests(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function runTests() { michael@0: is(getSidebarItem(1).attachment.state, PROFILE_COMPLETED); michael@0: michael@0: gPanel.once("parsed", () => { michael@0: function assertSampleAndFinish() { michael@0: let [win,doc] = getProfileInternals(); michael@0: let sample = doc.getElementsByClassName("samplePercentage"); michael@0: michael@0: if (sample.length <= 0) michael@0: return void setTimeout(assertSampleAndFinish, 100); michael@0: michael@0: ok(sample.length > 0, "We have Cleopatra UI displayed"); michael@0: tearDown(gTab, () => { michael@0: gTab = null; michael@0: gPanel = null; michael@0: gToolbox = null; michael@0: }); michael@0: } michael@0: michael@0: assertSampleAndFinish(); michael@0: }); michael@0: michael@0: let profile = gPanel.profiles.get(1); michael@0: gPanel.sidebar.selectedItem = gPanel.sidebar.getItemByProfile(profile); michael@0: }