11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci    This tests that 'performance.measure' throws exceptions with reasonable messages.
51cb0ef41Sopenharmony_ci</head>
61cb0ef41Sopenharmony_ci<body>
71cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
81cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
91cb0ef41Sopenharmony_ci<script>
101cb0ef41Sopenharmony_ci    window.performance.clearMarks();
111cb0ef41Sopenharmony_ci    window.performance.clearMeasures();
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci    window.performance.mark('mark');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci    const eventMarks = [
161cb0ef41Sopenharmony_ci        'unloadEventStart',
171cb0ef41Sopenharmony_ci        'unloadEventEnd',
181cb0ef41Sopenharmony_ci        'redirectStart',
191cb0ef41Sopenharmony_ci        'redirectEnd',
201cb0ef41Sopenharmony_ci        'secureConnectionStart',
211cb0ef41Sopenharmony_ci        'domInteractive',
221cb0ef41Sopenharmony_ci        'domContentLoadedEventStart',
231cb0ef41Sopenharmony_ci        'domContentLoadedEventEnd',
241cb0ef41Sopenharmony_ci        'domComplete',
251cb0ef41Sopenharmony_ci        'loadEventStart',
261cb0ef41Sopenharmony_ci        'loadEventEnd',
271cb0ef41Sopenharmony_ci    ];
281cb0ef41Sopenharmony_ci    eventMarks.forEach(function(name) {
291cb0ef41Sopenharmony_ci        test(()=>{
301cb0ef41Sopenharmony_ci            assert_throws_dom("InvalidAccessError", ()=>{
311cb0ef41Sopenharmony_ci                window.performance.measure("measuring", name, "mark");
321cb0ef41Sopenharmony_ci            }, "Should throw");
331cb0ef41Sopenharmony_ci        }, `Passing '${name}' as a mark to measure API should cause error when the mark is empty.`);
341cb0ef41Sopenharmony_ci    });
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci    const args = [
371cb0ef41Sopenharmony_ci        51.15,  // Verify that number is parsed as string, not number.
381cb0ef41Sopenharmony_ci        "DoesNotExist", // Non-existant mark name should cause error.
391cb0ef41Sopenharmony_ci    ];
401cb0ef41Sopenharmony_ci    args.forEach(each => {
411cb0ef41Sopenharmony_ci        test(()=>{
421cb0ef41Sopenharmony_ci            assert_throws_dom("SyntaxError", ()=>{
431cb0ef41Sopenharmony_ci                window.performance.measure("measuring", each, "mark");
441cb0ef41Sopenharmony_ci            }, "Should throw");
451cb0ef41Sopenharmony_ci        }, `Passing ${each} as a mark to measure API should cause error.`);
461cb0ef41Sopenharmony_ci    });
471cb0ef41Sopenharmony_ci</script>
481cb0ef41Sopenharmony_ci</body>
491cb0ef41Sopenharmony_ci</html>