2022-10-12 11:14:59 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
2022-10-19 16:50:16 +02:00
|
|
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
2022-11-03 13:31:08 -04:00
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
2022-10-12 11:14:59 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Error.h>
|
|
|
|
#include <AK/RefPtr.h>
|
2022-11-08 10:18:11 -05:00
|
|
|
#include <LibCore/Promise.h>
|
2022-11-08 10:10:27 -05:00
|
|
|
#include <LibWeb/WebDriver/Error.h>
|
2022-11-08 09:42:36 -05:00
|
|
|
#include <LibWeb/WebDriver/Response.h>
|
2022-11-08 10:18:11 -05:00
|
|
|
#include <WebDriver/WebContentConnection.h>
|
2022-10-12 11:14:59 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
namespace WebDriver {
|
|
|
|
|
|
|
|
class Session {
|
|
|
|
public:
|
|
|
|
Session(unsigned session_id, NonnullRefPtr<Client> client);
|
|
|
|
~Session();
|
|
|
|
|
|
|
|
unsigned session_id() const { return m_id; }
|
|
|
|
|
2022-11-08 10:42:12 -05:00
|
|
|
WebContentConnection& web_content_connection()
|
|
|
|
{
|
|
|
|
VERIFY(m_web_content_connection);
|
|
|
|
return *m_web_content_connection;
|
|
|
|
}
|
|
|
|
|
2022-10-12 11:14:59 +01:00
|
|
|
ErrorOr<void> start();
|
2022-11-08 14:14:29 -05:00
|
|
|
Web::WebDriver::Response stop();
|
2022-10-12 11:14:59 +01:00
|
|
|
|
|
|
|
private:
|
2022-11-08 10:18:11 -05:00
|
|
|
using ServerPromise = Core::Promise<ErrorOr<void>>;
|
2022-11-11 14:14:58 -05:00
|
|
|
ErrorOr<NonnullRefPtr<Core::LocalServer>> create_server(String const& socket_path, NonnullRefPtr<ServerPromise> promise);
|
2022-11-08 10:18:11 -05:00
|
|
|
|
2022-10-12 11:14:59 +01:00
|
|
|
NonnullRefPtr<Client> m_client;
|
|
|
|
bool m_started { false };
|
|
|
|
unsigned m_id { 0 };
|
2022-11-08 10:18:11 -05:00
|
|
|
RefPtr<WebContentConnection> m_web_content_connection;
|
2022-11-11 14:14:58 -05:00
|
|
|
Optional<pid_t> m_browser_pid;
|
2022-10-12 11:14:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|