Skip to content

Commit

Permalink
Bug 1497681 [wpt PR 13437] - Fix flakiness in resource_timing_buffer_…
Browse files Browse the repository at this point in the history
…full_250, a=testonly

Automatic update from web-platform-testsFix flakiness in resource_timing_buffer_full_250

This CL uses document fragments to append scripts faster. Also, we do
not need to wait until onload of one script to begin appending the next.

Bug: 626703, 883837
Change-Id: I0bc010640793d6a7113d404f2838fd5cfe88ab25
Reviewed-on: https://chromium-review.googlesource.com/c/1265901
Reviewed-by: Timothy Dresser <[email protected]>
Commit-Queue: Nicolás Peña Moreno <[email protected]>
Cr-Commit-Position: refs/heads/master@{#598896}

--

wpt-commits: ed3b742cd294a5d39d40bc4f8271e9ebe864245f
wpt-pr: 13437
  • Loading branch information
npm1 authored and moz-wptsync-bot committed Oct 17, 2018
1 parent 657a3f3 commit 54f4791
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@
function() {
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
let counter = performance.getEntriesByType("resource").length;
function appendScript() {
const src = "resources/empty.js?" + counter;
const script = document.createElement('script');
script.type = 'text/javascript';
script.onload = function() { ++counter; appendScript()};
script.src = src;
document.body.appendChild(script);
function appendScripts() {
const documentFragment = document.createDocumentFragment();
// Add 100 elements at a time to avoid page reflow every time.
let numScriptsAccumulated = 0;
while (numScriptsAccumulated < 100) {
const src = "resources/empty.js?" + counter;
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
documentFragment.appendChild(script);
++counter;
++numScriptsAccumulated;
}
document.body.appendChild(documentFragment);
t.step_timeout(appendScripts, 20);
}
appendScript();
appendScripts();
});
</script>
</body>
Expand Down

0 comments on commit 54f4791

Please sign in to comment.