mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
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:
committed by
Alexander Kalenik
parent
84e72243d4
commit
b36f2361f1
Notes:
github-actions[bot]
2026-03-31 07:49:24 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/b36f2361f1e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8687 Reviewed-by: https://github.com/shannonbooth
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user