• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: script=performanceobservers.js
2
3  async_test(function (t) {
4    var stored_entries = [];
5    var observer  = new PerformanceObserver(
6        t.step_func(function (entryList, obs) {
7          stored_entries =
8            stored_entries.concat(entryList.getEntries());
9          if (stored_entries.length >= 4) {
10            checkEntries(stored_entries,
11              [{ entryType: "mark", name: "mark1"},
12              { entryType: "mark", name: "mark2"},
13              { entryType: "measure", name: "measure1"},
14              { entryType: "measure", name: "measure2"}]);
15            observer.disconnect();
16            t.done();
17          }
18        })
19      );
20    observer.observe({entryTypes: ["mark", "measure"]});
21  }, "entries are observable");
22
23  async_test(function (t) {
24    var mark_entries = [];
25    var observer = new PerformanceObserver(
26        t.step_func(function (entryList, obs) {
27          mark_entries =
28            mark_entries.concat(entryList.getEntries());
29          if (mark_entries.length >= 2) {
30            checkEntries(mark_entries,
31              [{ entryType: "mark", name: "mark1"},
32              { entryType: "mark", name: "mark2"}]);
33            observer.disconnect();
34            t.done();
35          }
36        })
37      );
38    observer.observe({entryTypes: ["mark"]});
39    self.performance.mark("mark1");
40    self.performance.mark("mark2");
41  }, "mark entries are observable");
42
43  async_test(function (t) {
44    var measure_entries = [];
45    var observer = new PerformanceObserver(
46        t.step_func(function (entryList, obs) {
47          measure_entries =
48            measure_entries.concat(entryList.getEntries());
49          if (measure_entries.length >= 2) {
50            checkEntries(measure_entries,
51              [{ entryType: "measure", name: "measure1"},
52              { entryType: "measure", name: "measure2"}]);
53            observer.disconnect();
54            t.done();
55          }
56        })
57      );
58    observer.observe({entryTypes: ["measure"]});
59    self.performance.measure("measure1");
60    self.performance.measure("measure2");
61  }, "measure entries are observable");
62