summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_markers-timestamp.js
blob: 78ba01c8130eae096f85460cd703cd81547e548c (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test that we get a "TimeStamp" marker.
 */
"use strict";

const {
  pmmConsoleMethod,
  pmmInitWithBrowser,
} = require("devtools/client/performance/test/helpers/profiler-mm-utils");
const MARKER_NAME = "TimeStamp";

add_task(async function() {
  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");

  const front = await target.getFront("performance");
  const rec = await front.startRecording({ withMarkers: true });

  pmmInitWithBrowser(gBrowser);
  pmmConsoleMethod("timeStamp");
  pmmConsoleMethod("timeStamp", "myLabel");

  const markers = await waitForMarkerType(
    front,
    MARKER_NAME,
    m => m.length >= 2
  );

  await front.stopRecording(rec);

  ok(
    markers.every(({ stack }) => typeof stack === "number"),
    "All markers have stack references."
  );
  ok(
    markers.every(({ name }) => name === "TimeStamp"),
    "All markers found are TimeStamp markers"
  );
  ok(markers.length === 2, "found 2 TimeStamp markers");
  ok(
    markers.every(
      ({ start, end }) => typeof start === "number" && start === end
    ),
    "All markers have equal start and end times"
  );
  is(
    markers[0].causeName,
    void 0,
    "Unlabeled timestamps have an empty causeName"
  );
  is(
    markers[1].causeName,
    "myLabel",
    "Labeled timestamps have correct causeName"
  );

  await target.destroy();
  gBrowser.removeCurrentTab();
});