From 813c66403d287225fadbdfcceb83100bad7964e8 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 5 Feb 2024 03:26:05 -0700 Subject: [PATCH] LibWeb: Catch null browsing context in destroy_top_level_traversable When WebDriver asks to destroy a window, we can hit this case with no active browsing context. This seems odd, but perhaps is a spec issue as well. Just log to dbgln for now. --- Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 72731b5f99e..5e05f97ca62 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -888,7 +888,11 @@ void TraversableNavigable::destroy_top_level_traversable() } // 3. Remove browsingContext. - browsing_context->remove(); + if (!browsing_context) { + dbgln("TraversableNavigable::destroy_top_level_traversable: No browsing context?"); + } else { + browsing_context->remove(); + } // 4. Remove traversable from the user interface (e.g., close or hide its tab in a tabbed browser). page().client().page_did_close_top_level_traversable();