LibWeb+WebContent+WebDriver: Bring session start and close up to spec

Lots of editorial spec bugs here, but these changes largely affect how
the unhandledPromptBehavior capability is handled. We also now set an
additional capability for the default User Agent string.
This commit is contained in:
Timothy Flynn 2025-02-05 16:05:25 -05:00 committed by Tim Flynn
commit ee649fc13b
Notes: github-actions[bot] 2025-02-06 14:02:15 +00:00
9 changed files with 290 additions and 131 deletions

View file

@ -29,11 +29,9 @@ struct LaunchBrowserCallbacks;
class Session : public RefCounted<Session> {
public:
Session(String session_id, NonnullRefPtr<Client> client, Web::WebDriver::LadybirdOptions options);
static ErrorOr<NonnullRefPtr<Session>> create(NonnullRefPtr<Client> client, JsonObject& capabilities, ReadonlySpan<StringView> flags);
~Session();
void initialize_from_capabilities(JsonObject&);
String session_id() const { return m_id; }
struct Window {
@ -56,8 +54,6 @@ public:
bool has_window_handle(StringView handle) const { return m_windows.contains(handle); }
ErrorOr<void> start(LaunchBrowserCallbacks const&);
Web::WebDriver::Response set_timeouts(JsonValue);
Web::WebDriver::Response close_window();
Web::WebDriver::Response switch_to_window(StringView);
@ -83,6 +79,10 @@ public:
}
private:
Session(NonnullRefPtr<Client> client, JsonObject const& capabilities, String session_id, bool http);
ErrorOr<void> start(LaunchBrowserCallbacks const&);
using ServerPromise = Core::Promise<ErrorOr<void>>;
ErrorOr<NonnullRefPtr<Core::LocalServer>> create_server(NonnullRefPtr<ServerPromise> promise);
@ -90,7 +90,9 @@ private:
Web::WebDriver::LadybirdOptions m_options;
bool m_started { false };
String m_id;
bool m_http { false };
HashMap<String, Window> m_windows;
String m_current_window_handle;