ladybird/Libraries/LibWeb/WebDriver/UserPrompt.h
Andreas Kling 24f37c6732 LibWebView: Keep browser history in the UI process
Use the LibWebView history mirror to preserve traversable session
history across WebContent process swaps. WebContent reports snapshots to
the UI process, and new renderers can be seeded from the mirror.

Browser back and forward now resolve through the UI-owned used history
steps. WebContent still runs the spec traversal path when the current
renderer has enough matching state to do so.

Handle canceled and no-op UI navigations without leaving speculative
history entries or pending WebDriver waits behind. Preserve traversal
precheck state across synchronous IPC shutdown, and avoid overwriting a
restored target entry's persisted scroll state before the document has
adopted that entry.
2026-06-14 17:38:44 +02:00

75 lines
1.8 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/Export.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,
File,
Prompt,
FallbackDefault,
};
// https://w3c.github.io/webdriver/#dfn-prompt-handler-configuration
struct PromptHandlerConfiguration {
enum class Notify {
No,
Yes,
};
static PromptHandlerConfiguration deserialize(JsonValue const&);
StringView serialize() const;
bool operator==(PromptHandlerConfiguration const&) const = default;
PromptHandler handler { PromptHandler::Dismiss };
Notify notify { Notify::Yes };
};
// https://w3c.github.io/webdriver/#dfn-user-prompt-handler
using UserPromptHandler = Optional<HashMap<PromptType, PromptHandlerConfiguration>>;
WEB_API UserPromptHandler const& user_prompt_handler();
WEB_API void set_user_prompt_handler(UserPromptHandler);
WEB_API PromptHandlerConfiguration get_the_prompt_handler(PromptType);
Response deserialize_as_an_unhandled_prompt_behavior(JsonValue);
bool check_user_prompt_handler_matches(JsonObject const&);
WEB_API void update_the_user_prompt_handler(JsonObject const&);
WEB_API JsonValue serialize_the_user_prompt_handler();
}
namespace IPC {
template<>
WEB_API ErrorOr<void> encode(Encoder&, Web::WebDriver::PromptHandlerConfiguration const&);
template<>
WEB_API ErrorOr<Web::WebDriver::PromptHandlerConfiguration> decode(Decoder&);
}