browser/devtools/profiler/test/browser_profiler_bug_855244_multiple_tabs.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>";
     6 let gTab1, gPanel1;
     7 let gTab2, gPanel2;
     9 // Tests that you can run the profiler in multiple tabs at the same
    10 // time and that closing the debugger panel in one tab doesn't lock
    11 // profilers in other tabs.
    13 registerCleanupFunction(function () {
    14   gTab1 = gTab2 = gPanel1 = gPanel2 = null;
    15 });
    17 function test() {
    18   waitForExplicitFinish();
    20   openTwoTabs()
    21     .then(startTwoProfiles)
    22     .then(stopFirstProfile)
    23     .then(stopSecondProfile)
    24     .then(closeTabs)
    25     .then(openTwoTabs)
    26     .then(startTwoProfiles)
    27     .then(closeFirstPanel)
    28     .then(stopSecondProfile)
    29     .then(closeTabs)
    30     .then(finish);
    31 }
    33 function openTwoTabs() {
    34   let deferred = promise.defer();
    36   setUp(URL, (tab, browser, panel) => {
    37     gTab1 = tab;
    38     gPanel1 = panel;
    40     loadTab(URL, (tab, browser) => {
    41       gTab2 = tab;
    42       openProfiler(tab, () => {
    43         let target = TargetFactory.forTab(tab);
    44         gPanel2 = gDevTools.getToolbox(target).getPanel("jsprofiler");
    45         deferred.resolve();
    46       });
    47     });
    48   });
    50   return deferred.promise;
    51 }
    53 function startTwoProfiles() {
    54   let deferred = promise.defer();
    55   gPanel1.controller.start("Profile 1", (err) => {
    56     ok(!err, "Profile in tab 1 started without errors");
    57     gPanel2.controller.start("Profile 1", (err) => {
    58       ok(!err, "Profile in tab 2 started without errors");
    59       gPanel1.controller.isActive((err, isActive) => {
    60         ok(isActive, "Profiler is active");
    61         deferred.resolve();
    62       });
    63     });
    64   });
    66   return deferred.promise;
    67 }
    69 function stopFirstProfile() {
    70   let deferred = promise.defer();
    72   gPanel1.controller.stop("Profile 1", (err, data) => {
    73     ok(!err, "Profile in tab 1 stopped without errors");
    74     ok(data, "Profile in tab 1 returned some data");
    75     deferred.resolve();
    76   });
    78   return deferred.promise;
    79 }
    81 function stopSecondProfile() {
    82   let deferred = promise.defer();
    84   gPanel2.controller.stop("Profile 1", (err, data) => {
    85     ok(!err, "Profile in tab 2 stopped without errors");
    86     ok(data, "Profile in tab 2 returned some data");
    87     deferred.resolve();
    88   });
    90   return deferred.promise;
    91 }
    93 function closeTabs() {
    94   while (gBrowser.tabs.length > 1) {
    95     gBrowser.removeCurrentTab();
    96   }
    97 }
    99 function closeFirstPanel() {
   100   let target = TargetFactory.forTab(gTab1);
   101   let toolbox = gDevTools.getToolbox(target);
   102   return toolbox.destroy;
   103 }

mercurial