mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
WebContent+WebDriver: Handle when new windows are immediately closed
This happens when window.close() is invoked immediately upon a window being opened.
This commit is contained in:
parent
556a0936dd
commit
ce11a90726
Notes:
github-actions[bot]
2024-10-06 00:43:31 +00:00
Author: https://github.com/trflynn89
Commit: ce11a90726
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1644
Reviewed-by: https://github.com/shannonbooth ✅
3 changed files with 14 additions and 3 deletions
|
@ -73,7 +73,14 @@ ErrorOr<NonnullRefPtr<Core::LocalServer>> Session::create_server(NonnullRefPtr<S
|
|||
dbgln("WebDriver is connected to WebContent socket");
|
||||
auto web_content_connection = maybe_connection.release_value();
|
||||
|
||||
auto window_handle = web_content_connection->get_window_handle();
|
||||
auto maybe_window_handle = web_content_connection->get_window_handle();
|
||||
if (maybe_window_handle.is_error()) {
|
||||
promise->reject(Error::from_string_literal("Window was closed immediately"));
|
||||
return;
|
||||
}
|
||||
|
||||
auto window_handle = MUST(String::from_byte_string(maybe_window_handle.value().as_string()));
|
||||
|
||||
web_content_connection->on_close = [this, window_handle]() {
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Window {} was closed remotely.", window_handle);
|
||||
m_windows.remove(window_handle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue