blob: dc527b9a32f5149fde4be86d3b2ae5d81fd2d4c7 [file] [log] [blame]
Yoav Weiss79001b12018-12-12 17:16:561<!DOCTYPE HTML>
2<html>
3<head>
4<meta charset="utf-8">
Yoav Weiss79001b12018-12-12 17:16:565<title>This test validates that setResourceTimingBufferFull behaves appropriately when set to the current buffer level.</title>
Nicolás Peña Moreno8a1c14c2021-05-27 22:27:506<link rel="author" title="Google" href="http://www.google.com/" />
7<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#dom-performance-onresourcetimingbufferfull">
Yoav Weiss79001b12018-12-12 17:16:568<script src="/resources/testharness.js"></script>
9<script src="/resources/testharnessreport.js"></script>
Nicolás Peña Moreno8a1c14c2021-05-27 22:27:5010<script src="resources/resource-loaders.js"></script>
Yoav Weiss79001b12018-12-12 17:16:5611<script src="resources/buffer-full-utilities.js"></script>
12</head>
13<body>
14<script>
Yoav Weiss79001b12018-12-12 17:16:5615promise_test(async () => {
Nicolás Peña Moreno8a1c14c2021-05-27 22:27:5016 let result = '';
17 performance.addEventListener('resourcetimingbufferfull', () => {
18 result += 'Event Fired with ' +
19 performance.getEntriesByType('resource').length + ' entries.';
20 performance.clearResourceTimings();
21 });
22 result += 'Before adding entries. ';
23 await fillUpTheBufferWithTwoResources();
24 result += 'After adding entries. ';
25 load.script(scriptResources[2]);
26 await bufferFullFirePromise;
27 assert_equals(result, 'Before adding entries. After adding entries. Event Fired with 2 entries.');
28 const entries = performance.getEntriesByType('resource');
29 assert_equals(entries.length, 1,
30 'Number of entries in resource timing buffer is unexpected');
31 assert_true(entries[0].name.includes(scriptResources[2]),
32 'The entry must correspond to the last resource loaded.')
33}, "Test that adding entries and firing the buffer full event happen in the right order.");
Yoav Weiss79001b12018-12-12 17:16:5634</script>