• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(()=>{
30            assert_throws_dom("InvalidAccessError", ()=>{
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(()=>{
42            assert_throws_dom("SyntaxError", ()=>{
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>