diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 40518f5fd5f..5f6a1f328f6 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -57,9 +57,10 @@ static DeprecatedString search_engines_file_path() return builder.to_deprecated_string(); } -BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url) +BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url, WebView::UseJavaScriptBytecode use_javascript_bytecode) : m_cookie_jar(cookie_jar) , m_window_actions(*this) + , m_use_javascript_bytecode(use_javascript_bytecode) { auto app_icon = GUI::Icon::default_icon("app-browser"sv); m_bookmarks_bar = Browser::BookmarksBarWidget::construct(Browser::bookmarks_file_path(), true); @@ -563,7 +564,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab) Tab& BrowserWindow::create_new_tab(URL url, Web::HTML::ActivateTab activate) { - auto& new_tab = m_tab_widget->add_tab("New tab"_short_string, *this); + auto& new_tab = m_tab_widget->add_tab("New tab"_short_string, *this, m_use_javascript_bytecode); m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1); diff --git a/Userland/Applications/Browser/BrowserWindow.h b/Userland/Applications/Browser/BrowserWindow.h index fc6d39cf2e3..5841ae1c106 100644 --- a/Userland/Applications/Browser/BrowserWindow.h +++ b/Userland/Applications/Browser/BrowserWindow.h @@ -50,7 +50,7 @@ public: void broadcast_window_size(Gfx::IntSize); private: - explicit BrowserWindow(CookieJar&, URL); + BrowserWindow(CookieJar&, URL, WebView::UseJavaScriptBytecode); void build_menus(); ErrorOr load_search_engines(GUI::Menu& settings_menu); @@ -86,6 +86,8 @@ private: RefPtr m_disable_user_agent_spoofing; RefPtr m_disable_search_engine_action; RefPtr m_change_homepage_action; + + WebView::UseJavaScriptBytecode m_use_javascript_bytecode {}; }; } diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index fced89f5add..04fd85c4c61 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -114,7 +114,7 @@ void Tab::update_status(Optional text_override, i32 count_waiting) } } -Tab::Tab(BrowserWindow& window) +Tab::Tab(BrowserWindow& window, WebView::UseJavaScriptBytecode use_javascript_bytecode) { load_from_gml(tab_gml).release_value_but_fixme_should_propagate_errors(); @@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow& window) auto& webview_container = *find_descendant_of_type_named("webview_container"); - m_web_content_view = webview_container.add(); + m_web_content_view = webview_container.add(use_javascript_bytecode); auto preferred_color_scheme = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, Browser::default_color_scheme)); m_web_content_view->set_preferred_color_scheme(preferred_color_scheme); diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index 94ec973f8df..67cf4dc6815 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace WebView { class OutOfProcessWebView; @@ -98,7 +99,7 @@ public: WebView::OutOfProcessWebView& view() { return *m_web_content_view; } private: - explicit Tab(BrowserWindow&); + Tab(BrowserWindow&, WebView::UseJavaScriptBytecode); virtual void show_event(GUI::ShowEvent&) override; virtual void hide_event(GUI::HideEvent&) override; diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 22d28c20c4e..f6fe799a2b6 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -96,10 +96,12 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd unix fattr cpath rpath wpath proc exec")); Vector specified_urls; + bool use_ast_interpreter = false; Core::ArgsParser args_parser; args_parser.add_positional_argument(specified_urls, "URLs to open", "url", Core::ArgsParser::Required::No); args_parser.add_option(Browser::g_webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path"); + args_parser.add_option(use_ast_interpreter, "Enable JavaScript AST interpreter (deprecated)", "ast", 0); args_parser.parse(arguments); @@ -173,7 +175,7 @@ ErrorOr serenity_main(Main::Arguments arguments) first_url = TRY(url_from_argument_string(specified_urls.first())); auto cookie_jar = TRY(Browser::CookieJar::create(*database)); - auto window = Browser::BrowserWindow::construct(cookie_jar, first_url); + auto window = Browser::BrowserWindow::construct(cookie_jar, first_url, use_ast_interpreter ? WebView::UseJavaScriptBytecode::No : WebView::UseJavaScriptBytecode::Yes); auto content_filters_watcher = TRY(Core::FileWatcher::create()); content_filters_watcher->on_change = [&](Core::FileWatcherEvent const&) { diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 7313ae52d6b..523194e0c69 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -47,6 +47,8 @@ void OutOfProcessWebView::create_client(EnableCallgrindProfiling) }); }; + client().async_set_use_javascript_bytecode(use_javascript_bytecode() == UseJavaScriptBytecode::Yes); + m_client_state.client_handle = Web::Crypto::generate_random_uuid().release_value_but_fixme_should_propagate_errors(); client().async_set_window_handle(m_client_state.client_handle); diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index fc2fee1c370..48f290141eb 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,11 @@ Web::Page const& ConnectionFromClient::page() const return m_page_host->page(); } +void ConnectionFromClient::set_use_javascript_bytecode(bool use_bytecode) +{ + JS::Bytecode::Interpreter::set_enabled(use_bytecode); +} + Messages::WebContentServer::GetWindowHandleResponse ConnectionFromClient::get_window_handle() { return m_page_host->page().top_level_browsing_context().window_handle(); diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index f87bff314fc..1608092c1ad 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -48,6 +48,7 @@ private: Web::Page& page(); Web::Page const& page() const; + virtual void set_use_javascript_bytecode(bool) override; virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle() override; virtual void set_window_handle(String const& handle) override; virtual void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path) override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 072b887a29c..65f92cbe7e8 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -9,6 +9,9 @@ endpoint WebContentServer { + // NOTE: This is only used on SerenityOS when attaching to a WebContent process served by SystemServer. + set_use_javascript_bytecode(bool use_javascript_bytecode) =| + get_window_handle() => (String handle) set_window_handle(String handle) =|