11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<html> 31cb0ef41Sopenharmony_ci<head> 41cb0ef41Sopenharmony_ci<meta charset="utf-8" /> 51cb0ef41Sopenharmony_ci<title>functionality test of window.performance.clearMarks</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 entrylist_checker = new performance_entrylist_checker('mark'); 191cb0ef41Sopenharmony_ci const string_mark_names = mark_names.map(function (x) { return String(x)}); 201cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 211cb0ef41Sopenharmony_ci performance.mark(name); 221cb0ef41Sopenharmony_ci }); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci for (let i = 0; i < mark_names.length; ++i) 251cb0ef41Sopenharmony_ci { 261cb0ef41Sopenharmony_ci performance.clearMarks(mark_names[i]); 271cb0ef41Sopenharmony_ci const retained_entries = performance.getEntriesByType('mark'); 281cb0ef41Sopenharmony_ci const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); 291cb0ef41Sopenharmony_ci entrylist_checker.entrylist_check(retained_entries, mark_names.length - i - 1, string_mark_names, 301cb0ef41Sopenharmony_ci 'First loop: checking entries after removing "' + mark_names[i] + '". '); 311cb0ef41Sopenharmony_ci test_equals(non_retained_entries.length, 0, 321cb0ef41Sopenharmony_ci 'First loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); 331cb0ef41Sopenharmony_ci } 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 361cb0ef41Sopenharmony_ci performance.mark(name); 371cb0ef41Sopenharmony_ci }); 381cb0ef41Sopenharmony_ci performance.clearMarks(); 391cb0ef41Sopenharmony_ci test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist after we clear all.'); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci // Following cases test clear existed mark name that is tied for two times. 421cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 431cb0ef41Sopenharmony_ci performance.mark(name); 441cb0ef41Sopenharmony_ci }); 451cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 461cb0ef41Sopenharmony_ci performance.mark(name); 471cb0ef41Sopenharmony_ci }); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci for (let i = 0; i < mark_names.length; ++i) 501cb0ef41Sopenharmony_ci { 511cb0ef41Sopenharmony_ci performance.clearMarks(mark_names[i]); 521cb0ef41Sopenharmony_ci const retained_entries = performance.getEntriesByType('mark'); 531cb0ef41Sopenharmony_ci const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); 541cb0ef41Sopenharmony_ci entrylist_checker.entrylist_check(retained_entries, (mark_names.length - i - 1) * 2, string_mark_names, 551cb0ef41Sopenharmony_ci 'Second loop: checking entries after removing "' + mark_names[i] + '". '); 561cb0ef41Sopenharmony_ci test_equals(non_retained_entries.length, 0, 571cb0ef41Sopenharmony_ci 'Second loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); 581cb0ef41Sopenharmony_ci } 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci // Following cases test clear functionality when mark names are tied for two times. 611cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 621cb0ef41Sopenharmony_ci performance.mark(name); 631cb0ef41Sopenharmony_ci }); 641cb0ef41Sopenharmony_ci mark_names.forEach(function(name) { 651cb0ef41Sopenharmony_ci performance.mark(name); 661cb0ef41Sopenharmony_ci }); 671cb0ef41Sopenharmony_ci var entry_number_before_useless_clear = performance.getEntriesByType('Mark').length; 681cb0ef41Sopenharmony_ci performance.clearMarks('NonExist'); 691cb0ef41Sopenharmony_ci var entry_number_after_useless_clear = performance.getEntriesByType('Mark').length; 701cb0ef41Sopenharmony_ci test_equals(entry_number_before_useless_clear, entry_number_after_useless_clear, 'Nothing should happen if we clear a non-exist mark.'); 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci performance.clearMarks(); 731cb0ef41Sopenharmony_ci test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist when we clear all.'); 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci done(); 761cb0ef41Sopenharmony_ci} 771cb0ef41Sopenharmony_ci</script> 781cb0ef41Sopenharmony_ci</head> 791cb0ef41Sopenharmony_ci<body onload=onload_test()> 801cb0ef41Sopenharmony_ci <h1>Description</h1> 811cb0ef41Sopenharmony_ci <p>This test validates functionality of the interface window.performance.clearMarks.</p> 821cb0ef41Sopenharmony_ci <div id="log"></div> 831cb0ef41Sopenharmony_ci</body> 841cb0ef41Sopenharmony_ci</html> 85