summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/po-takeRecords.any.js
blob: 86ad397b0a5c379d0129d43c92952bc6c8c5c0cf (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
// META: title=PerformanceObserver: takeRecords
// META: script=performanceobservers.js

async_test(function (t) {
    const observer = new PerformanceObserver(function (entryList, observer) {
      assert_unreached('This callback should not have been called.')
    });
    let entries = observer.takeRecords();
    checkEntries(entries, [], 'No records before observe');
    observer.observe({entryTypes: ['mark']});
    assert_equals(typeof(observer.takeRecords), 'function');
    entries = observer.takeRecords();
    checkEntries(entries, [], 'No records just from observe');
    performance.mark('a');
    performance.mark('b');
    entries = observer.takeRecords();
    checkEntries(entries, [
      {entryType: 'mark', name: 'a'},
      {entryType: 'mark', name: 'b'}
    ]);
    performance.mark('c');
    performance.mark('d');
    performance.mark('e');
    entries = observer.takeRecords();
    checkEntries(entries, [
      {entryType: 'mark', name: 'c'},
      {entryType: 'mark', name: 'd'},
      {entryType: 'mark', name: 'e'}
    ]);
    entries = observer.takeRecords();
    checkEntries(entries, [], 'No entries right after takeRecords');
    observer.disconnect();
    t.done();
  }, "Test PerformanceObserver's takeRecords()");