#include "third_party/blink/renderer/core/inspector/main_thread_debugger.h"
#include <memory>
#include <set>
#include "base/feature_list.h"
#include "base/synchronization/lock.h"
#include "base/unguessable_token.h"
#include "build/chromeos_buildflags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/bindings/core/v8/binding_security.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_node.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_window.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/dom/container_node.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
#include "third_party/blink/renderer/core/events/error_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/frame_console.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/console_message_storage.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/inspector/v8_inspector_string.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/timing/memory_info.h"
#include "third_party/blink/renderer/core/workers/worklet_global_scope.h"
#include "third_party/blink/renderer/core/xml/xpath_evaluator.h"
#include "third_party/blink/renderer/core/xml/xpath_result.h"
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/bindings/v8_set_return_value.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
namespace {
LocalFrame* ToFrame(ExecutionContext* context) { … }
}
MainThreadDebugger::MainThreadDebugger(v8::Isolate* isolate)
: … { … }
MainThreadDebugger::~MainThreadDebugger() = default;
void MainThreadDebugger::ReportConsoleMessage(
ExecutionContext* context,
mojom::ConsoleMessageSource source,
mojom::ConsoleMessageLevel level,
const String& message,
SourceLocation* location) { … }
int MainThreadDebugger::ContextGroupId(ExecutionContext* context) { … }
void MainThreadDebugger::SetClientMessageLoop(
std::unique_ptr<ClientMessageLoop> client_message_loop) { … }
void MainThreadDebugger::DidClearContextsForFrame(LocalFrame* frame) { … }
void MainThreadDebugger::ContextCreated(ScriptState* script_state,
LocalFrame* frame,
const SecurityOrigin* origin) { … }
void MainThreadDebugger::ContextWillBeDestroyed(ScriptState* script_state) { … }
void MainThreadDebugger::ExceptionThrown(ExecutionContext* context,
ErrorEvent* event) { … }
int MainThreadDebugger::ContextGroupId(LocalFrame* frame) { … }
MainThreadDebugger* MainThreadDebugger::Instance(v8::Isolate* isolate) { … }
void MainThreadDebugger::runMessageLoopOnInstrumentationPause(
int context_group_id) { … }
void MainThreadDebugger::runMessageLoopOnPause(int context_group_id) { … }
void MainThreadDebugger::quitMessageLoopOnPause() { … }
void MainThreadDebugger::muteMetrics(int context_group_id) { … }
void MainThreadDebugger::unmuteMetrics(int context_group_id) { … }
v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(
int context_group_id) { … }
void MainThreadDebugger::beginEnsureAllContextsInGroup(int context_group_id) { … }
void MainThreadDebugger::endEnsureAllContextsInGroup(int context_group_id) { … }
bool MainThreadDebugger::canExecuteScripts(int context_group_id) { … }
void MainThreadDebugger::runIfWaitingForDebugger(int context_group_id) { … }
void MainThreadDebugger::consoleAPIMessage(
int context_group_id,
v8::Isolate::MessageErrorLevel level,
const v8_inspector::StringView& message,
const v8_inspector::StringView& url,
unsigned line_number,
unsigned column_number,
v8_inspector::V8StackTrace* stack_trace) { … }
void MainThreadDebugger::consoleClear(int context_group_id) { … }
v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(
v8::Isolate* isolate,
v8::Local<v8::Context> context) { … }
void MainThreadDebugger::installAdditionalCommandLineAPI(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object) { … }
static Node* SecondArgumentAsNode(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void MainThreadDebugger::QuerySelectorCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void MainThreadDebugger::QuerySelectorAllCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void MainThreadDebugger::XpathSelectorCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}