| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 1 | <!DOCTYPE HTML> |
| 2 | <html> |
| 3 | <head onload> |
| 4 | <meta charset="utf-8" /> |
| 5 | <title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title> |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 6 | <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 Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 8 | <script src="/resources/testharness.js"></script> |
| 9 | <script src="/resources/testharnessreport.js"></script> |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 10 | <script src="resources/resource-loaders.js"></script> |
| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 11 | <script src="resources/buffer-full-utilities.js"></script> |
| 12 | </head> |
| 13 | <body> |
| 14 | <script> |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 15 | promise_test(async t => { |
| 16 | addAssertUnreachedBufferFull(t); |
| 17 | await fillUpTheBufferWithSingleResource('resources/empty.js?willbelost'); |
| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 18 | // These resources overflow the entry buffer, and go into the secondary buffer. |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 19 | load.xhr_sync(scriptResources[0]); |
| 20 | load.xhr_sync(scriptResources[1]); |
| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 21 | performance.clearResourceTimings(); |
| 22 | performance.setResourceTimingBufferSize(3); |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 23 | load.xhr_sync(scriptResources[2]); |
| 24 | const entriesAfterAddition = performance.getEntriesByType('resource'); |
| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 25 | await waitForNextTask(); |
| Nicolás Peña Moreno | 8a1c14c | 2021-05-27 22:27:50 | [diff] [blame] | 26 | checkEntries(3); |
| 27 | assert_equals(entriesAfterAddition.length, 0, "No entries should have been added to the primary buffer before the task to 'fire a buffer full event'."); |
| Yoav Weiss | 79001b1 | 2018-12-12 17:16:56 | [diff] [blame] | 28 | }, "Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one"); |
| 29 | </script> |
| 30 | </body> |
| 31 | </html> |