OLD | NEW |
1 importScripts('../../resources/testharness.js'); | 1 importScripts('../../resources/testharness.js'); |
2 | 2 |
3 promise_test(function(test) { | 3 promise_test(function(test) { |
4 var durationMsec = 100; | 4 var durationMsec = 100; |
5 | 5 |
6 return new Promise(function(resolve) { | 6 return new Promise(function(resolve) { |
7 performance.mark('startMark'); | 7 performance.mark('startMark'); |
8 setTimeout(resolve, durationMsec); | 8 setTimeout(resolve, durationMsec); |
9 }).then(function() { | 9 }).then(function() { |
10 performance.mark('endMark'); | 10 performance.mark('endMark'); |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 assert_equals(performance.getEntriesByType('mark').length, 2); | 22 assert_equals(performance.getEntriesByType('mark').length, 2); |
23 assert_equals(performance.getEntriesByType('measure').length, 1); | 23 assert_equals(performance.getEntriesByType('measure').length, 1); |
24 performance.clearMarks('startMark'); | 24 performance.clearMarks('startMark'); |
25 performance.clearMeasures('measure'); | 25 performance.clearMeasures('measure'); |
26 assert_equals(performance.getEntriesByType('mark').length, 1); | 26 assert_equals(performance.getEntriesByType('mark').length, 1); |
27 assert_equals(performance.getEntriesByType('measure').length, 0); | 27 assert_equals(performance.getEntriesByType('measure').length, 0); |
28 }); | 28 }); |
29 }, 'User Timing'); | 29 }, 'User Timing'); |
30 | 30 |
| 31 promise_test(function(test) { |
| 32 return fetch('../../resources/dummy.txt') |
| 33 .then(function(resp) { |
| 34 return resp.text(); |
| 35 }) |
| 36 .then(function(t) { |
| 37 var expectedResources = ['/resources/testharness.js', '/resources/dumm
y.txt']; |
| 38 assert_equals(performance.getEntriesByType('resource').length, expecte
dResources.length); |
| 39 for (var i = 0; i < expectedResources.length; i++) { |
| 40 var entry = performance.getEntriesByType('resource')[i]; |
| 41 assert_true(entry.name.endsWith(expectedResources[i])); |
| 42 assert_equals(entry.workerStart, 0); |
| 43 assert_greater_than(entry.startTime, 0); |
| 44 assert_greater_than(entry.responseEnd, entry.startTime); |
| 45 } |
| 46 }); |
| 47 }, 'Resource Timing'); |
| 48 |
31 done(); | 49 done(); |
OLD | NEW |