diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index 2f56310eae..5bf6251d81 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -67,6 +68,9 @@ public: bool is_scripting_enabled() const { return m_is_scripting_enabled; } void set_is_scripting_enabled(bool b) { m_is_scripting_enabled = b; } + bool is_webdriver_active() const { return m_is_webdriver_active; } + void set_is_webdriver_active(bool b) { m_is_webdriver_active = b; } + private: PageClient& m_client; @@ -77,6 +81,10 @@ private: bool m_same_origin_policy_enabled { false }; bool m_is_scripting_enabled { true }; + + // https://w3c.github.io/webdriver/#dfn-webdriver-active-flag + // The webdriver-active flag is set to true when the user agent is under remote control. It is initially false. + bool m_is_webdriver_active { false }; }; class PageClient { diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 4ece205b89..f51b8a0a52 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -530,6 +530,11 @@ void OutOfProcessWebView::set_preferred_color_scheme(Web::CSS::PreferredColorSch client().async_set_preferred_color_scheme(color_scheme); } +void OutOfProcessWebView::set_is_webdriver_active(bool is_webdriver_enabled) +{ + client().async_set_is_webdriver_active(is_webdriver_enabled); +} + void OutOfProcessWebView::focusin_event(GUI::FocusEvent&) { client().async_set_has_focus(true); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index 6fc85212c9..d8a2878696 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -61,6 +61,7 @@ public: void set_content_filters(Vector); void set_proxy_mappings(Vector proxies, HashMap mappings); void set_preferred_color_scheme(Web::CSS::PreferredColorScheme); + void set_is_webdriver_active(bool); Function on_context_menu_request; Function on_link_click; diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 5f54a26340..852a54150a 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2020-2022, Andreas Kling * Copyright (c) 2021, Sam Atkins + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -498,6 +499,11 @@ void ConnectionFromClient::set_is_scripting_enabled(bool is_scripting_enabled) m_page_host->set_is_scripting_enabled(is_scripting_enabled); } +void ConnectionFromClient::set_is_webdriver_active(bool is_webdriver_active) +{ + m_page_host->set_is_webdriver_active(is_webdriver_active); +} + Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries() { auto* document = page().top_level_browsing_context().active_document(); diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index 63e40feb6c..206b06aecc 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -70,6 +71,7 @@ private: virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override; virtual void set_has_focus(bool) override; virtual void set_is_scripting_enabled(bool) override; + virtual void set_is_webdriver_active(bool) override; virtual void handle_file_return(i32 error, Optional const& file, i32 request_id) override; virtual void set_system_visibility_state(bool visible) override; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 910fb4197e..30c820dab2 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -70,6 +71,11 @@ void PageHost::set_is_scripting_enabled(bool is_scripting_enabled) page().set_is_scripting_enabled(is_scripting_enabled); } +void PageHost::set_is_webdriver_active(bool is_webdriver_active) +{ + page().set_is_webdriver_active(is_webdriver_active); +} + Web::Layout::InitialContainingBlock* PageHost::layout_root() { auto* document = page().top_level_browsing_context().active_document(); diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 83b2bb3864..b145675379 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -30,10 +31,10 @@ public: void set_viewport_rect(Gfx::IntRect const&); void set_screen_rects(Vector const& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; }; void set_preferred_color_scheme(Web::CSS::PreferredColorScheme); - void set_should_show_line_box_borders(bool b) { m_should_show_line_box_borders = b; } void set_has_focus(bool); void set_is_scripting_enabled(bool); + void set_is_webdriver_active(bool); private: // ^PageClient diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 8eb8e8277b..7c7fb44cc3 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -49,6 +49,7 @@ endpoint WebContentServer set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =| set_has_focus(bool has_focus) =| set_is_scripting_enabled(bool is_scripting_enabled) =| + set_is_webdriver_active(bool is_webdriver_active) =| get_local_storage_entries() => (OrderedHashMap entries) get_session_storage_entries() => (OrderedHashMap entries)