summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/user-timing/measure-exceptions.html
blob: 2836eaee2a86c10997893f3e9b77c86079030019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
    This tests that 'performance.measure' throws exceptions with reasonable messages.
</head>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
    window.performance.clearMarks();
    window.performance.clearMeasures();

    window.performance.mark('mark');

    const eventMarks = [
        'unloadEventStart',
        'unloadEventEnd',
        'redirectStart',
        'redirectEnd',
        'secureConnectionStart',
        'domInteractive',
        'domContentLoadedEventStart',
        'domContentLoadedEventEnd',
        'domComplete',
        'loadEventStart',
        'loadEventEnd',
    ];
    eventMarks.forEach(function(name) {
        test(()=>{
            assert_throws_dom("InvalidAccessError", ()=>{
                window.performance.measure("measuring", name, "mark");
            }, "Should throw");
        }, `Passing '${name}' as a mark to measure API should cause error when the mark is empty.`);
    });

    const args = [
        51.15,  // Verify that number is parsed as string, not number.
        "DoesNotExist", // Non-existant mark name should cause error.
    ];
    args.forEach(each => {
        test(()=>{
            assert_throws_dom("SyntaxError", ()=>{
                window.performance.measure("measuring", each, "mark");
            }, "Should throw");
        }, `Passing ${each} as a mark to measure API should cause error.`);
    });
</script>
</body>
</html>