OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 |
| 5 description("This tests that PerformanceObserver gets called the right number of
times."); |
| 6 |
| 7 window.jsTestIsAsync = true; |
| 8 |
| 9 var entries = []; |
| 10 |
| 11 var expectedEntries = [ |
| 12 {entryType:'mark', name:'mark_1'}, |
| 13 {entryType:'mark', name:'mark_2'}, |
| 14 {entryType:'measure', name:'measure_1'} |
| 15 ]; |
| 16 |
| 17 var observer = new PerformanceObserver(performanceCallback); |
| 18 |
| 19 function performanceCallback(performanceEntryList) |
| 20 { |
| 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(); |
| 31 } |
| 32 |
| 33 function performMeasure() |
| 34 { |
| 35 window.performance.measure('measure_1', 'mark_1', 'mark_2'); |
| 36 } |
| 37 |
| 38 var config = { entryTypes: ['mark', 'measure'] }; |
| 39 observer.observe(config); |
| 40 |
| 41 window.performance.mark('mark_1'); |
| 42 window.performance.mark('mark_2'); |
| 43 |
| 44 window.setTimeout(performMeasure, 0); |
| 45 </script> |
OLD | NEW |