#include "third_party/blink/renderer/core/inspector/thread_debugger_common_impl.h"
#include <memory>
#include "base/check.h"
#include "base/rand_util.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_blob.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_token_list.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_listener_info.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_target.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_all_collection.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_collection.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_node.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_node_list.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_script_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_trusted_html.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_trusted_script.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_trusted_script_url.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_window.h"
#include "third_party/blink/renderer/core/dom/attr.h"
#include "third_party/blink/renderer/core/dom/attribute.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_list.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/html/html_collection.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/inspector/v8_inspector_string.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_html.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_script.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_script_url.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/bindings/v8_dom_wrapper.h"
#include "third_party/blink/renderer/platform/bindings/v8_set_return_value.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
namespace blink {
ThreadDebuggerCommonImpl::ThreadDebuggerCommonImpl(v8::Isolate* isolate)
: … { … }
ThreadDebuggerCommonImpl::~ThreadDebuggerCommonImpl() = default;
mojom::ConsoleMessageLevel
ThreadDebuggerCommonImpl::V8MessageLevelToMessageLevel(
v8::Isolate::MessageErrorLevel level) { … }
void ThreadDebuggerCommonImpl::AsyncTaskScheduled(
const StringView& operation_name,
void* task,
bool recurring) { … }
void ThreadDebuggerCommonImpl::AsyncTaskCanceled(void* task) { … }
void ThreadDebuggerCommonImpl::AllAsyncTasksCanceled() { … }
void ThreadDebuggerCommonImpl::AsyncTaskStarted(void* task) { … }
void ThreadDebuggerCommonImpl::AsyncTaskFinished(void* task) { … }
v8_inspector::V8StackTraceId ThreadDebuggerCommonImpl::StoreCurrentStackTrace(
const StringView& description) { … }
void ThreadDebuggerCommonImpl::ExternalAsyncTaskStarted(
const v8_inspector::V8StackTraceId& parent) { … }
void ThreadDebuggerCommonImpl::ExternalAsyncTaskFinished(
const v8_inspector::V8StackTraceId& parent) { … }
unsigned ThreadDebuggerCommonImpl::PromiseRejected(
v8::Local<v8::Context> context,
const String& error_message,
v8::Local<v8::Value> exception,
std::unique_ptr<SourceLocation> location) { … }
void ThreadDebuggerCommonImpl::PromiseRejectionRevoked(
v8::Local<v8::Context> context,
unsigned promise_rejection_id) { … }
void ThreadDebuggerCommonImpl::beginUserGesture() { … }
namespace {
static const char kType[] = …;
static const char kValue[] = …;
enum ShadowTreeSerialization { … };
v8::Local<v8::String> TypeStringKey(v8::Isolate* isolate_) { … }
v8::Local<v8::String> ValueStringKey(v8::Isolate* isolate_) { … }
v8::Local<v8::Object> SerializeNodeToV8Object(
Node* node,
v8::Isolate* isolate,
int max_node_depth,
ShadowTreeSerialization include_shadow_tree) { … }
std::unique_ptr<v8_inspector::DeepSerializedValue> DeepSerializeHtmlCollection(
HTMLCollection* html_collection,
v8::Isolate* isolate_,
int max_depth,
int max_node_depth,
ShadowTreeSerialization include_shadow_tree) { … }
std::unique_ptr<v8_inspector::DeepSerializedValue> DeepSerializeNodeList(
NodeList* node_list,
v8::Isolate* isolate_,
int max_depth,
int max_node_depth,
ShadowTreeSerialization include_shadow_tree) { … }
std::unique_ptr<v8_inspector::DeepSerializedValue> DeepSerializeNode(
Node* node,
v8::Isolate* isolate,
int max_node_depth,
ShadowTreeSerialization include_shadow_tree) { … }
std::unique_ptr<v8_inspector::DeepSerializedValue> DeepSerializeWindow(
DOMWindow* window,
v8::Isolate* isolate) { … }
}
bool ReadAdditionalSerializationParameters(
v8::Local<v8::Object> additional_parameters,
int& max_node_depth,
ShadowTreeSerialization& include_shadow_tree,
v8::Local<v8::Context> context,
std::unique_ptr<v8_inspector::StringBuffer>* error_message) { … }
std::unique_ptr<v8_inspector::DeepSerializationResult>
ThreadDebuggerCommonImpl::deepSerialize(
v8::Local<v8::Value> v8_value,
int max_depth,
v8::Local<v8::Object> additional_parameters) { … }
std::unique_ptr<v8_inspector::StringBuffer>
ThreadDebuggerCommonImpl::valueSubtype(v8::Local<v8::Value> value) { … }
std::unique_ptr<v8_inspector::StringBuffer>
ThreadDebuggerCommonImpl::descriptionForValueSubtype(
v8::Local<v8::Context> context,
v8::Local<v8::Value> value) { … }
double ThreadDebuggerCommonImpl::currentTimeMS() { … }
bool ThreadDebuggerCommonImpl::isInspectableHeapObject(
v8::Local<v8::Object> object) { … }
static void ReturnDataCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
static v8::Maybe<bool> CreateDataProperty(v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
v8::Local<v8::Name> key,
v8::Local<v8::Value> value) { … }
static void CreateFunctionPropertyWithData(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const char* name,
v8::FunctionCallback callback,
v8::Local<v8::Value> data,
const char* description,
v8::SideEffectType side_effect_type) { … }
v8::Maybe<bool> ThreadDebuggerCommonImpl::CreateDataPropertyInArray(
v8::Local<v8::Context> context,
v8::Local<v8::Array> array,
int index,
v8::Local<v8::Value> value) { … }
void ThreadDebuggerCommonImpl::CreateFunctionProperty(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const char* name,
v8::FunctionCallback callback,
const char* description,
v8::SideEffectType side_effect_type) { … }
void ThreadDebuggerCommonImpl::installAdditionalCommandLineAPI(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object) { … }
static Vector<String> NormalizeEventTypes(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
static EventTarget* FirstArgumentAsEventTarget(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void ThreadDebuggerCommonImpl::SetMonitorEventsCallback(
const v8::FunctionCallbackInfo<v8::Value>& info,
bool enabled) { … }
void ThreadDebuggerCommonImpl::MonitorEventsCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void ThreadDebuggerCommonImpl::UnmonitorEventsCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void ThreadDebuggerCommonImpl::GetAccessibleNameCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void ThreadDebuggerCommonImpl::GetAccessibleRoleCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void ThreadDebuggerCommonImpl::GetEventListenersCallback(
const v8::FunctionCallbackInfo<v8::Value>& callback_info) { … }
static uint64_t GetTraceId(ThreadDebuggerCommonImpl* this_thread_debugger,
v8::Local<v8::String> label) { … }
void ThreadDebuggerCommonImpl::consoleTime(v8::Isolate* isolate,
v8::Local<v8::String> label) { … }
void ThreadDebuggerCommonImpl::consoleTimeEnd(v8::Isolate* isolate,
v8::Local<v8::String> label) { … }
void ThreadDebuggerCommonImpl::consoleTimeStamp(v8::Isolate* isolate,
v8::Local<v8::String> label) { … }
void ThreadDebuggerCommonImpl::startRepeatingTimer(
double interval,
V8InspectorClient::TimerCallback callback,
void* data) { … }
void ThreadDebuggerCommonImpl::cancelTimer(void* data) { … }
int64_t ThreadDebuggerCommonImpl::generateUniqueId() { … }
void ThreadDebuggerCommonImpl::OnTimer(TimerBase* timer) { … }
}