blob: 8e1762c147dccf2a4e38898cb3c2c1ed03e2617c [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head onload>
<meta charset="utf-8" />
<title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/append.js"></script>
</head>
<body>
<script>
const resource_timing_buffer_size = 1;
const t = async_test("Verify that adding entries and then increasing the size of the resource timing buffer results in entries added in the right order");
performance.clearResourceTimings();
performance.addEventListener('resourcetimingbufferfull', t.unreached_func("resourcetimingbufferfull should not fire"));
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
// This resource gets buffered in the resource timing entry buffer.
xhrScript('resources/empty.js?xhr');
// These resources overflow the entry buffer, and goes into the secondary buffer.
xhrScript('resources/empty.js?xhr2');
xhrScript('resources/empty.js?xhr3');
performance.setResourceTimingBufferSize(3);
window.onload = t.step_timeout(()=>{
let entries = performance.getEntriesByType('resource');
assert_equals(entries.length, 3,
'All resources should be in the buffer, since its size was increased');
assert_true(entries[0].name.includes('empty.js?xhr'), "empty.js?xhr2 is in the entries buffer");
assert_true(entries[1].name.includes('empty.js?xhr2'), "empty.js?xhr3 is in the entries buffer");
assert_true(entries[2].name.includes('empty.js?xhr3'), "empty.js?xhr3 is in the entries buffer");
t.done();
}, 0);
</script>
</body>
</html>