From 190c0cc215a862a30a5f5ee198dc6bb6779e0cd1 Mon Sep 17 00:00:00 2001 From: Bruno Boi Date: Fri, 30 Jun 2023 07:53:23 +0000 Subject: [PATCH] [FIX] web: fix undeterministically failing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since [1], a test introduced in [2] was failing undeterministically. **Explanation** Commit [1] introduced a positioning recomputation when a load event occur in the target's document. The failing test in [2] loads an inline stylesheet inside of an iframe without waiting for it to be loaded. When the test failed it was because of the "load" event of the aforementioned stylesheet that occured at an inappropriate moment. Now the test awaits for this event. Note that within the same conditions in the real world, we want to make sure the popper is repositioned. So this current fix is a bit cheating but the test is about testing an unrelated behavior, so this is acceptable IMO. Runbot error id: 22544 [1]: 532c4cfa4e60bc9531 [2]: 208a1277750d63eef3 closes odoo/odoo#126938 X-original-commit: 3ca170bf31ca6e6f12293f0dabe106d385773333 Signed-off-by: Michaƫl Mattiello (mcm) --- addons/web/static/tests/core/position_hook_tests.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/web/static/tests/core/position_hook_tests.js b/addons/web/static/tests/core/position_hook_tests.js index cdf987fd1af..aa845821a3f 100644 --- a/addons/web/static/tests/core/position_hook_tests.js +++ b/addons/web/static/tests/core/position_hook_tests.js @@ -472,10 +472,10 @@ QUnit.test("iframe: both popper and target inside", async (assert) => { const iframe = document.createElement("iframe"); Object.assign(iframe.style, IFRAME_STYLE); iframe.srcdoc = `
`; - const def = makeDeferred(); + let def = makeDeferred(); iframe.onload = def.resolve; container.appendChild(iframe); - await def; + await def; // wait for the iframe to be loaded const iframeBody = iframe.contentDocument.body; Object.assign(iframeBody.style, { ...FLEXBOX_STYLE, @@ -484,7 +484,9 @@ QUnit.test("iframe: both popper and target inside", async (assert) => { overflowX: "hidden", }); + def = makeDeferred(); const iframeSheet = iframe.contentDocument.createElement("style"); + iframeSheet.onload = def.resolve; iframeSheet.textContent = ` #popper { background-color: plum; @@ -493,6 +495,7 @@ QUnit.test("iframe: both popper and target inside", async (assert) => { } `; iframe.contentDocument.head.appendChild(iframeSheet); + await def; // wait for the iframe's stylesheet to be loaded const innerContainer = iframe.contentDocument.getElementById("inner-container"); Object.assign(innerContainer.style, {