Files
ladybird/Tests/LibWeb/Text/input/css/element-requires-update-if-navigable-container-does.html
Aliaksandr Kalenik b36f2361f1 Tests: Fix flaky iframe srcdoc test to wait for actual content
The test checked iframe.contentDocument?.readyState !== "complete" to
decide whether to wait for the iframe's load event. However, the
initial about:blank document has readyState "complete", so this check
passes immediately even when the srcdoc navigation hasn't activated
yet. Under heavy load with sanitizers, the srcdoc document activation
is delayed long enough for the test to proceed with the about:blank
document, causing a TypeError when querySelector("#target") returns
null.

Fix by waiting for the actual srcdoc content to appear rather than
relying on readyState. Use a while loop with { once: true } load
event listeners to handle the case where multiple load events fire
(one for about:blank, one for srcdoc).
2026-03-31 09:47:59 +02:00

42 lines
960 B
HTML

<!doctype html>
<style>
iframe {
width: 50px;
height: 0px;
}
</style>
<iframe
id="iframe"
srcdoc="
<div id=target></div>
<style>
#target {
order: calc(100vh / 1px);
}
</style>
"
></iframe>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
while (!iframe.contentDocument?.querySelector("#target"))
await new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
requestAnimationFrame(() => {
requestAnimationFrame(() => {
const target = iframe.contentDocument.querySelector("#target");
println(getComputedStyle(target).order);
for (let height of [1, 2, 3]) {
iframe.style.height = `${height}px`;
println(getComputedStyle(target).order);
}
done();
});
});
});
</script>