mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb+WebContent+WebDriver: Allow specifying multiple prompt handlers
WebDriver script authors may now provide either:
* A user prompt handler configuration to be used for all prompt types.
* A set of per-prompt-type user prompt handlers.
This also paves the way for interaction with the beforeunload prompt,
though we do not yet support that feature in LibWeb.
See: 43903d0
This commit is contained in:
parent
eef9d07088
commit
2583996e18
Notes:
github-actions[bot]
2025-02-06 14:02:21 +00:00
Author: https://github.com/trflynn89
Commit: 2583996e18
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3471
Reviewed-by: https://github.com/AtkinsSJ
10 changed files with 349 additions and 92 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
|||
#include <LibWeb/Loader/UserAgent.h>
|
||||
#include <LibWeb/WebDriver/Capabilities.h>
|
||||
#include <LibWeb/WebDriver/TimeoutsConfiguration.h>
|
||||
#include <LibWeb/WebDriver/UserPrompt.h>
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
|
@ -30,21 +31,6 @@ static Response deserialize_as_a_page_load_strategy(JsonValue value)
|
|||
return value;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-deserialize-as-an-unhandled-prompt-behavior
|
||||
static Response deserialize_as_an_unhandled_prompt_behavior(JsonValue value)
|
||||
{
|
||||
// 1. If value is not a string return an error with error code invalid argument.
|
||||
if (!value.is_string())
|
||||
return Error::from_code(ErrorCode::InvalidArgument, "Capability unhandledPromptBehavior must be a string"sv);
|
||||
|
||||
// 2. If value is not present as a keyword in the known prompt handling approaches table return an error with error code invalid argument.
|
||||
if (!value.as_string().is_one_of("dismiss"sv, "accept"sv, "dismiss and notify"sv, "accept and notify"sv, "ignore"sv))
|
||||
return Error::from_code(ErrorCode::InvalidArgument, "Invalid pageLoadStrategy capability"sv);
|
||||
|
||||
// 3. Return success with data value.
|
||||
return value;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-deserialize-as-a-proxy
|
||||
static ErrorOr<JsonObject, Error> deserialize_as_a_proxy(JsonValue parameter)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue