diff --git a/testing/web-platform/tests/resource-timing/buffer-full-add-after-full-event.html b/testing/web-platform/tests/resource-timing/buffer-full-add-after-full-event.html new file mode 100644 index 000000000000..07897b5d28df --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-add-after-full-event.html @@ -0,0 +1,77 @@ + + + + + +This test validates that setResourceTimingBufferFull behaves appropriately when set to the current buffer level. + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback-that-drop.html b/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback-that-drop.html new file mode 100644 index 000000000000..d61d2af05c67 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback-that-drop.html @@ -0,0 +1,51 @@ + + + + +This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback.html b/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback.html new file mode 100644 index 000000000000..b37c47b23fb5 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-add-entries-during-callback.html @@ -0,0 +1,50 @@ + + + + +This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-add-then-clear.html b/testing/web-platform/tests/resource-timing/buffer-full-add-then-clear.html new file mode 100644 index 000000000000..710852ced55f --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-add-then-clear.html @@ -0,0 +1,49 @@ + + + + +This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-decrease-buffer-during-callback.html b/testing/web-platform/tests/resource-timing/buffer-full-decrease-buffer-during-callback.html new file mode 100644 index 000000000000..e6de33ded1b7 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-decrease-buffer-during-callback.html @@ -0,0 +1,49 @@ + + + + +This test validates that decreasing the buffer size in onresourcetimingbufferfull callback does not result in extra entries being dropped. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-increase-buffer-during-callback.html b/testing/web-platform/tests/resource-timing/buffer-full-increase-buffer-during-callback.html new file mode 100644 index 000000000000..b46d2d65690a --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-increase-buffer-during-callback.html @@ -0,0 +1,49 @@ + + + + +This test validates increasing the buffer size in onresourcetimingbufferfull callback of resource timing. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-inspect-buffer-during-callback.html b/testing/web-platform/tests/resource-timing/buffer-full-inspect-buffer-during-callback.html new file mode 100644 index 000000000000..d46d4692a55b --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-inspect-buffer-during-callback.html @@ -0,0 +1,56 @@ + + + + +This test validates the buffer doesn't contain more entries than it should inside onresourcetimingbufferfull callback. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-set-to-current-buffer.html b/testing/web-platform/tests/resource-timing/buffer-full-set-to-current-buffer.html new file mode 100644 index 000000000000..1e5486ec2cdf --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-set-to-current-buffer.html @@ -0,0 +1,82 @@ + + + + + +This test validates that setResourceTimingBufferFull behaves appropriately when set to the current buffer level. + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-store-and-clear-during-callback.html b/testing/web-platform/tests/resource-timing/buffer-full-store-and-clear-during-callback.html new file mode 100644 index 000000000000..f0791cba6b39 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-store-and-clear-during-callback.html @@ -0,0 +1,55 @@ + + + + +This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing. + + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-then-increased.html b/testing/web-platform/tests/resource-timing/buffer-full-then-increased.html new file mode 100644 index 000000000000..2265077fc15a --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-then-increased.html @@ -0,0 +1,44 @@ + + + + +This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled. + + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/buffer-full-when-populate-entries.html b/testing/web-platform/tests/resource-timing/buffer-full-when-populate-entries.html new file mode 100644 index 000000000000..00d2ae0e4426 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/buffer-full-when-populate-entries.html @@ -0,0 +1,46 @@ + + + + + + +This test validates the functionality of onresourcetimingbufferfull in resource timing. + + + + + + + + diff --git a/testing/web-platform/tests/resource-timing/resource_timing_buffer_full_when_populate_entries.html b/testing/web-platform/tests/resource-timing/resource_timing_buffer_full_when_populate_entries.html deleted file mode 100644 index 3e62b199a32b..000000000000 --- a/testing/web-platform/tests/resource-timing/resource_timing_buffer_full_when_populate_entries.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -This test validates the functionality of onresourcetimingbufferfull in resource timing. - - - - - - - - - diff --git a/testing/web-platform/tests/resource-timing/resource_timing_store_and_clear_during_callback.html b/testing/web-platform/tests/resource-timing/resource_timing_store_and_clear_during_callback.html deleted file mode 100644 index 218fc0c2bcd5..000000000000 --- a/testing/web-platform/tests/resource-timing/resource_timing_store_and_clear_during_callback.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - -This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing. - - - - - - - - - - - diff --git a/testing/web-platform/tests/resource-timing/resources/buffer-full-utilities.js b/testing/web-platform/tests/resource-timing/resources/buffer-full-utilities.js new file mode 100644 index 000000000000..b143da7b325f --- /dev/null +++ b/testing/web-platform/tests/resource-timing/resources/buffer-full-utilities.js @@ -0,0 +1,58 @@ +let appendScript = (src, resolve) => { + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = src; + script.onload = resolve; + document.body.appendChild(script); +} + +let xhrScript = src => { + var xhr = new XMLHttpRequest(); + xhr.open("GET", src, false); + xhr.send(null); +} + +let waitForNextTask = () => { + return new Promise(resolve => { + step_timeout(resolve, 0); + }); +}; + +let waitForEventToFire = () => { + return new Promise(resolve => { + let waitForIt = function() { + if (eventFired) { + eventFired = false; + resolve(); + } else { + step_timeout(waitForIt, 0); + } + } + step_timeout(waitForIt, 0); + }); +}; + +let clearBufferAndSetSize = size => { + performance.clearResourceTimings(); + performance.setResourceTimingBufferSize(size); +} + +let fillUpTheBufferWithSingleResource = src => { + return new Promise(resolve => { + // This resource gets buffered in the resource timing entry buffer. + appendScript(src, resolve); + }); +}; + +let loadResource = src => { + return new Promise(resolve => { + appendScript(src, resolve); + }); +}; + +let fillUpTheBufferWithTwoResources = async src => { + // These resources get buffered in the resource timing entry buffer. + await loadResource(src); + await loadResource(src + '?second'); +}; + diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js b/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js index a752b436524e..cac327c34bf9 100644 --- a/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js +++ b/testing/web-platform/tests/service-workers/service-worker/resources/performance-timeline-worker.js @@ -44,19 +44,13 @@ promise_test(function(test) { assert_greater_than(entry.startTime, 0); assert_greater_than(entry.responseEnd, entry.startTime); } - return Promise.race([ - new Promise(function(resolve) { + return new Promise(function(resolve) { performance.onresourcetimingbufferfull = _ => { resolve('bufferfull'); } performance.setResourceTimingBufferSize(expectedResources.length); - }), - - // Race the bufferfull event against another fetch. We should get the - // event before this completes. This allows us to detect a failure - // to dispatch the event without timing out the entire test. - fetch('dummy.txt').then(resp => resp.text()) - ]); + fetch('dummy.txt'); + }); }) .then(function(result) { assert_equals(result, 'bufferfull');