tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_perf-02.js (1153B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 "use strict";
      5 
      6 /**
      7 * Test what happens when other tools control the profiler.
      8 */
      9 add_task(async function () {
     10  const { front, client } = await initPerfFront();
     11 
     12  // Simulate other tools by getting an independent handle on the Gecko Profiler.
     13  // eslint-disable-next-line mozilla/use-services
     14  const geckoProfiler = Cc["@mozilla.org/tools/profiler;1"].getService(
     15    Ci.nsIProfiler
     16  );
     17 
     18  is(await front.isActive(), false, "The profiler hasn't been started yet.");
     19 
     20  // Start the profiler.
     21  await front.startProfiler();
     22  is(await front.isActive(), true, "The profiler was started.");
     23 
     24  // Stop the profiler manually through the Gecko Profiler interface.
     25  const profilerStopped = once(front, "profiler-stopped");
     26  geckoProfiler.StopProfiler();
     27  await profilerStopped;
     28  is(
     29    await front.isActive(),
     30    false,
     31    "The profiler was stopped by another tool."
     32  );
     33 
     34  // Clean up.
     35  await front.destroy();
     36  await client.close();
     37 });