mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
Tests/LibWeb: Prevent flake with iframe loading in gamepad-iframe.html
If `sendMessageAndWait` sends a message before the iframe is setup and listening we would wait indefinitely making the test timeout.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
0664e9fbf5
commit
5dbb857c40
Notes:
github-actions[bot]
2025-11-17 16:22:39 +00:00
Author: https://github.com/lpas Commit: https://github.com/LadybirdBrowser/ladybird/commit/5dbb857c40e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6829 Reviewed-by: https://github.com/gmta ✅
@@ -30,14 +30,22 @@
|
||||
|
||||
const sendMessageAndWait = (message) => {
|
||||
return new Promise((resolve) => {
|
||||
window.onmessage = ({ data }) => {
|
||||
const listener = ({ data }) => {
|
||||
window.removeEventListener('message', listener);
|
||||
resolve(data);
|
||||
};
|
||||
|
||||
window.addEventListener('message', listener);
|
||||
testIframe.contentWindow.postMessage(message, "*");
|
||||
});
|
||||
};
|
||||
|
||||
// wait for the iframe to be ready
|
||||
await new Promise((resolve) => {
|
||||
testIframe.addEventListener('load', resolve);
|
||||
if (testIframe.contentDocument.readyState === 'complete')
|
||||
resolve();
|
||||
});
|
||||
|
||||
const gamepad = internals.connectVirtualGamepad();
|
||||
await handleSDLInputEvents();
|
||||
listenForGamepadConnected();
|
||||
|
||||
Reference in New Issue
Block a user