tor-browser

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

browser_perf-04.js (1641B)


      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 * Run through a series of basic recording actions for the perf actor.
      8 */
      9 add_task(async function () {
     10  const { front, client } = await initPerfFront();
     11 
     12  // Assert the initial state.
     13  is(
     14    await front.isSupportedPlatform(),
     15    true,
     16    "This test only runs on supported platforms."
     17  );
     18  is(await front.isActive(), false, "The profiler is not active yet.");
     19 
     20  // Getting the active Browser ID to assert in the "profiler-started" event.
     21  const win = Services.wm.getMostRecentBrowserWindow();
     22  const activeTabID = win.gBrowser.selectedBrowser.browsingContext.browserId;
     23 
     24  front.once(
     25    "profiler-started",
     26    (entries, interval, features, duration, activeTID) => {
     27      is(entries, 1024, "Should apply entries by startProfiler");
     28      is(interval, 0.1, "Should apply interval by startProfiler");
     29      is(typeof features, "number", "Should apply features by startProfiler");
     30      is(duration, 2, "Should apply duration by startProfiler");
     31      is(
     32        activeTID,
     33        activeTabID,
     34        "Should apply active browser ID by startProfiler"
     35      );
     36    }
     37  );
     38 
     39  // Start the profiler.
     40  await front.startProfiler({
     41    entries: 1000,
     42    duration: 2,
     43    interval: 0.1,
     44    features: ["js", "stackwalk"],
     45  });
     46 
     47  is(await front.isActive(), true, "The profiler is active.");
     48 
     49  // clean up
     50  await front.stopProfilerAndDiscardProfile();
     51  await front.destroy();
     52  await client.close();
     53 });