Index: LayoutTests/http/tests/serviceworker/resources/performance-timeline-worker.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/performance-timeline-worker.js b/LayoutTests/http/tests/serviceworker/resources/performance-timeline-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..393d7b05d95173690d43bc923f802463acf09c98 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/resources/performance-timeline-worker.js |
@@ -0,0 +1,29 @@ |
+importScripts('worker-testharness.js'); |
+ |
+promise_test(function(test) { |
+ var durationMsec = 100; |
+ |
+ return new Promise(function(resolve) { |
+ performance.mark('startMark'); |
+ setTimeout(resolve, durationMsec); |
+ }).then(function() { |
+ performance.mark('endMark'); |
+ performance.measure('measure', 'startMark', 'endMark'); |
+ |
+ var startMark = performance.getEntriesByName('startMark')[0]; |
+ var endMark = performance.getEntriesByName('endMark')[0]; |
+ var measure = performance.getEntriesByType('measure')[0]; |
+ |
+ assert_equals(measure.startTime, startMark.startTime); |
+ assert_approx_equals(endMark.startTime - startMark.startTime, |
+ measure.duration, 0.001); |
+ assert_greater_than(measure.duration, durationMsec); |
+ |
+ assert_equals(performance.getEntriesByType('mark').length, 2); |
+ assert_equals(performance.getEntriesByType('measure').length, 1); |
+ performance.clearMarks('startMark'); |
+ performance.clearMeasures('measure'); |
+ assert_equals(performance.getEntriesByType('mark').length, 1); |
+ assert_equals(performance.getEntriesByType('measure').length, 0); |
kinuko
2015/06/04 08:21:22
Why do we have slightly different tests for Servic
Kunihiko Sakamoto
2015/06/05 03:43:56
See above comment.
|
+ }); |
+}, 'User Timing in Service Worker'); |