Skip to content

Truly independent web browser

Revert "WebDriver: Create new windows through the browser UI"

Andreas Klingca3df625d3d7
diff --git a/Libraries/LibWebView/HeadlessWebView.cpp b/Libraries/LibWebView/HeadlessWebView.cpp
index 96badc3827e..b7b5aa72267 100644
--- a/Libraries/LibWebView/HeadlessWebView.cpp
+++ b/Libraries/LibWebView/HeadlessWebView.cpp
@@ -81,10 +81,6 @@ HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSi
// A headless window is exactly its viewport, so every page gets the viewport as its window size.
m_window_size = viewport_size.to_type<int>();
- on_new_webdriver_window = [this](auto) {
- return NewWebDriverWindow { *create_view_for_new_tab_or_window(this->is_private()), NewWindowType::Tab };
- };
-
on_new_web_view = [this](auto, auto, CanonicalTraversable& traversable) {
auto web_view = HeadlessWebView::create_child(*this, traversable);
diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h
index b9680471832..85d09835eef 100644
--- a/Libraries/LibWebView/ViewImplementation.h
+++ b/Libraries/LibWebView/ViewImplementation.h
@@ -466,15 +466,6 @@ public:
Function<void()> on_ready_to_paint;
Function<void(TabPerformanceStats const&)> on_performance_stats;
- enum class NewWindowType {
- Tab,
- Window,
- };
- struct NewWebDriverWindow {
- ViewImplementation& view;
- NewWindowType type;
- };
- Function<NewWebDriverWindow(NewWindowType)> on_new_webdriver_window;
Function<String(Web::HTML::ActivateTab, Web::HTML::WebViewHints, CanonicalTraversable&)> on_new_web_view;
Function<void()> on_activate_tab;
Function<void()> on_close;
diff --git a/Libraries/LibWebView/WebDriverBrowserConnection.cpp b/Libraries/LibWebView/WebDriverBrowserConnection.cpp
index c3fa604b117..8d1a6a495a6 100644
--- a/Libraries/LibWebView/WebDriverBrowserConnection.cpp
+++ b/Libraries/LibWebView/WebDriverBrowserConnection.cpp
@@ -178,77 +178,6 @@ void WebDriverBrowserConnection::run_content_command(u64 command_id, String wind
view->run_webdriver_content_command(command_id, browsing_context, name, move(payload), move(arguments));
}
-// 11.5 New Window, https://w3c.github.io/webdriver/#dfn-new-window
-void WebDriverBrowserConnection::new_window(u64 command_id, String window_handle, JsonValue payload)
-{
- // 1. If the implementation does not support creating new top-level browsing contexts, return error with error code unsupported operation.
-
- // 2. If session's current top-level browsing context is no longer open, return error with error code no such window.
- auto view = ViewImplementation::find_view_by_handle(window_handle);
- if (!view.has_value()) {
- async_command_complete(command_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found"sv));
- return;
- }
- if (!view->on_new_webdriver_window) {
- async_command_complete(command_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, "Creating windows is not supported"sv));
- return;
- }
-
- // 3. Try to handle any user prompts with session.
- view->run_webdriver_user_prompt_handling([strong_this = NonnullRefPtr { *this }, command_id, view_id = view->view_id(), payload = move(payload)](Web::WebDriver::Response response) {
- if (response.is_error()) {
- strong_this->async_command_complete(command_id, move(response));
- return;
- }
- auto view = ViewImplementation::find_view_by_id(view_id);
- if (!view.has_value()) {
- strong_this->async_command_complete(command_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found"sv));
- return;
- }
-
- // 4. Let type hint be the result of getting the property "type" from parameters.
- if (!payload.is_object()) {
- strong_this->async_command_complete(command_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object"sv));
- return;
- }
- auto type_hint = payload.as_object().get("type"sv);
- if (type_hint.has_value() && !type_hint->is_null() && !type_hint->is_string()) {
- strong_this->async_command_complete(command_id, Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload property 'type' must be null or a string"sv));
- return;
- }
-
- // 5. Create a new top-level browsing context by running the window open steps with URL set to "about:blank",
- // target set to the empty string, and features set to "noopener" and the user agent configured to create a new
- // browsing context. This must be done without invoking the focusing steps for the created browsing context.
- // If type hint has the value "tab", and the implementation supports multiple browsing context in the same OS
- // window, the new browsing context should share an OS window with session's current browsing context. If type hint
- // is "window", and the implementation supports multiple browsing contexts in separate OS windows, the created
- // browsing context should be in a new OS window. In all other cases the details of how the browsing context is
- // presented to the user are implementation defined.
- // NB: The UI's new tab path creates an independent traversable with no opener and an initial about:blank document
- // in its own WebContent process, rather than opening a popup in the current page's process.
- using NewWindowType = ViewImplementation::NewWindowType;
- auto requested_type = type_hint.has_value() && type_hint->is_string() && type_hint->as_string() == "window"sv
- ? NewWindowType::Window
- : NewWindowType::Tab;
- auto new_window = view->on_new_webdriver_window(requested_type);
-
- // 6. Let handle be the associated window handle of the newly created window.
- auto handle = new_window.view.handle();
-
- // 7. Let type be "tab" if the newly created window shares an OS-level window with session's current browsing context, or "window" otherwise.
- auto type = new_window.type == NewWindowType::Tab ? "tab"sv : "window"sv;
-
- // 8. Let result be a new JSON Object initialized with:
- JsonObject result;
- result.set("handle"sv, move(handle));
- result.set("type"sv, type);
-
- // 9. Return success with data result.
- strong_this->async_command_complete(command_id, JsonValue { move(result) });
- });
-}
-
// 11.3 Switch to Window, https://w3c.github.io/webdriver/#dfn-switch-to-window
void WebDriverBrowserConnection::switch_to_window(u64 command_id, String window_handle)
{
diff --git a/Libraries/LibWebView/WebDriverBrowserConnection.h b/Libraries/LibWebView/WebDriverBrowserConnection.h
index 1328b79b1bf..37208dc9aa3 100644
--- a/Libraries/LibWebView/WebDriverBrowserConnection.h
+++ b/Libraries/LibWebView/WebDriverBrowserConnection.h
@@ -33,7 +33,6 @@ private:
virtual void get_session_history(u64 command_id, String window_handle) override;
virtual void load_url(u64 command_id, String window_handle, URL::URL url) override;
virtual void run_content_command(u64 command_id, String window_handle, Web::WebDriver::SessionBrowsingContext browsing_context, String name, JsonValue payload, Vector<String> arguments) override;
- virtual void new_window(u64 command_id, String window_handle, JsonValue payload) override;
virtual void switch_to_window(u64 command_id, String window_handle) override;
virtual void switch_to_parent_frame(u64 command_id, String window_handle) override;
virtual void set_current_browsing_context_to_top_level(u64 command_id, String window_handle) override;
diff --git a/Services/WebContent/WebDriverConnection.cpp b/Services/WebContent/WebDriverConnection.cpp
index 7472af864cc..25e681065d2 100644
--- a/Services/WebContent/WebDriverConnection.cpp
+++ b/Services/WebContent/WebDriverConnection.cpp
@@ -218,7 +218,7 @@ static bool fire_an_event(Utf16FlyString const& name, Optional<Web::DOM::Element
NonnullRefPtr<WebDriverConnection> WebDriverConnection::create(PageClient& page_client)
{
- // NB: Allow script-initiated pop-ups in WebDriver sessions.
+ // Allow pop-ups, or otherwise /window/new won't be able to open a new tab.
page_client.page().set_should_block_pop_ups(false);
return adopt_ref(*new WebDriverConnection(page_client));
@@ -298,6 +298,8 @@ void WebDriverConnection::run_command(u64 command_id, Optional<Web::HTML::CrossP
return asynchronous(get_title());
if (name == "close_window"sv)
return asynchronous(close_window());
+ if (name == "new_window"sv)
+ return asynchronous(new_window(move(payload)));
if (name == "switch_to_frame"sv)
return asynchronous(switch_to_frame(move(payload)));
if (name == "get_window_rect"sv)
@@ -494,6 +496,61 @@ Web::WebDriver::Response WebDriverConnection::close_window()
return JsonValue {};
}
+// 11.5 New Window, https://w3c.github.io/webdriver/#dfn-new-window
+Web::WebDriver::Response WebDriverConnection::new_window(JsonValue payload)
+{
+ // 1. If the implementation does not support creating new top-level browsing contexts, return error with error code unsupported operation.
+
+ // 2. If the current top-level browsing context is no longer open, return error with error code no such window.
+ TRY(ensure_current_top_level_browsing_context_is_open());
+
+ // 3. Handle any user prompts and return its value if it is an error.
+ handle_any_user_prompts([this, payload = move(payload)]() {
+ // 4. Let type hint be the result of getting the property "type" from the parameters argument.
+ if (!payload.is_object()) {
+ driver_execution_complete(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object"sv));
+ return;
+ }
+
+ // FIXME: Actually use this value to decide between an OS window or tab.
+ auto type_hint = payload.as_object().get("type"sv);
+ if (type_hint.has_value() && !type_hint->is_null() && !type_hint->is_string()) {
+ driver_execution_complete(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload property `type` is not null or a string"sv));
+ return;
+ }
+
+ // 5. Create a new top-level browsing context by running the window open steps with url set to "about:blank",
+ // target set to the empty string, and features set to "noopener" and the user agent configured to create a new
+ // browsing context. This must be done without invoking the focusing steps for the created browsing context. If
+ // type hint has the value "tab", and the implementation supports multiple browsing context in the same OS
+ // window, the new browsing context should share an OS window with the current browsing context. If type hint
+ // is "window", and the implementation supports multiple browsing contexts in separate OS windows, the
+ // created browsing context should be in a new OS window. In all other cases the details of how the browsing
+ // context is presented to the user are implementation defined.
+ auto* active_window = current_browsing_context().active_window();
+ VERIFY(active_window);
+
+ Web::HTML::TemporaryExecutionContext execution_context { active_window->document()->relevant_settings_object() };
+ auto [target_navigable, no_opener, window_type] = MUST(active_window->window_open_steps_internal("about:blank"sv, ""sv, "noopener"sv));
+
+ // 6. Let handle be the associated window handle of the newly created window.
+ auto handle = as<Web::HTML::LocalTraversableNavigable>(*target_navigable->traversable_navigable()).window_handle().to_utf8();
+
+ // 7. Let type be "tab" if the newly created window shares an OS-level window with the current browsing context, or "window" otherwise.
+ auto type = "tab"sv;
+
+ // 8. Let result be a new JSON Object initialized with:
+ JsonObject result;
+ result.set("handle"sv, JsonValue { handle });
+ result.set("type"sv, JsonValue { type });
+
+ // 9. Return success with data result.
+ driver_execution_complete({ move(result) });
+ });
+
+ return JsonValue {};
+}
+
// 11.6 Switch To Frame, https://w3c.github.io/webdriver/#dfn-switch-to-frame
Web::WebDriver::Response WebDriverConnection::switch_to_frame(JsonValue payload)
{
diff --git a/Services/WebContent/WebDriverConnection.h b/Services/WebContent/WebDriverConnection.h
index 6317dffc841..6c0929f5131 100644
--- a/Services/WebContent/WebDriverConnection.h
+++ b/Services/WebContent/WebDriverConnection.h
@@ -48,6 +48,7 @@ private:
Web::WebDriver::Response get_current_url();
Web::WebDriver::Response get_title();
Web::WebDriver::Response close_window();
+ Web::WebDriver::Response new_window(JsonValue payload);
Web::WebDriver::Response switch_to_frame(JsonValue payload);
Web::WebDriver::Response get_window_rect();
Web::WebDriver::Response set_window_rect(JsonValue payload);
diff --git a/Services/WebDriver/Client.cpp b/Services/WebDriver/Client.cpp
index e6870a77385..00bffcadbce 100644
--- a/Services/WebDriver/Client.cpp
+++ b/Services/WebDriver/Client.cpp
@@ -11,6 +11,8 @@
#include <AK/Debug.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
+#include <LibCore/EventLoop.h>
+#include <LibCore/Timer.h>
#include <LibURL/Parser.h>
#include <LibWebCommon/WebDriver/Capabilities.h>
#include <LibWebCommon/WebDriver/Error.h>
@@ -438,7 +440,66 @@ ResponsePromise Client::new_window(Web::WebDriver::Parameters parameters, JsonVa
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/window/new");
auto session = WEBDRIVER_TRY(Session::find_session(parameters[0]));
- return session->new_window(move(payload));
+ auto promise = WebDriverPromise::construct();
+ auto new_window_promise = session->run_top_level_content_command("new_window"sv, move(payload));
+ promise->add_child(new_window_promise);
+ new_window_promise->when_resolved([promise, session](JsonValue& handle_value) {
+ if (!handle_value.is_object()) {
+ promise->reject(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnknownError, "New Window response is not a JSON object"sv));
+ return;
+ }
+
+ auto handle_member = handle_value.as_object().get("handle"sv);
+ if (!handle_member.has_value() || !handle_member->is_string()) {
+ promise->reject(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnknownError, "New Window response does not contain a string 'handle' property"sv));
+ return;
+ }
+
+ auto handle = handle_member->as_string();
+ if (session->has_window_handle(handle)) {
+ promise->resolve(handle_value);
+ return;
+ }
+
+ static constexpr u32 CONNECTION_TIMEOUT_MS = 5000;
+ struct WaitState : public RefCounted<WaitState> {
+ Session::WindowHandleBecameAvailableCallbackID callback_id { 0 };
+ RefPtr<Core::Timer> timer;
+ bool settled { false };
+ };
+ auto wait_state = adopt_ref(*new WaitState);
+ wait_state->timer = Core::Timer::create_single_shot(AK::Duration::from_milliseconds(CONNECTION_TIMEOUT_MS), [promise, session, handle, wait_state] {
+ if (wait_state->settled)
+ return;
+ wait_state->settled = true;
+ Core::deferred_invoke([session, handle, wait_state] {
+ session->remove_window_handle_became_available_callback(handle, wait_state->callback_id);
+ wait_state->timer = nullptr;
+ });
+ promise->reject(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::Timeout, "Timed out waiting for window handle"sv));
+ });
+
+ auto handle_response = handle_value;
+ wait_state->callback_id = session->add_window_handle_became_available_callback(handle, [promise, handle_response = move(handle_response), wait_state]() mutable {
+ if (wait_state->settled)
+ return;
+ auto timer = move(wait_state->timer);
+ wait_state->settled = true;
+ if (timer)
+ timer->stop();
+ promise->resolve(move(handle_response)); }, [promise, wait_state] {
+ if (wait_state->settled)
+ return;
+ wait_state->settled = true;
+ if (auto timer = move(wait_state->timer))
+ timer->stop();
+ promise->reject(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnknownError, "Browser connection lost"sv)); });
+ wait_state->timer->start();
+ })
+ .when_rejected([promise](Web::WebDriver::Error& error) {
+ promise->reject(Web::WebDriver::Error(error));
+ });
+ return promise;
}
// 11.6 Switch To Frame, https://w3c.github.io/webdriver/#dfn-switch-to-frame
diff --git a/Services/WebDriver/Session.cpp b/Services/WebDriver/Session.cpp
index c17f6856cda..5fde184145d 100644
--- a/Services/WebDriver/Session.cpp
+++ b/Services/WebDriver/Session.cpp
@@ -376,6 +376,11 @@ void Session::close()
// 4. Perform any implementation-specific cleanup steps.
reject_start_promise(Error::from_string_literal("Session closed during browser startup"));
reject_pending_browser_commands();
+ auto window_handle_callbacks = move(m_window_handle_became_available_callbacks);
+ for (auto& callbacks : window_handle_callbacks) {
+ for (auto& callback : callbacks.value)
+ callback.on_session_close();
+ }
if (m_browser_connection) {
m_browser_connection->on_close = nullptr;
m_browser_connection->on_did_create_window = nullptr;
@@ -427,6 +432,7 @@ ErrorOr<void> Session::accept_browser_transport(NonnullOwnPtr<IPC::Transport> tr
if (m_current_window_handle.is_empty())
m_current_window_handle = window_handle;
+ dispatch_window_handle_became_available_callbacks(window_handle);
if (auto start_promise = move(m_start_promise))
start_promise->resolve({});
};
@@ -738,11 +744,11 @@ NonnullRefPtr<Session::WebDriverPromise> Session::close_window()
auto promise = WebDriverPromise::construct();
// 3. Close the current top-level browsing context.
- auto closed_window_handle = m_current_window_handle;
auto close_window_promise = run_top_level_content_command("close_window"sv);
promise->add_child(close_window_promise);
- close_window_promise->when_resolved([this_ref = NonnullRefPtr { *this }, promise, closed_window_handle = move(closed_window_handle)](JsonValue&) {
+ close_window_promise->when_resolved([this_ref = NonnullRefPtr { *this }, promise](JsonValue&) {
// 4. If there are no more open top-level browsing contexts, then close the session.
+ auto closed_window_handle = this_ref->m_current_window_handle;
this_ref->remove_window(closed_window_handle);
// 5. Return the result of running the remote end steps for the Get Window Handles command.
@@ -758,14 +764,6 @@ NonnullRefPtr<Session::WebDriverPromise> Session::close_window()
return promise;
}
-// 11.5 New Window, https://w3c.github.io/webdriver/#dfn-new-window
-NonnullRefPtr<Session::WebDriverPromise> Session::new_window(JsonValue payload)
-{
- return perform_browser_command([this, payload = move(payload)](u64 command_id) mutable {
- m_browser_connection->async_new_window(command_id, m_current_window_handle, move(payload));
- });
-}
-
// 11.3 Switch to Window, https://w3c.github.io/webdriver/#dfn-switch-to-window
NonnullRefPtr<Session::WebDriverPromise> Session::switch_to_window(StringView handle)
{
@@ -803,6 +801,38 @@ Web::WebDriver::Response Session::get_window_handles() const
return JsonValue { move(handles) };
}
+void Session::dispatch_window_handle_became_available_callbacks(String const& window_handle)
+{
+ // Registrations are one-shot: take() erases them before invoking their callbacks.
+ auto callbacks = m_window_handle_became_available_callbacks.take(window_handle);
+ if (!callbacks.has_value())
+ return;
+
+ for (auto& callback : callbacks.value())
+ callback.callback();
+}
+
+Session::WindowHandleBecameAvailableCallbackID Session::add_window_handle_became_available_callback(String const& handle, Function<void()> callback, Function<void()> on_session_close)
+{
+ auto id = m_next_window_handle_became_available_callback_id++;
+ m_window_handle_became_available_callbacks.ensure(handle).append({ id, move(callback), move(on_session_close) });
+ return id;
+}
+
+void Session::remove_window_handle_became_available_callback(String const& handle, WindowHandleBecameAvailableCallbackID id)
+{
+ auto callbacks = m_window_handle_became_available_callbacks.find(handle);
+ if (callbacks == m_window_handle_became_available_callbacks.end())
+ return;
+
+ callbacks->value.remove_all_matching([id](auto const& callback) {
+ return callback.id == id;
+ });
+
+ if (callbacks->value.is_empty())
+ m_window_handle_became_available_callbacks.remove(callbacks);
+}
+
ErrorOr<void, Web::WebDriver::Error> Session::ensure_current_window_handle_is_valid() const
{
if (!m_windows.contains(m_current_window_handle))
diff --git a/Services/WebDriver/Session.h b/Services/WebDriver/Session.h
index 2caefabd271..017933c4c0c 100644
--- a/Services/WebDriver/Session.h
+++ b/Services/WebDriver/Session.h
@@ -74,10 +74,15 @@ public:
String const& current_window_handle() const { return m_current_window_handle; }
bool test_hooks_enabled() const { return m_options.enable_test_hooks; }
+ bool has_window_handle(StringView handle) const { return m_windows.contains(handle); }
+ using WindowHandleBecameAvailableCallbackID = u64;
+ // Registrations are dispatched at most once. Callers must remove them when handling a timeout.
+ WindowHandleBecameAvailableCallbackID add_window_handle_became_available_callback(String const& handle, Function<void()> callback, Function<void()> on_session_close);
+ void remove_window_handle_became_available_callback(String const& handle, WindowHandleBecameAvailableCallbackID);
+
Web::WebDriver::Response get_timeouts() const;
Web::WebDriver::Response set_timeouts(JsonValue);
NonnullRefPtr<WebDriverPromise> close_window();
- NonnullRefPtr<WebDriverPromise> new_window(JsonValue payload);
NonnullRefPtr<WebDriverPromise> switch_to_window(StringView);
Web::WebDriver::Response get_window_handles() const;
@@ -109,6 +114,7 @@ private:
NonnullRefPtr<WebDriverPromise> run_content_command(Web::WebDriver::SessionBrowsingContext, StringView name, JsonValue payload, Vector<String> arguments);
ErrorOr<void> create_server();
void remove_window(StringView window_handle);
+ void dispatch_window_handle_became_available_callbacks(String const& window_handle);
void reject_pending_browser_commands();
void arm_browser_startup_timeout(NonnullRefPtr<ServerPromise>);
void cancel_browser_startup_timeout();
@@ -159,6 +165,14 @@ private:
Web::WebDriver::TimeoutsConfiguration m_timeouts;
Optional<JsonValue> m_timeouts_configuration;
bool m_strict_file_interactiblity { false };
+
+ struct WindowHandleBecameAvailableCallback {
+ WindowHandleBecameAvailableCallbackID id;
+ Function<void()> callback;
+ Function<void()> on_session_close;
+ };
+ HashMap<String, Vector<WindowHandleBecameAvailableCallback>> m_window_handle_became_available_callbacks;
+ WindowHandleBecameAvailableCallbackID m_next_window_handle_became_available_callback_id { 1 };
};
NonnullRefPtr<Session::WebDriverPromise> continue_with_promise(NonnullRefPtr<Session::WebDriverPromise>, Function<NonnullRefPtr<Session::WebDriverPromise>()>);
diff --git a/Services/WebDriver/WebDriverBrowserClient.ipc b/Services/WebDriver/WebDriverBrowserClient.ipc
index db7425f0f37..46cb3898aa3 100644
--- a/Services/WebDriver/WebDriverBrowserClient.ipc
+++ b/Services/WebDriver/WebDriverBrowserClient.ipc
@@ -13,7 +13,6 @@ endpoint WebDriverBrowserClient {
get_session_history(u64 command_id, String window_handle) =|
load_url(u64 command_id, String window_handle, URL::URL url) =|
run_content_command(u64 command_id, String window_handle, Web::WebDriver::SessionBrowsingContext browsing_context, String name, JsonValue payload, Vector<String> arguments) =|
- new_window(u64 command_id, String window_handle, JsonValue payload) =|
switch_to_window(u64 command_id, String window_handle) =|
switch_to_parent_frame(u64 command_id, String window_handle) =|
set_current_browsing_context_to_top_level(u64 command_id, String window_handle) =|
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index 27634cbecd0..7e2c8ef9220 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -635,8 +635,7 @@ Optional<String> Application::system_font_family() const
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WindowConfiguration const& configuration, BrowserWindow::IsPopupWindow is_popup_window, WebView::IsPrivate is_private, Tab* parent_tab, Optional<WebView::CanonicalTraversable&> traversable, ShowWindow show_window, Optional<Web::HTML::PreparedNavigationDescriptor> initial_navigation)
{
auto* window = new BrowserWindow(initial_urls, is_popup_window, is_private, parent_tab, traversable);
- if (show_window != ShowWindow::WithoutActivating)
- set_active_window(*window);
+ set_active_window(*window);
QObject::connect(window, &QObject::destroyed, m_application.ptr(), [this, window] {
if (m_active_window == window)
m_active_window = nullptr;
@@ -649,18 +648,14 @@ BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, Win
}
window->set_window_rect(configuration.x, configuration.y, configuration.width, configuration.height);
- if (show_window != ShowWindow::No) {
- if (show_window == ShowWindow::WithoutActivating)
- window->setAttribute(Qt::WA_ShowWithoutActivating);
+ if (show_window == ShowWindow::Yes) {
if (configuration.maximized == true)
window->showMaximized();
else
window->show();
- if (show_window == ShowWindow::Yes) {
- window->activateWindow();
- window->raise();
- }
+ window->activateWindow();
+ window->raise();
}
size_t initial_url_index = 0;
diff --git a/UI/Qt/Application.h b/UI/Qt/Application.h
index 870d3ca9ce4..29ab8a57bb8 100644
--- a/UI/Qt/Application.h
+++ b/UI/Qt/Application.h
@@ -39,7 +39,6 @@ struct WindowConfiguration {
enum class ShowWindow {
No,
Yes,
- WithoutActivating,
};
class Application final : public WebView::Application {
diff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cpp
index cf455642014..7ff4e06cd81 100644
--- a/UI/Qt/BrowserWindow.cpp
+++ b/UI/Qt/BrowserWindow.cpp
@@ -605,16 +605,6 @@ void BrowserWindow::initialize_tab(Tab* tab)
}
});
- tab->view().on_new_webdriver_window = [this](WebView::ViewImplementation::NewWindowType type) {
- using NewWindowType = WebView::ViewImplementation::NewWindowType;
- if (type == NewWindowType::Window) {
- auto& window = Application::the().new_window({ URL::about_blank() }, Application::the().configuration_for_new_window(), IsPopupWindow::No, m_is_private, nullptr, {}, ShowWindow::WithoutActivating);
- return WebView::ViewImplementation::NewWebDriverWindow { window.current_tab()->view(), type };
- }
- auto& new_tab = create_new_tab(Web::HTML::ActivateTab::No, TabLocation::end());
- return WebView::ViewImplementation::NewWebDriverWindow { new_tab.view(), type };
- };
-
tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, WebView::CanonicalTraversable& traversable) {
if (hints.popup) {
auto cascaded_configuration = Application::the().configuration_for_new_window();