Skip to content

Truly independent web browser

LibWeb: Only stop observing lazy iframes that are being observed

Andreas Kling9bf905ec09d7
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cpp
index 4457a8b5085..0cf0a4ed7ea 100644
--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp
+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp
@@ -3382,10 +3382,8 @@ void LocalNavigable::adopt_navigation_started_in_ui_process(Utf16String navigati
// then stop intersection-observing a lazy loading element container and set container's lazy load resumption steps to null.
if (container && container->is_html_iframe_element()) {
auto& iframe_element = static_cast<HTMLIFrameElement&>(*container);
- if (iframe_element.will_lazy_load_element()) {
- iframe_element.document().stop_intersection_observing_a_lazy_loading_element(iframe_element);
- iframe_element.set_lazy_load_resumption_steps(nullptr);
- }
+ if (iframe_element.will_lazy_load_element())
+ iframe_element.stop_lazy_loading();
}
// 15. If navigable's parent is non-null, then set navigable's is delaying load events to true.
@@ -3519,10 +3517,8 @@ void LocalNavigable::begin_navigation(PreparedNavigation navigation)
// then stop intersection-observing a lazy loading element container and set container's lazy load resumption steps to null.
if (container && container->is_html_iframe_element()) {
auto& iframe_element = static_cast<HTMLIFrameElement&>(*container);
- if (iframe_element.will_lazy_load_element()) {
- iframe_element.document().stop_intersection_observing_a_lazy_loading_element(iframe_element);
- iframe_element.set_lazy_load_resumption_steps(nullptr);
- }
+ if (iframe_element.will_lazy_load_element())
+ iframe_element.stop_lazy_loading();
}
// 12. If historyHandling is "auto", then:
diff --git a/Tests/LibWeb/Crash/HTML/lazy-iframe-without-src-navigated-by-name.html b/Tests/LibWeb/Crash/HTML/lazy-iframe-without-src-navigated-by-name.html
new file mode 100644
index 00000000000..1a5cfdca7a1
--- /dev/null
+++ b/Tests/LibWeb/Crash/HTML/lazy-iframe-without-src-navigated-by-name.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<!-- A lazy iframe without a src is never intersection-observed, so the document has no lazy load intersection observer
+ when the iframe is navigated. -->
+<html class="test-wait">
+<body>
+<iframe name="target" loading="lazy"></iframe>
+<script>
+ window.open("data:text/html,hi", "target");
+ requestAnimationFrame(() => requestAnimationFrame(() => document.documentElement.classList.remove("test-wait")));
+</script>
+</body>
+</html>