Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / performance / performance-observer.html
bloba0380fffc29c96b698c2c5e35a1ebdacf16f522a
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
5 description("This tests that PerformanceObserver gets called the right number of times.");
7 window.jsTestIsAsync = true;
9 var entries = [];
11 var expectedEntries = [
12 {entryType:'mark', name:'mark_1'},
13 {entryType:'mark', name:'mark_2'},
14 {entryType:'measure', name:'measure_1'}
17 var observer = new PerformanceObserver(performanceCallback);
19 function performanceCallback(performanceEntryList)
21 entries = entries.concat(performanceEntryList.getEntries());
22 if (entries.length != expectedEntries.length)
23 return;
24 shouldBe('entries[0].entryType', 'expectedEntries[0].entryType');
25 shouldBe('entries[0].name', 'expectedEntries[0].name');
26 shouldBe('entries[1].entryType', 'expectedEntries[1].entryType');
27 shouldBe('entries[1].name', 'expectedEntries[1].name');
28 shouldBe('entries[2].entryType', 'expectedEntries[2].entryType');
29 shouldBe('entries[2].name', 'expectedEntries[2].name');
30 finishJSTest();
33 function performMeasure()
35 window.performance.measure('measure_1', 'mark_1', 'mark_2');
38 var config = { entryTypes: ['mark', 'measure'] };
39 observer.observe(config);
41 window.performance.mark('mark_1');
42 window.performance.mark('mark_2');
44 window.setTimeout(performMeasure, 0);
45 </script>