mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
make sure async test is dispatched
Better than `testing.expectEqual(true, true)`.
This commit is contained in:
@@ -493,18 +493,22 @@
|
|||||||
|
|
||||||
<script id="document-element-load">
|
<script id="document-element-load">
|
||||||
{
|
{
|
||||||
|
let asyncBlockDispatched = false;
|
||||||
const docElement = document.documentElement;
|
const docElement = document.documentElement;
|
||||||
|
|
||||||
testing.async(async () => {
|
testing.async(async () => {
|
||||||
const result = await new Promise(resolve => {
|
const result = await new Promise(resolve => {
|
||||||
// We should get this fired at capturing phase when a resource loaded.
|
// 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);
|
testing.expectEqual(e.eventPhase, Event.CAPTURING_PHASE);
|
||||||
resolve(true);
|
return resolve(true);
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncBlockDispatched = true;
|
||||||
testing.expectEqual(true, result);
|
testing.expectEqual(true, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testing.eventually(() => testing.expectEqual(true, asyncBlockDispatched));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user