summaryrefslogtreecommitdiffstats
path: root/tools/profiler/tests/browser/browser_test_markers_parent_process.js
blob: 28b82f805481f51307049143bcc3ded0bb70faf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

add_task(async function test_markers_parent_process() {
  info("Test markers that are generated by the browser's parent process.");

  info("Start the profiler in nostacksampling mode.");
  await startProfiler({ features: ["nostacksampling"] });

  info("Dispatch a DOMEvent");
  window.dispatchEvent(new Event("synthetic"));

  info("Stop the profiler and get the profile.");
  const profile = await stopNowAndGetProfile();

  const markers = getInflatedMarkerData(profile.threads[0]);
  {
    const domEventStart = markers.find(
      ({ phase, data }) =>
        phase === INTERVAL_START && data?.eventType === "synthetic"
    );
    const domEventEnd = markers.find(
      ({ phase, data }) =>
        phase === INTERVAL_END && data?.eventType === "synthetic"
    );
    ok(domEventStart, "A start DOMEvent was generated");
    ok(domEventEnd, "An end DOMEvent was generated");
    ok(
      domEventEnd.data.latency > 0,
      "DOMEvent had a a latency value generated."
    );
    ok(domEventEnd.data.type === "DOMEvent");
    ok(domEventEnd.name === "DOMEvent");
  }
  // Add more marker tests.
});