Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 importScripts('worker-testharness.js'); | |
| 2 | |
| 3 promise_test(function(test) { | |
| 4 var durationMsec = 100; | |
| 5 | |
| 6 return new Promise(function(resolve) { | |
| 7 performance.mark('startMark'); | |
| 8 setTimeout(resolve, durationMsec); | |
| 9 }).then(function() { | |
| 10 performance.mark('endMark'); | |
| 11 performance.measure('measure', 'startMark', 'endMark'); | |
| 12 | |
| 13 var startMark = performance.getEntriesByName('startMark')[0]; | |
| 14 var endMark = performance.getEntriesByName('endMark')[0]; | |
| 15 var measure = performance.getEntriesByType('measure')[0]; | |
| 16 | |
| 17 assert_equals(measure.startTime, startMark.startTime); | |
| 18 assert_approx_equals(endMark.startTime - startMark.startTime, | |
| 19 measure.duration, 0.001); | |
| 20 assert_greater_than(measure.duration, durationMsec); | |
| 21 | |
| 22 assert_equals(performance.getEntriesByType('mark').length, 2); | |
| 23 assert_equals(performance.getEntriesByType('measure').length, 1); | |
| 24 performance.clearMarks('startMark'); | |
| 25 performance.clearMeasures('measure'); | |
| 26 assert_equals(performance.getEntriesByType('mark').length, 1); | |
| 27 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.
| |
| 28 }); | |
| 29 }, 'User Timing in Service Worker'); | |
| OLD | NEW |