• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: script=resources/user-timing-helper.js
2
3function endTime(entry) {
4  return entry.startTime + entry.duration;
5}
6
7test(function() {
8  performance.clearMarks();
9  performance.clearMeasures();
10  const markEntry = performance.mark("mark", {startTime: 123});
11  const measureEntry = performance.measure("A", undefined, "mark");
12  assert_equals(measureEntry.startTime, 0);
13  assert_equals(endTime(measureEntry), markEntry.startTime);
14}, "When the end mark is given and the start is unprovided, the end time of the measure entry should be the end mark's time, the start time should be 0.");
15
16test(function() {
17  performance.clearMarks();
18  performance.clearMeasures();
19  const markEntry = performance.mark("mark", {startTime: 123});
20  const endMin = Number(performance.now().toFixed(2));
21  const measureEntry = performance.measure("A", "mark", undefined);
22  const endMax = Number(performance.now().toFixed(2));
23  assert_equals(measureEntry.startTime, markEntry.startTime);
24  assert_greater_than_equal(Number(endTime(measureEntry).toFixed(2)), endMin);
25  assert_greater_than_equal(endMax, Number(endTime(measureEntry).toFixed(2)));
26}, "When the start mark is given and the end is unprovided, the start time of the measure entry should be the start mark's time, the end should be now.");
27
28test(function() {
29  performance.clearMarks();
30  performance.clearMeasures();
31  const markEntry = performance.mark("mark", {startTime: 123});
32  const measureEntry = performance.measure("A", "mark", "mark");
33  assert_equals(endTime(measureEntry), markEntry.startTime);
34  assert_equals(measureEntry.startTime, markEntry.startTime);
35}, "When start and end mark are both given, the start time and end time of the measure entry should be the the marks' time, repectively");
36