browser/devtools/profiler/test/browser_profiler_console_api_content.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     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";
     8 let gTab, gPanel, gToolbox;
    10 function test() {
    11   waitForExplicitFinish();
    13   setUp(URL, (tab, browser, panel) => {
    14     gTab = tab;
    15     gPanel = panel;
    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;
    24           runTests();
    25         });
    26       });
    27     });
    28  });
    29 }
    31 function runTests() {
    32   is(getSidebarItem(1).attachment.state, PROFILE_COMPLETED);
    34   gPanel.once("parsed", () => {
    35     function assertSampleAndFinish() {
    36       let [win,doc] = getProfileInternals();
    37       let sample = doc.getElementsByClassName("samplePercentage");
    39       if (sample.length <= 0)
    40         return void setTimeout(assertSampleAndFinish, 100);
    42       ok(sample.length > 0, "We have Cleopatra UI displayed");
    43       tearDown(gTab, () => {
    44         gTab = null;
    45         gPanel = null;
    46         gToolbox = null;
    47       });
    48     }
    50     assertSampleAndFinish();
    51   });
    53   let profile = gPanel.profiles.get(1);
    54   gPanel.sidebar.selectedItem = gPanel.sidebar.getItemByProfile(profile);
    55 }

mercurial