diff --git a/Tests/LibWeb/Text/expected/window-scroll-while-parsing.txt b/Tests/LibWeb/Text/expected/window-scroll-while-parsing.txt new file mode 100644 index 0000000000..d62176687c --- /dev/null +++ b/Tests/LibWeb/Text/expected/window-scroll-while-parsing.txt @@ -0,0 +1 @@ +PASS (didn't crash) \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/window-scroll-while-parsing.html b/Tests/LibWeb/Text/input/window-scroll-while-parsing.html new file mode 100644 index 0000000000..208ca888f6 --- /dev/null +++ b/Tests/LibWeb/Text/input/window-scroll-while-parsing.html @@ -0,0 +1,5 @@ +
PASS (didn't crash) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 8f49b15a4e..e3d792300a 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1273,6 +1273,12 @@ void Window::scroll(ScrollToOptions const& options) auto viewport_height = viewport_rect.height(); auto const document = top_level_traversable->active_document(); + VERIFY(document); + + // Make sure layout is up-to-date before looking at scrollable overflow metrics. + document->update_layout(); + + VERIFY(document->paintable_box()); auto scrolling_area = document->paintable_box()->scrollable_overflow_rect()->to_type