OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/js-test.js"></script> | |
3 <script> | |
4 window.jsTestIsAsync = true; | |
5 | |
6 var entries = []; | |
7 var expectedEntries = [ | |
8 {entryType:'mark', name:'mark_1'}, | |
9 {entryType:'mark', name:'mark_2'}, | |
10 {entryType:'measure', name:'measure_1'} | |
11 ]; | |
12 | |
13 function testPerformanceObserver() | |
esprehn
2015/09/09 22:41:40
Just inline this code below.
MikeB
2015/09/10 19:53:01
Done.
| |
14 { | |
15 var observer = new PerformanceObserver(performanceCallback); | |
16 | |
17 function performanceCallback(performanceEntryList) | |
18 { | |
19 entries = entries.concat(performanceEntryList.getEntries()); | |
20 if (entries.length != expectedEntries.length) | |
21 return; | |
22 shouldBe('entries[0].entryType', 'expectedEntries[0].entryType'); | |
23 shouldBe('entries[0].name', 'expectedEntries[0].name'); | |
24 shouldBe('entries[1].entryType', 'expectedEntries[1].entryType'); | |
25 shouldBe('entries[1].name', 'expectedEntries[1].name'); | |
26 shouldBe('entries[2].entryType', 'expectedEntries[2].entryType'); | |
27 shouldBe('entries[2].name', 'expectedEntries[2].name'); | |
28 testRunner.notifyDone(); | |
esprehn
2015/09/09 22:41:40
finishJSTest(), don't call testRunner directly.
MikeB
2015/09/10 19:53:01
Done.
| |
29 } | |
30 | |
31 function performMeasure() | |
32 { | |
33 window.performance.measure('measure_1', 'mark_1', 'mark_2'); | |
34 } | |
35 | |
36 var config = { entryTypes: ['mark', 'measure'] }; | |
37 observer.observe(config); | |
38 window.performance.mark('mark_1'); | |
39 window.performance.mark('mark_2'); | |
40 window.setTimeout(performMeasure, 0); | |
41 } | |
42 | |
43 description("This tests that PerformanceObserver gets called the right number of times."); | |
44 | |
45 testPerformanceObserver(); | |
46 testRunner.waitUntilDone(); | |
esprehn
2015/09/09 22:41:40
jsTestIsAsync should do this for you, remove this.
MikeB
2015/09/10 19:53:01
Done.
| |
47 </script> | |
OLD | NEW |