summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/po-entries-sort.any.js
blob: b0c781a3c0c03bf81e820168bdf70b536275040b (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
62
63
64
// META: script=performanceobservers.js

  async_test(function (t) {
    var stored_entries = [];
    var stored_entries_by_type = [];
    var observer = new PerformanceObserver(
        t.step_func(function (entryList, obs) {

          stored_entries = entryList.getEntries();
          stored_entries_by_type = entryList.getEntriesByType("mark");
          stored_entries_by_name = entryList.getEntriesByName("name-repeat");
          var startTimeOfMark2 = entryList.getEntriesByName("mark2")[0].startTime;

          checkSorted(stored_entries);
          checkEntries(stored_entries, [
            {entryType: "measure", name: "measure1"},
            {entryType: "measure", name: "measure2"},
            {entryType: "measure", name: "measure3"},
            {entryType: "measure", name: "name-repeat"},
            {entryType: "mark", name: "mark1"},
            {entryType: "mark", name: "mark2"},
            {entryType: "measure", name: "measure-matching-mark2-1"},
            {entryType: "measure", name: "measure-matching-mark2-2"},
            {entryType: "mark", name: "name-repeat"},
            {entryType: "mark", name: "name-repeat"},
          ]);

          checkSorted(stored_entries_by_type);
          checkEntries(stored_entries_by_type, [
            {entryType: "mark", name: "mark1"},
            {entryType: "mark", name: "mark2"},
            {entryType: "mark", name: "name-repeat"},
            {entryType: "mark", name: "name-repeat"},
          ]);

          checkSorted(stored_entries_by_name);
          checkEntries(stored_entries_by_name, [
            {entryType: "measure", name: "name-repeat"},
            {entryType: "mark", name: "name-repeat"},
            {entryType: "mark", name: "name-repeat"},
          ]);

          observer.disconnect();
          t.done();
        })
      );

    observer.observe({entryTypes: ["mark", "measure"]});

    self.performance.mark("mark1");
    self.performance.measure("measure1");
    wait(); // Ensure mark1 !== mark2 startTime by making sure performance.now advances.
    self.performance.mark("mark2");
    self.performance.measure("measure2");
    self.performance.measure("measure-matching-mark2-1", "mark2");
    wait(); // Ensure mark2 !== mark3 startTime by making sure performance.now advances.
    self.performance.mark("name-repeat");
    self.performance.measure("measure3");
    self.performance.measure("measure-matching-mark2-2", "mark2");
    wait(); // Ensure name-repeat startTime will differ.
    self.performance.mark("name-repeat");
    wait(); // Ensure name-repeat startTime will differ.
    self.performance.measure("name-repeat");
  }, "getEntries, getEntriesByType, getEntriesByName sort order");