| Nicolás Peña Moreno | d310304 | 2019-04-03 19:19:53 | [diff] [blame] | 1 | <!DOCTYPE HTML> |
| 2 | <meta charset=utf-8> |
| 3 | <title>UserTiming L3: Measure basic usage</title> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script> |
| 7 | function endTime(entry) { |
| 8 | return entry.startTime + entry.duration; |
| 9 | } |
| 10 | |
| 11 | test(function() { |
| 12 | performance.clearMarks(); |
| 13 | performance.clearMeasures(); |
| 14 | const markEntry = performance.mark("mark", {startTime: 123}); |
| 15 | const measureEntry = performance.measure("A", undefined, "mark"); |
| 16 | assert_equals(measureEntry.startTime, 0); |
| 17 | assert_equals(endTime(measureEntry), markEntry.startTime); |
| 18 | }, "When the end mark is given and the start is unprovided, the end time of the measure entry should be the end mark's time, the start time should be 0."); |
| 19 | |
| 20 | test(function() { |
| 21 | performance.clearMarks(); |
| 22 | performance.clearMeasures(); |
| 23 | const markEntry = performance.mark("mark", {startTime: 123}); |
| 24 | const endMin = performance.now(); |
| 25 | const measureEntry = performance.measure("A", "mark", undefined); |
| 26 | const endMax = performance.now(); |
| 27 | assert_equals(measureEntry.startTime, markEntry.startTime); |
| 28 | assert_greater_than_equal(endTime(measureEntry), endMin); |
| 29 | assert_greater_than_equal(endMax, endTime(measureEntry)); |
| 30 | }, "When the start mark is given and the end is unprovided, the start time of the measure entry should be the start mark's time, the end should be now."); |
| 31 | |
| 32 | test(function() { |
| 33 | performance.clearMarks(); |
| 34 | performance.clearMeasures(); |
| 35 | const markEntry = performance.mark("mark", {startTime: 123}); |
| 36 | const measureEntry = performance.measure("A", "mark", "mark"); |
| 37 | assert_equals(endTime(measureEntry), markEntry.startTime); |
| 38 | assert_equals(measureEntry.startTime, markEntry.startTime); |
| 39 | }, "When start and end mark are both given, the start time and end time of the measure entry should be the the marks' time, repectively"); |
| 40 | </script> |