Bug 1497681 [wpt PR 13437] - Fix flakiness in resource_timing_buffer_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 <tdresser@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598896}

--

wpt-commits: ed3b742cd294a5d39d40bc4f8271e9ebe864245f
wpt-pr: 13437
This commit is contained in:
Nicolas Pena 2018-10-15 17:16:27 +00:00 коммит произвёл James Graham
Родитель cf8d2c4325
Коммит 2b7015a1a2
1 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -16,15 +16,23 @@
function() {
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
let counter = performance.getEntriesByType("resource").length;
function appendScript() {
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.onload = function() { ++counter; appendScript()};
script.src = src;
document.body.appendChild(script);
documentFragment.appendChild(script);
++counter;
++numScriptsAccumulated;
}
appendScript();
document.body.appendChild(documentFragment);
t.step_timeout(appendScripts, 20);
}
appendScripts();
});
</script>
</body>