buffer-full-store-and-clear-during-callback.html (1746B)
1 <!DOCTYPE HTML> 2 <html> 3 <head onload> 4 <meta charset="utf-8" /> 5 <title>This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.</title> 6 <link rel="author" title="Intel" href="http://www.intel.com/" /> 7 <link rel="help" href="https://www.w3.org/TR/resource-timing-2/#dom-performance-onresourcetimingbufferfull"/> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="resources/resource-loaders.js"></script> 11 <script src="resources/buffer-full-utilities.js"></script> 12 </head> 13 <body> 14 <script> 15 promise_test(async () => { 16 await fillUpTheBufferWithSingleResource(); 17 const entryBuffer = []; 18 performance.addEventListener('resourcetimingbufferfull', () => { 19 entryBuffer.push(...performance.getEntriesByType('resource')); 20 performance.clearResourceTimings(); 21 }); 22 load.script(scriptResources[1]); 23 await bufferFullFirePromise; 24 const entries = performance.getEntriesByType('resource'); 25 assert_equals(entries.length, 1, 26 "Only the last entry should be stored in resource timing buffer since it's cleared once it overflows."); 27 assert_true(entries[0].name.includes(scriptResources[1]), 28 scriptResources[1] + " is in the entries buffer"); 29 assert_equals(entryBuffer.length, 1, 30 '1 resource timing entry should be moved to entryBuffer.'); 31 assert_true(entryBuffer[0].name.includes(scriptResources[0]), 32 scriptResources[0] + ' is in the entryBuffer'); 33 }, "Test that entries overflowing the buffer trigger the buffer full event, can be stored, and make their way to the primary buffer after it's cleared in the buffer full event."); 34 </script> 35 </body> 36 </html>