mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
WebDriver: Don't remove windows if attempting to close the window failed
For example, if a dialog is open and the session is configured to ignore dialogs (instead of automatically closing them), then the Close Window endpoint will have failed. We can't remove the client-side window handle in that case.
This commit is contained in:
parent
7f4d2ef0d6
commit
4c61ce5b10
Notes:
github-actions[bot]
2024-11-05 19:07:03 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/4c61ce5b107 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2176 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 5 additions and 5 deletions
|
@ -193,15 +193,15 @@ Web::WebDriver::Response Session::set_timeouts(JsonValue payload)
|
|||
// 11.2 Close Window, https://w3c.github.io/webdriver/#dfn-close-window
|
||||
Web::WebDriver::Response Session::close_window()
|
||||
{
|
||||
{
|
||||
// Defer removing the window handle from this session until after we know we are done with its connection.
|
||||
ScopeGuard guard { [this] { m_windows.remove(m_current_window_handle); m_current_window_handle = "NoSuchWindowPleaseSelectANewOne"_string; } };
|
||||
|
||||
// 3. Close the current top-level browsing context.
|
||||
TRY(perform_async_action([&](auto& connection) {
|
||||
return connection.close_window();
|
||||
}));
|
||||
|
||||
{
|
||||
// Defer removing the window handle from this session until after we know we are done with its connection.
|
||||
ScopeGuard guard { [this] { m_windows.remove(m_current_window_handle); m_current_window_handle = "NoSuchWindowPleaseSelectANewOne"_string; } };
|
||||
|
||||
// 4. If there are no more open top-level browsing contexts, then close the session.
|
||||
if (m_windows.size() == 1)
|
||||
m_client->close_session(session_id());
|
||||
|
|
Loading…
Reference in a new issue