| Nicolas Pena | 5170483 | 2018-04-12 19:56:32 | [diff] [blame^] | 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> |
| 14 | setup({ explicit_done: true }); |
| 15 | |
| 16 | function 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(performance.mark, performance); |
| 21 | |
| 22 | for (let i = 0; i < mark_names.length; ++i) |
| 23 | { |
| 24 | performance.clearMarks(mark_names[i]); |
| 25 | const retained_entries = performance.getEntriesByType('mark'); |
| 26 | const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); |
| 27 | entrylist_checker.entrylist_check(retained_entries, mark_names.length - i - 1, string_mark_names, |
| 28 | 'First loop: checking entries after removing "' + mark_names[i] + '". '); |
| 29 | test_equals(non_retained_entries.length, 0, |
| 30 | 'First loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); |
| 31 | } |
| 32 | |
| 33 | mark_names.forEach(performance.mark, performance); |
| 34 | performance.clearMarks(); |
| 35 | test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist after we clear all.'); |
| 36 | |
| 37 | // Following cases test clear existed mark name that is tied for two times. |
| 38 | mark_names.forEach(performance.mark, performance); |
| 39 | mark_names.forEach(performance.mark, performance); |
| 40 | |
| 41 | for (let i = 0; i < mark_names.length; ++i) |
| 42 | { |
| 43 | performance.clearMarks(mark_names[i]); |
| 44 | const retained_entries = performance.getEntriesByType('mark'); |
| 45 | const non_retained_entries = performance.getEntriesByName(mark_names[i], 'mark'); |
| 46 | entrylist_checker.entrylist_check(retained_entries, (mark_names.length - i - 1) * 2, string_mark_names, |
| 47 | 'Second loop: checking entries after removing "' + mark_names[i] + '". '); |
| 48 | test_equals(non_retained_entries.length, 0, |
| 49 | 'Second loop: marks that we cleared for "' + mark_names[i] + '" should not exist anymore.'); |
| 50 | } |
| 51 | |
| 52 | // Following cases test clear functionality when mark names are tied for two times. |
| 53 | mark_names.forEach(performance.mark, performance); |
| 54 | mark_names.forEach(performance.mark, performance); |
| 55 | var entry_number_before_useless_clear = performance.getEntriesByType('Mark').length; |
| 56 | performance.clearMarks('NonExist'); |
| 57 | var entry_number_after_useless_clear = performance.getEntriesByType('Mark').length; |
| 58 | test_equals(entry_number_before_useless_clear, entry_number_after_useless_clear, 'Nothing should happen if we clear a non-exist mark.'); |
| 59 | |
| 60 | performance.clearMarks(); |
| 61 | test_equals(performance.getEntriesByType('mark').length, 0, 'No marks should exist when we clear all.'); |
| 62 | |
| 63 | done(); |
| 64 | } |
| 65 | </script> |
| 66 | </head> |
| 67 | <body onload=onload_test()> |
| 68 | <h1>Description</h1> |
| 69 | <p>This test validates functionality of the interface window.performance.clearMarks.</p> |
| 70 | <div id="log"></div> |
| 71 | </body> |
| 72 | </html> |