browser/devtools/profiler/test/browser_profiler_console_api_content.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/profiler/test/browser_profiler_console_api_content.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>";
     1.8 +const BASE = "http://example.com/browser/browser/devtools/profiler/test/";
     1.9 +const PAGE = BASE + "mock_console_api.html";
    1.10 +
    1.11 +let gTab, gPanel, gToolbox;
    1.12 +
    1.13 +function test() {
    1.14 +  waitForExplicitFinish();
    1.15 +
    1.16 +  setUp(URL, (tab, browser, panel) => {
    1.17 +    gTab = tab;
    1.18 +    gPanel = panel;
    1.19 +
    1.20 +    openProfiler(tab, (toolbox) => {
    1.21 +      gToolbox = toolbox;
    1.22 +      loadUrl(PAGE, tab, () => {
    1.23 +        gPanel.sidebar.on("stateChanged", (_, item) => {
    1.24 +          if (item.attachment.state !== PROFILE_COMPLETED)
    1.25 +            return;
    1.26 +
    1.27 +          runTests();
    1.28 +        });
    1.29 +      });
    1.30 +    });
    1.31 + });
    1.32 +}
    1.33 +
    1.34 +function runTests() {
    1.35 +  is(getSidebarItem(1).attachment.state, PROFILE_COMPLETED);
    1.36 +
    1.37 +  gPanel.once("parsed", () => {
    1.38 +    function assertSampleAndFinish() {
    1.39 +      let [win,doc] = getProfileInternals();
    1.40 +      let sample = doc.getElementsByClassName("samplePercentage");
    1.41 +
    1.42 +      if (sample.length <= 0)
    1.43 +        return void setTimeout(assertSampleAndFinish, 100);
    1.44 +
    1.45 +      ok(sample.length > 0, "We have Cleopatra UI displayed");
    1.46 +      tearDown(gTab, () => {
    1.47 +        gTab = null;
    1.48 +        gPanel = null;
    1.49 +        gToolbox = null;
    1.50 +      });
    1.51 +    }
    1.52 +
    1.53 +    assertSampleAndFinish();
    1.54 +  });
    1.55 +
    1.56 +  let profile = gPanel.profiles.get(1);
    1.57 +  gPanel.sidebar.selectedItem = gPanel.sidebar.getItemByProfile(profile);
    1.58 +}
    1.59 \ No newline at end of file

mercurial