Skip to content

Truly independent web browser

Tests/LibWebView: Stop relying on timing in the link hover test

Andreas Kling63557a7c0280
diff --git a/Tests/LibWebView/TestLinkHoverStatus.cpp b/Tests/LibWebView/TestLinkHoverStatus.cpp
index 7770db591a9..ec5d7225543 100644
--- a/Tests/LibWebView/TestLinkHoverStatus.cpp
+++ b/Tests/LibWebView/TestLinkHoverStatus.cpp
@@ -158,7 +158,6 @@ function navigate_frame() { frame.srcdoc = frame.getAttribute("srcdoc") + "<!--
VERIFY(hovered_url->serialize() == "https://example.com/in-iframe"sv);
view->run_javascript("navigate_frame()"_string);
Core::EventLoop::current().spin_until([&]() { return unhovers_reported >= 6; });
- VERIFY(!hovered_url.has_value());
Core::EventLoop::current().spin_until([&]() { return last_title == "frame load 2"sv; });
// The new iframe document's link is a fresh target. Then over to the page's own link: The iframe's handler hears
@@ -179,14 +178,13 @@ function navigate_frame() { frame.srcdoc = frame.getAttribute("srcdoc") + "<!--
VERIFY(hovered_url->serialize() == "https://example.com/parent"sv);
// Back over the iframe's link, then a new top-level document: The iframe dies along with the old one, and its
- // handler reports the link gone as the iframe's document is destroyed.
+ // handler reports the link gone as the iframe's document is destroyed. The iframe has the move ahead of the page, so
+ // the page may hover from the pointer's last position for a moment. What counts is that no link is left.
move_mouse_to(*view, { 20, 20 });
- Core::EventLoop::current().spin_until([&]() { return hovers_reported >= 9; });
- VERIFY(hovered_url->serialize() == "https://example.com/in-iframe"sv);
+ Core::EventLoop::current().spin_until([&]() { return hovered_url.has_value() && hovered_url->serialize() == "https://example.com/in-iframe"sv; });
view->load_html("<!DOCTYPE html><p>Plain</p>"sv);
- Core::EventLoop::current().spin_until([&]() { return unhovers_reported >= 8; });
+ Core::EventLoop::current().spin_until([&]() { return loads_finished >= 5; });
VERIFY(!hovered_url.has_value());
- VERIFY(hovers_reported == 9);
outln("PASS: a MouseLeave or a document replacement ends the link hover, and the next move over the link reports it again");
}