LibURL+LibWeb: Add a helper to check if a URL is a WebUI URL

Let's not have to know off-hand that we need to update Environments.cpp
when adding a new WebUI. It's more obvious just below where we define
the URLs.
This commit is contained in:
Timothy Flynn
2026-04-05 11:54:53 -04:00
committed by Tim Flynn
parent 39d7abee2f
commit 2f3199adbf
Notes: github-actions[bot] 2026-04-09 14:09:52 +00:00
2 changed files with 8 additions and 4 deletions

View File

@@ -283,10 +283,8 @@ bool is_scripting_enabled(EnvironmentSettingsObject const& settings)
// The user has not disabled scripting for realm at this time. (User agents may provide users with the option to disable scripting globally, or in a finer-grained manner, e.g., on a per-origin basis, down to the level of individual realms.)
auto const& document = as<HTML::Window>(settings.global_object()).associated_document();
// NB: about:settings and about:processes are internal pages using javascript, so we do not consider user configuration for these pages.
if (document.url() != URL::about_settings()
&& document.url() != URL::about_processes()
&& !document.page().is_scripting_enabled())
// NB: WebUI pages are internal pages requiring javascript, so we do not consider user configuration for these.
if (!document.page().is_scripting_enabled() && !URL::is_webui_url(document.url()))
return false;
// Either settings's global object is not a Window object, or settings's global object's associated Document's active sandboxing flag set does not have its sandboxed scripts browsing context flag set.