forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpo-takeRecords.html
39 lines (39 loc) · 1.39 KB
/
po-takeRecords.html
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
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>PerformanceObserver: takeRecords</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="performanceobservers.js"></script>
<script>
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()");
</script>