11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<meta charset="utf-8" />
51cb0ef41Sopenharmony_ci<title>functionality test of window.performance.measure</title>
61cb0ef41Sopenharmony_ci<link rel="author" title="Intel" href="http://www.intel.com/" />
71cb0ef41Sopenharmony_ci<link rel="help" href="http://www.w3.org/TR/user-timing/#extensions-performance-interface"/>
81cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
91cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
101cb0ef41Sopenharmony_ci<script src="/common/performance-timeline-utils.js"></script>
111cb0ef41Sopenharmony_ci<script src="resources/webperftestharness.js"></script>
121cb0ef41Sopenharmony_ci<script src="resources/webperftestharnessextension.js"></script>
131cb0ef41Sopenharmony_ci<script>
141cb0ef41Sopenharmony_cisetup({ explicit_done: true });
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cifunction onload_test()
171cb0ef41Sopenharmony_ci{
181cb0ef41Sopenharmony_ci    const context = new PerformanceContext(window.performance);
191cb0ef41Sopenharmony_ci    const entrylist_checker = new performance_entrylist_checker('measure');
201cb0ef41Sopenharmony_ci    const measure_names = measures.map(function(x) {return x[0];});
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci    test_equals(context.getEntriesByType('measure').length, 0, 'There should be ' + 0 + ' entries returned.');
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci    mark_names.forEach(function(name) {
251cb0ef41Sopenharmony_ci        context.mark(name);
261cb0ef41Sopenharmony_ci    });
271cb0ef41Sopenharmony_ci    measures.forEach(context.initialMeasures, context);
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci    let measure_entrylist = context.getEntriesByType('measure');
301cb0ef41Sopenharmony_ci    entrylist_checker.entrylist_check(measure_entrylist, measures.length, measure_names,
311cb0ef41Sopenharmony_ci        'Checking all entries.');
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci    for (let i = 0; i < measure_entrylist.length; ++i)
341cb0ef41Sopenharmony_ci    {
351cb0ef41Sopenharmony_ci        const measure_entrylist_by_name = context.getEntriesByName(measure_entrylist[i].name, 'measure');
361cb0ef41Sopenharmony_ci        entrylist_checker.entrylist_check(measure_entrylist_by_name, 1, measure_names,
371cb0ef41Sopenharmony_ci            'First loop: checking entry of name "' + measure_entrylist[i].name + '".');
381cb0ef41Sopenharmony_ci    }
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci    // Following cases test for scenarios that measure names are tied for two times
411cb0ef41Sopenharmony_ci    mark_names.forEach(function(name) {
421cb0ef41Sopenharmony_ci        context.mark(name);
431cb0ef41Sopenharmony_ci    });
441cb0ef41Sopenharmony_ci    measures.forEach(context.initialMeasures, context);
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ci    measure_entrylist = context.getEntriesByType('measure');
471cb0ef41Sopenharmony_ci    entrylist_checker.entrylist_check(measure_entrylist, measures.length * 2, measure_names,
481cb0ef41Sopenharmony_ci        'Checking all doubly measured entries.');
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci    for (let i = 0; i < measure_entrylist.length; ++i)
511cb0ef41Sopenharmony_ci    {
521cb0ef41Sopenharmony_ci        const measure_entrylist_by_name = context.getEntriesByName(measure_entrylist[i].name, 'measure');
531cb0ef41Sopenharmony_ci        entrylist_checker.entrylist_check(measure_entrylist_by_name, 2, measure_names,
541cb0ef41Sopenharmony_ci            'Second loop step ' + i + ': checking entry of name "' + measure_entrylist[i].name + '".');
551cb0ef41Sopenharmony_ci    }
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci    done();
581cb0ef41Sopenharmony_ci}
591cb0ef41Sopenharmony_ci</script>
601cb0ef41Sopenharmony_ci</head>
611cb0ef41Sopenharmony_ci<body onload=onload_test()>
621cb0ef41Sopenharmony_ci    <h1>Description</h1>
631cb0ef41Sopenharmony_ci    <p>This test validates functionality of the interface window.performance.measure.</p>
641cb0ef41Sopenharmony_ci    <div id="log"></div>
651cb0ef41Sopenharmony_ci</body>
661cb0ef41Sopenharmony_ci</html>
67