| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script src="resources/slow.js"></script> | 4 <script src="resources/slow.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 async_test(function (t) { | 7 async_test(function (t) { |
| 8 var observer = new PerformanceObserver( | 8 var observer = new PerformanceObserver( |
| 9 t.step_func(function (entryList) { | 9 t.step_func(function (entryList) { |
| 10 var entries = entryList.getEntries(); | 10 var entries = entryList.getEntries(); |
| 11 assert_equals(entries.length, 1, | 11 assert_equals(entries.length, 1, |
| 12 "Exactly one entry is expected."); | 12 "Exactly one entry is expected."); |
| 13 var longtask = entries[0]; | 13 var longtask = entries[0]; |
| 14 assert_equals(longtask.entryType, "longtask", | 14 assert_equals(longtask.entryType, "longtask"); |
| 15 "entryType expected to be: longtask"); | 15 assert_equals(longtask.name, "self"); |
| 16 assert_equals(longtask.name, "same-origin-self", | 16 assert_greater_than(longtask.duration, 50); |
| 17 "name expected to be: same-origin-self"); | |
| 18 assert_greater_than(longtask.duration, 50, | |
| 19 "duration expected to be greater than 50ms threshold"); | |
| 20 assert_equals(longtask.startTime, Math.floor(longtask.startTime), | 17 assert_equals(longtask.startTime, Math.floor(longtask.startTime), |
| 21 "startTime expected to have 1 miillisecond granularity"); | 18 "startTime expected to have 1 miillisecond granularity"); |
| 22 | 19 |
| 23 // Assert the TaskAttributionTiming entry in attribution. | 20 // Assert the TaskAttributionTiming entry in attribution. |
| 24 assert_equals(longtask.attribution.length, 1, | 21 assert_equals(longtask.attribution.length, 1, |
| 25 "Exactly one attribution entry is expected"); | 22 "Exactly one attribution entry is expected"); |
| 26 var attribution = longtask.attribution[0]; | 23 var attribution = longtask.attribution[0]; |
| 27 assert_equals(attribution.entryType, "taskattribution"); | 24 assert_equals(attribution.entryType, "taskattribution"); |
| 28 assert_equals(attribution.name, "frame"); | 25 assert_equals(attribution.name, "script"); |
| 29 assert_equals(attribution.duration, 0); | 26 assert_equals(attribution.duration, 0); |
| 30 assert_equals(attribution.startTime, 0); | 27 assert_equals(attribution.startTime, 0); |
| 31 | 28 |
| 32 observer.disconnect(); | 29 observer.disconnect(); |
| 33 t.done(); | 30 t.done(); |
| 34 }) | 31 }) |
| 35 ); | 32 ); |
| 36 observer.observe({entryTypes: ["longtask"]}); | 33 observer.observe({entryTypes: ["longtask"]}); |
| 37 | 34 |
| 38 }, "Performance longtask entries are observable"); | 35 }, "Performance longtask entries are observable"); |
| 39 | 36 |
| 40 </script> | 37 </script> |
| OLD | NEW |