blob: 2836eaee2a86c10997893f3e9b77c86079030019 [file] [log] [blame]
Liquan(Max) Gud8a50252019-04-26 18:47:321<!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 McGruer3696f222020-01-23 19:11:5830 assert_throws_dom("InvalidAccessError", ()=>{
Liquan(Max) Gud8a50252019-04-26 18:47:3231 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 McGruer3696f222020-01-23 19:11:5842 assert_throws_dom("SyntaxError", ()=>{
Liquan(Max) Gud8a50252019-04-26 18:47:3243 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>