| <!DOCTYPE html> |
| <script src="../../resources/js-test.js"></script> |
| <script> |
| |
| description("This tests that PerformanceObserver gets called the right number of times."); |
| |
| window.jsTestIsAsync = true; |
| |
| var entries = []; |
| |
| var expectedEntries = [ |
| {entryType:'mark', name:'mark_1'}, |
| {entryType:'mark', name:'mark_2'}, |
| {entryType:'measure', name:'measure_1'} |
| ]; |
| |
| var observer = new PerformanceObserver(performanceCallback); |
| |
| function performanceCallback(performanceEntryList) |
| { |
| entries = entries.concat(performanceEntryList.getEntries()); |
| if (entries.length != expectedEntries.length) |
| return; |
| shouldBe('entries[0].entryType', 'expectedEntries[0].entryType'); |
| shouldBe('entries[0].name', 'expectedEntries[0].name'); |
| shouldBe('entries[1].entryType', 'expectedEntries[1].entryType'); |
| shouldBe('entries[1].name', 'expectedEntries[1].name'); |
| shouldBe('entries[2].entryType', 'expectedEntries[2].entryType'); |
| shouldBe('entries[2].name', 'expectedEntries[2].name'); |
| finishJSTest(); |
| } |
| |
| function performMeasure() |
| { |
| window.performance.measure('measure_1', 'mark_1', 'mark_2'); |
| } |
| |
| var config = { entryTypes: ['mark', 'measure'] }; |
| observer.observe(config); |
| |
| window.performance.mark('mark_1'); |
| window.performance.mark('mark_2'); |
| |
| window.setTimeout(performMeasure, 0); |
| </script> |