Index: LayoutTests/fast/performance/performance-observer.html |
diff --git a/LayoutTests/fast/performance/performance-observer.html b/LayoutTests/fast/performance/performance-observer.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..073dae1843d4cac2f3a1dd87c585c6ff00952b6e |
--- /dev/null |
+++ b/LayoutTests/fast/performance/performance-observer.html |
@@ -0,0 +1,47 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/js-test.js"></script> |
+<script> |
+window.jsTestIsAsync = true; |
+ |
+var entries = []; |
+var expectedEntries = [ |
+ {entryType:'mark', name:'mark_1'}, |
+ {entryType:'mark', name:'mark_2'}, |
+ {entryType:'measure', name:'measure_1'} |
+]; |
+ |
+function testPerformanceObserver() |
esprehn
2015/09/09 22:41:40
Just inline this code below.
MikeB
2015/09/10 19:53:01
Done.
|
+{ |
+ 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'); |
+ testRunner.notifyDone(); |
esprehn
2015/09/09 22:41:40
finishJSTest(), don't call testRunner directly.
MikeB
2015/09/10 19:53:01
Done.
|
+ } |
+ |
+ 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); |
+} |
+ |
+description("This tests that PerformanceObserver gets called the right number of times."); |
+ |
+testPerformanceObserver(); |
+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.
|
+</script> |