| Liquan(Max) Gu | d8a5025 | 2019-04-26 18:47:32 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | This tests that 'performance.measure' throws exceptions with reasonable messages. |
| 5 | </head> |
| 6 | <body> |
| 7 | <script src="/resources/testharness.js"></script> |
| 8 | <script src="/resources/testharnessreport.js"></script> |
| 9 | <script> |
| 10 | window.performance.clearMarks(); |
| 11 | window.performance.clearMeasures(); |
| 12 | |
| 13 | window.performance.mark('mark'); |
| 14 | |
| 15 | const eventMarks = [ |
| 16 | 'unloadEventStart', |
| 17 | 'unloadEventEnd', |
| 18 | 'redirectStart', |
| 19 | 'redirectEnd', |
| 20 | 'secureConnectionStart', |
| 21 | 'domInteractive', |
| 22 | 'domContentLoadedEventStart', |
| 23 | 'domContentLoadedEventEnd', |
| 24 | 'domComplete', |
| 25 | 'loadEventStart', |
| 26 | 'loadEventEnd', |
| 27 | ]; |
| 28 | eventMarks.forEach(function(name) { |
| 29 | test(()=>{ |
| Stephen McGruer | 3696f22 | 2020-01-23 19:11:58 | [diff] [blame] | 30 | assert_throws_dom("InvalidAccessError", ()=>{ |
| Liquan(Max) Gu | d8a5025 | 2019-04-26 18:47:32 | [diff] [blame] | 31 | window.performance.measure("measuring", name, "mark"); |
| 32 | }, "Should throw"); |
| 33 | }, `Passing '${name}' as a mark to measure API should cause error when the mark is empty.`); |
| 34 | }); |
| 35 | |
| 36 | const args = [ |
| 37 | 51.15, // Verify that number is parsed as string, not number. |
| 38 | "DoesNotExist", // Non-existant mark name should cause error. |
| 39 | ]; |
| 40 | args.forEach(each => { |
| 41 | test(()=>{ |
| Stephen McGruer | 3696f22 | 2020-01-23 19:11:58 | [diff] [blame] | 42 | assert_throws_dom("SyntaxError", ()=>{ |
| Liquan(Max) Gu | d8a5025 | 2019-04-26 18:47:32 | [diff] [blame] | 43 | window.performance.measure("measuring", each, "mark"); |
| 44 | }, "Should throw"); |
| 45 | }, `Passing ${each} as a mark to measure API should cause error.`); |
| 46 | }); |
| 47 | </script> |
| 48 | </body> |
| 49 | </html> |