mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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: https://github.com/w3c/webdriver/commit/43903d0
68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <AK/JsonValue.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/StringView.h>
|
|
#include <LibIPC/Forward.h>
|
|
#include <LibWeb/WebDriver/Response.h>
|
|
|
|
namespace Web::WebDriver {
|
|
|
|
// https://w3c.github.io/webdriver/#dfn-known-prompt-handlers
|
|
enum class PromptHandler {
|
|
Accept,
|
|
Dismiss,
|
|
Ignore,
|
|
};
|
|
|
|
// https://w3c.github.io/webdriver/#dfn-valid-prompt-types
|
|
enum class PromptType {
|
|
Alert,
|
|
BeforeUnload,
|
|
Confirm,
|
|
Default,
|
|
Prompt,
|
|
FallbackDefault,
|
|
};
|
|
|
|
// https://w3c.github.io/webdriver/#dfn-prompt-handler-configuration
|
|
struct PromptHandlerConfiguration {
|
|
enum class Notify {
|
|
No,
|
|
Yes,
|
|
};
|
|
|
|
static PromptHandlerConfiguration deserialize(JsonValue const&);
|
|
|
|
PromptHandler handler { PromptHandler::Dismiss };
|
|
Notify notify { Notify::Yes };
|
|
};
|
|
|
|
// https://w3c.github.io/webdriver/#dfn-user-prompt-handler
|
|
using UserPromptHandler = Optional<HashMap<PromptType, PromptHandlerConfiguration>>;
|
|
|
|
UserPromptHandler const& user_prompt_handler();
|
|
void set_user_prompt_handler(UserPromptHandler);
|
|
|
|
Response deserialize_as_an_unhandled_prompt_behavior(JsonValue);
|
|
void update_the_user_prompt_handler(JsonObject const&);
|
|
|
|
}
|
|
|
|
namespace IPC {
|
|
|
|
template<>
|
|
ErrorOr<void> encode(Encoder&, Web::WebDriver::PromptHandlerConfiguration const&);
|
|
|
|
template<>
|
|
ErrorOr<Web::WebDriver::PromptHandlerConfiguration> decode(Decoder&);
|
|
|
|
}
|