1<!DOCTYPE html> 2<html> 3<head> 4<meta charset="utf-8" /> 5<title>functionality test of window.performance.clearMarks</title> 6<link rel="author" title="Intel" href="http://www.intel.com/" /> 7<link rel="help" href="http://www.w3.org/TR/user-timing/#extensions-performance-interface"/> 8<script src="/resources/testharness.js"></script> 9<script src="/resources/testharnessreport.js"></script> 10<script src="/common/performance-timeline-utils.js"></script> 11<script src="resources/webperftestharness.js"></script> 12<script src="resources/webperftestharnessextension.js"></script> 13<script> 14setup({ explicit_done: true }); 15 16function onload_test() 17{ 18 const entrylist_checker = new performance_entrylist_checker('mark'); 19 const string_mark_names = mark_names.map(function (x) { return String(x)}); 20 mark_names.forEach(function(name) { 21 performance.mark(name); 22 }); 23 24 for (let i = 0; i < mark_names.length; ++i) 25 { 26 performance.clearMarks(mark_names[i]); 27 const retained_entries = performance.getEntriesByType('mark'); 28 const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); 29 entrylist_checker.entrylist_check(retained_entries, mark_names.length - i - 1, string_mark_names, 30 'First loop: checking entries after removing "' + mark_names[i] + '". '); 31 test_equals(non_retained_entries.length, 0, 32 'First loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); 33 } 34 35 mark_names.forEach(function(name) { 36 performance.mark(name); 37 }); 38 performance.clearMarks(); 39 test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist after we clear all.'); 40 41 // Following cases test clear existed mark name that is tied for two times. 42 mark_names.forEach(function(name) { 43 performance.mark(name); 44 }); 45 mark_names.forEach(function(name) { 46 performance.mark(name); 47 }); 48 49 for (let i = 0; i < mark_names.length; ++i) 50 { 51 performance.clearMarks(mark_names[i]); 52 const retained_entries = performance.getEntriesByType('mark'); 53 const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); 54 entrylist_checker.entrylist_check(retained_entries, (mark_names.length - i - 1) * 2, string_mark_names, 55 'Second loop: checking entries after removing "' + mark_names[i] + '". '); 56 test_equals(non_retained_entries.length, 0, 57 'Second loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); 58 } 59 60 // Following cases test clear functionality when mark names are tied for two times. 61 mark_names.forEach(function(name) { 62 performance.mark(name); 63 }); 64 mark_names.forEach(function(name) { 65 performance.mark(name); 66 }); 67 var entry_number_before_useless_clear = performance.getEntriesByType('Mark').length; 68 performance.clearMarks('NonExist'); 69 var entry_number_after_useless_clear = performance.getEntriesByType('Mark').length; 70 test_equals(entry_number_before_useless_clear, entry_number_after_useless_clear, 'Nothing should happen if we clear a non-exist mark.'); 71 72 performance.clearMarks(); 73 test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist when we clear all.'); 74 75 done(); 76} 77</script> 78</head> 79<body onload=onload_test()> 80 <h1>Description</h1> 81 <p>This test validates functionality of the interface window.performance.clearMarks.</p> 82 <div id="log"></div> 83</body> 84</html> 85