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).
This commit is contained in:
Aliaksandr Kalenik
2026-03-31 08:38:13 +02:00
committed by Alexander Kalenik
parent 84e72243d4
commit b36f2361f1
Notes: github-actions[bot] 2026-03-31 07:49:24 +00:00

View File

@@ -20,8 +20,8 @@
<script src="../include.js"></script>
<script>
asyncTest(async done => {
if (iframe.contentDocument?.readyState !== "complete")
await new Promise(resolve => iframe.addEventListener("load", resolve));
while (!iframe.contentDocument?.querySelector("#target"))
await new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
requestAnimationFrame(() => {
requestAnimationFrame(() => {