Skip to content

Truly independent web browser

Tests/LibWeb: Wait for cross-origin frames’ answers, not a timer

sideshowbarkerb9e61ab91834
diff --git a/Tests/LibWeb/Text/input/notifications/request-permission-cross-origin-iframe.html b/Tests/LibWeb/Text/input/notifications/request-permission-cross-origin-iframe.html
index b8b6c28ace1..759b8e15f2a 100644
--- a/Tests/LibWeb/Text/input/notifications/request-permission-cross-origin-iframe.html
+++ b/Tests/LibWeb/Text/input/notifications/request-permission-cross-origin-iframe.html
@@ -19,8 +19,8 @@
internals.setNextPermissionPromptOutcome("notifications", "allow");
const iframe = document.createElement("iframe");
iframe.src = frameURL.href;
+ // Wait for the frame's answer itself rather than for a fixed time, since its process can take a while to start.
const result = await new Promise(resolve => {
- setTimeout(() => resolve("no answer"), 2000);
addEventListener("message", event => {
// The frame lives in its own process, so the click has to travel through the UI process to reach it.
if (event.data === "ready")
diff --git a/Tests/LibWeb/Text/input/notifications/ui-refuses-prompt-from-cross-origin-frame.html b/Tests/LibWeb/Text/input/notifications/ui-refuses-prompt-from-cross-origin-frame.html
index 44c01a5d307..f1d2c568d27 100644
--- a/Tests/LibWeb/Text/input/notifications/ui-refuses-prompt-from-cross-origin-frame.html
+++ b/Tests/LibWeb/Text/input/notifications/ui-refuses-prompt-from-cross-origin-frame.html
@@ -19,8 +19,8 @@
internals.setNextPermissionPromptOutcome("notifications", "allow");
const iframe = document.createElement("iframe");
iframe.src = frameURL.href;
+ // Wait for the frame's answer itself rather than for a fixed time, since its process can take a while to start.
const result = await new Promise(resolve => {
- setTimeout(() => resolve("no answer"), 2000);
addEventListener("message", event => resolve(event.data));
document.body.appendChild(iframe);
});