From 61c1e4a85519660b4784d4d5976d4e5d30410490 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Sun, 16 Mar 2025 14:13:58 +0000 Subject: [PATCH] LibWebView: Keep javascript URL navigations in the same process JavaScript URLs run in the same document context the navigation was started in, so they're not eligible to be moved to a new WebContent process. Fixes the "Login as demo user" link on https://demo.immich.app/ --- Libraries/LibWebView/SiteIsolation.cpp | 4 ++++ .../javascript-navigation-stays-in-same-process.txt | 1 + .../javascript-navigation-stays-in-same-process.html | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/HTML/javascript-navigation-stays-in-same-process.txt create mode 100644 Tests/LibWeb/Text/input/HTML/javascript-navigation-stays-in-same-process.html diff --git a/Libraries/LibWebView/SiteIsolation.cpp b/Libraries/LibWebView/SiteIsolation.cpp index b24ddf4027b..c937a70e4cd 100644 --- a/Libraries/LibWebView/SiteIsolation.cpp +++ b/Libraries/LibWebView/SiteIsolation.cpp @@ -27,6 +27,10 @@ bool is_url_suitable_for_same_process_navigation(URL::URL const& current_url, UR if (Web::HTML::url_matches_about_blank(current_url)) return true; + // Make sure JavaScript URLs run in the same process. + if (target_url.scheme() == "javascript"sv) + return true; + // Allow cross-scheme non-HTTP(S) navigation. Disallow cross-scheme HTTP(s) navigation. auto current_url_is_http = Web::Fetch::Infrastructure::is_http_or_https_scheme(current_url.scheme()); auto target_url_is_http = Web::Fetch::Infrastructure::is_http_or_https_scheme(target_url.scheme()); diff --git a/Tests/LibWeb/Text/expected/HTML/javascript-navigation-stays-in-same-process.txt b/Tests/LibWeb/Text/expected/HTML/javascript-navigation-stays-in-same-process.txt new file mode 100644 index 00000000000..56ba9218d98 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/javascript-navigation-stays-in-same-process.txt @@ -0,0 +1 @@ +Hello world, this was printed by a JavaScript navigation! diff --git a/Tests/LibWeb/Text/input/HTML/javascript-navigation-stays-in-same-process.html b/Tests/LibWeb/Text/input/HTML/javascript-navigation-stays-in-same-process.html new file mode 100644 index 00000000000..8f63ea250a7 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/javascript-navigation-stays-in-same-process.html @@ -0,0 +1,11 @@ + + +
Hello world, this was printed by a JavaScript navigation!
+