servoshell: Add button to toggle experimental web platform features. (#39125)

This makes it easier to experiment with the impact of experimental
features when browsing around in servoshell. The toggle is global and
causes all webviews to reload with the new preference values.

Testing: Manually tested; no UI testing for servoshell.

Not enabled:
<img width="317" height="82" alt="Screenshot 2025-09-03 at 9 34 30 PM"
src="https://github.com/user-attachments/assets/ca521ad5-ce1b-434e-a0c3-ea1b75d76d53"
/>

Enabled:
<img width="320" height="82" alt="Screenshot 2025-09-03 at 9 34 36 PM"
src="https://github.com/user-attachments/assets/7b6529b5-1055-4ae0-924a-96d57e115714"
/>

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-09-03 22:53:12 -04:00 committed by GitHub
parent 912b83b58f
commit aac6aa6c70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 2 deletions

View file

@ -88,6 +88,9 @@ pub(crate) struct ServoShellPreferences {
/// Log also to a file
#[cfg(target_env = "ohos")]
pub log_to_file: bool,
/// Whether the CLI option to enable experimental prefs was present at startup.
pub experimental_prefs_enabled: bool,
}
impl Default for ServoShellPreferences {
@ -111,6 +114,7 @@ impl Default for ServoShellPreferences {
log_filter: None,
#[cfg(target_env = "ohos")]
log_to_file: false,
experimental_prefs_enabled: false,
}
}
}
@ -605,7 +609,9 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
})
.collect();
if opt_match.opt_present("enable-experimental-web-platform-features") {
let experimental_prefs_enabled =
opt_match.opt_present("enable-experimental-web-platform-features");
if experimental_prefs_enabled {
for pref in EXPERIMENTAL_PREFS {
preferences.set_value(pref, PrefValue::Bool(true));
}
@ -677,6 +683,7 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
log_filter,
#[cfg(target_env = "ohos")]
log_to_file,
experimental_prefs_enabled,
..Default::default()
};