make sure async test is dispatched

Better than `testing.expectEqual(true, true)`.
This commit is contained in:
Halil Durak
2026-02-09 11:45:31 +03:00
parent a7882fa32b
commit 2e28e68c48

View File

@@ -493,18 +493,22 @@
<script id="document-element-load">
{
let asyncBlockDispatched = false;
const docElement = document.documentElement;
testing.async(async () => {
const result = await new Promise(resolve => {
// We should get this fired at capturing phase when a resource loaded.
docElement.addEventListener("load", (e) => {
docElement.addEventListener("load", e => {
testing.expectEqual(e.eventPhase, Event.CAPTURING_PHASE);
resolve(true);
return resolve(true);
}, true);
});
asyncBlockDispatched = true;
testing.expectEqual(true, result);
});
testing.eventually(() => testing.expectEqual(true, asyncBlockDispatched));
}
</script>