LibWeb+WebDriver: Add a flag to default WebDriver to headless mode

We previously only supported enabling headless mode on a per-session
basis via the capabilities record. We don't have the ability to mutate
this record from WPT, so this adds a flag to set the default mode.
This commit is contained in:
Timothy Flynn 2024-10-21 19:07:55 -04:00 committed by Tim Ledbetter
commit b24a7079f1
Notes: github-actions[bot] 2024-10-22 03:25:32 +00:00
3 changed files with 19 additions and 1 deletions

View file

@ -72,6 +72,13 @@ static ErrorOr<JsonObject, Error> deserialize_as_a_proxy(JsonValue parameter)
return proxy;
}
static InterfaceMode default_interface_mode { InterfaceMode::Graphical };
void set_default_interface_mode(InterfaceMode interface_mode)
{
default_interface_mode = interface_mode;
}
static Response deserialize_as_ladybird_options(JsonValue value)
{
if (!value.is_object())
@ -88,7 +95,7 @@ static Response deserialize_as_ladybird_options(JsonValue value)
static JsonObject default_ladybird_options()
{
JsonObject options;
options.set("headless"sv, false);
options.set("headless"sv, default_interface_mode == InterfaceMode::Headless);
return options;
}