[FIX] web: fix undeterministically failing test

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) <mcm@odoo.com>
This commit is contained in:
Bruno Boi
2023-06-30 13:08:31 +02:00
parent f027e10100
commit 190c0cc215
@@ -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 = `<div id="inner-container" />`;
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, {