mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 06:06:48 +00:00
LibDevTools: Introduce a Firefox DevTools server library
To aid with debugging web page issues in Ladybird without needing to implement a fully fledged inspector, we can implement the Firefox DevTools protocol and use their DevTools. The protocol is described here: https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html This commit contains just enough to connect to Ladybird from a DevTools client.
This commit is contained in:
parent
49c93d01db
commit
58bc44ba2a
Notes:
github-actions[bot]
2025-02-19 13:47:24 +00:00
Author: https://github.com/trflynn89
Commit: 58bc44ba2a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3589
Reviewed-by: https://github.com/ADKaster
20 changed files with 947 additions and 0 deletions
66
Libraries/LibDevTools/Actor.h
Normal file
66
Libraries/LibDevTools/Actor.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibDevTools/Forward.h>
|
||||
|
||||
namespace DevTools {
|
||||
|
||||
class Actor
|
||||
: public RefCounted<Actor>
|
||||
, public Weakable<Actor> {
|
||||
public:
|
||||
virtual ~Actor();
|
||||
|
||||
ByteString const& name() const { return m_name; }
|
||||
virtual void handle_message(StringView type, JsonObject const&) = 0;
|
||||
|
||||
class [[nodiscard]] BlockToken {
|
||||
public:
|
||||
BlockToken(Badge<Actor>, Actor&);
|
||||
~BlockToken();
|
||||
|
||||
BlockToken(BlockToken const&) = delete;
|
||||
BlockToken& operator=(BlockToken const&) = delete;
|
||||
|
||||
BlockToken(BlockToken&&);
|
||||
BlockToken& operator=(BlockToken&&);
|
||||
|
||||
private:
|
||||
WeakPtr<Actor> m_actor;
|
||||
};
|
||||
|
||||
void send_message(JsonValue, Optional<BlockToken> block_token = {});
|
||||
void send_missing_parameter_error(StringView parameter);
|
||||
void send_unrecognized_packet_type_error(StringView type);
|
||||
void send_unknown_actor_error(StringView actor);
|
||||
|
||||
protected:
|
||||
explicit Actor(DevToolsServer&, ByteString name);
|
||||
|
||||
DevToolsServer& devtools() { return m_devtools; }
|
||||
DevToolsServer const& devtools() const { return m_devtools; }
|
||||
|
||||
BlockToken block_responses();
|
||||
|
||||
private:
|
||||
DevToolsServer& m_devtools;
|
||||
ByteString m_name;
|
||||
|
||||
Vector<JsonValue> m_blocked_responses;
|
||||
bool m_block_responses { false };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue