From f6ce449fea773cd69f7a165881d5fc2ed6d248c3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 5 Jul 2021 16:24:23 +0200 Subject: [PATCH] [test/driver.js] Ensure that Image `src` is set *after* the callbacks in `resolveImages` *While I cannot guarantee that this will fix the recent intermittents, this patch really shouldn't hurt.* By setting the Image `src` first, there's a small possibility that the Image is loaded *before* we've had a change to attach the `onload`/`onerror` callbacks which may cause the Promise to remain in a pending state. Note that prior to PR 13641 we didn't correctly await all image resources to actually load, which could explain the very recent intermittent test-failures. --- test/driver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/driver.js b/test/driver.js index 7284bcd78b174..26e0d48da8cf3 100644 --- a/test/driver.js +++ b/test/driver.js @@ -97,7 +97,6 @@ async function resolveImages(node, silentErrors = false) { const loadedPromises = []; for (let i = 0, ii = data.length; i < ii; i++) { - images[i].src = data[i]; loadedPromises.push( new Promise(function (resolveImage, rejectImage) { images[i].onload = resolveImage; @@ -108,6 +107,7 @@ async function resolveImages(node, silentErrors = false) { rejectImage(new Error("Error loading image " + e)); } }; + images[i].src = data[i]; }) ); }