35#include <unordered_set> 
   37#include "../../third_party/inspector_protocol/crdtp/json.h" 
   46#include "src/inspector/protocol/Protocol.h" 
   61const char kGlobalHandleLabel[] = 
"DevTools console";
 
   62bool isResolvableNumberLike(String16 query) {
 
   63  return query == 
"Infinity" || query == 
"-Infinity" || query == 
"NaN";
 
   68using protocol::Runtime::InternalPropertyDescriptor;
 
   69using protocol::Runtime::PrivatePropertyDescriptor;
 
   70using protocol::Runtime::PropertyDescriptor;
 
   71using protocol::Runtime::RemoteObject;
 
   76    std::unique_ptr<protocol::Runtime::RemoteObject> 
result,
 
   77    std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails) {
 
   78  std::shared_ptr<EvaluateCallback> cb = 
callback.lock();
 
   82  cb->sendSuccess(std::move(
result), std::move(exceptionDetails));
 
 
   88                                   const protocol::DispatchResponse& response) {
 
   89  std::shared_ptr<EvaluateCallback> cb = 
callback.lock();
 
   93  cb->sendFailure(response);
 
 
  100                  int executionContextId, 
const String16& objectGroup,
 
  101                  std::unique_ptr<WrapOptions> wrapOptions, 
bool replMode,
 
  102                  bool throwOnSideEffect,
 
  103                  std::weak_ptr<EvaluateCallback> 
callback) {
 
  106    if (!response.IsSuccess()) 
return;
 
  110    if (value->IsPromise()) {
 
  118                                      Response::InternalError());
 
  121      if (!resolver->Resolve(context, value).FromMaybe(
false)) {
 
  123                                      Response::InternalError());
 
  126      promise = resolver->GetPromise();
 
  132            session, executionContextId, objectGroup, std::move(wrapOptions),
 
  133            replMode, throwOnSideEffect, 
callback, promise);
 
  145    if (promise->Then(context, thenCallbackFunction, catchCallbackFunction)
 
  149      if (!new_response.IsSuccess()) 
return;
 
  151                                    Response::InternalError());
 
 
  161               isolate, 
reinterpret_cast<const uint8_t*
>(
".repl_result"))
 
 
  168            info.Data().As<v8::Number>()->Value());
 
  172            ->promiseHandlerTracker();
 
  177    if (!handler) 
return;
 
  179        info.Length() > 0 ? info[0]
 
  181    handler->thenCallback(value);
 
  182    handlerTracker.
discard(handlerId,
 
 
  189            info.Data().As<v8::Number>()->Value());
 
  193            ->promiseHandlerTracker();
 
  198    if (!handler) 
return;
 
  200        info.Length() > 0 ? info[0]
 
  202    handler->catchCallback(value);
 
  203    handlerTracker.
discard(handlerId,
 
 
  209                         int executionContextId, 
const String16& objectGroup,
 
  210                         std::unique_ptr<WrapOptions> wrapOptions,
 
  211                         bool replMode, 
bool throwOnSideEffect,
 
  212                         std::weak_ptr<EvaluateCallback> 
callback,
 
 
  234            ->promiseHandlerTracker();
 
 
  246    if (!session) 
return;
 
  249    if (!response.IsSuccess()) 
return;
 
  275    std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue;
 
  278    if (!response.IsSuccess()) {
 
  284                                  std::move(wrappedValue), 
nullptr);
 
 
  293    if (!session) 
return;
 
  296    if (!response.IsSuccess()) 
return;
 
  297    std::unique_ptr<protocol::Runtime::RemoteObject> wrappedValue;
 
  300    if (!response.IsSuccess()) {
 
  315    if (maybeMessage.
ToLocal(&message)) {
 
  321      std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails;
 
  324      if (!response.IsSuccess()) {
 
  331                                    std::move(wrappedValue),
 
  332                                    std::move(exceptionDetails));
 
  337    std::unique_ptr<V8StackTraceImpl> 
stack;
 
  338    if (
result->IsNativeError()) {
 
  342                           result->ToDetailString(isolate->GetCurrentContext())
 
  360        m_replMode ? 
"Uncaught" : 
"Uncaught (in promise)" + messageString;
 
  361    std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails =
 
  362        protocol::Runtime::ExceptionDetails::create()
 
  364            .setText(exceptionDetailsText)
 
  365            .setLineNumber(stack && !stack->isEmpty() ? stack->topLineNumber()
 
  368                stack && !stack->isEmpty() ? stack->topColumnNumber() : 0)
 
  372    if (!response.IsSuccess()) {
 
  378      exceptionDetails->setStackTrace(
 
  380    if (stack && !stack->isEmpty())
 
  381      exceptionDetails->setScriptId(
 
  384                                  std::move(wrappedValue),
 
  385                                  std::move(exceptionDetails));
 
 
 
  401    : 
m_context(context), m_sessionId(sessionId) {}
 
 
  408  explicit PropertyAccumulator(std::vector<PropertyMirror>* mirrors)
 
  410  bool Add(PropertyMirror mirror)
 override {
 
  422    bool accessorPropertiesOnly, 
bool nonIndexedPropertiesOnly,
 
  424    std::unique_ptr<Array<PropertyDescriptor>>* properties,
 
  425    std::unique_ptr<protocol::Runtime::ExceptionDetails>* exceptionDetails) {
 
  432  *properties = std::make_unique<Array<PropertyDescriptor>>();
 
  433  std::vector<PropertyMirror> mirrors;
 
  434  PropertyAccumulator accumulator(&mirrors);
 
  436                                  accessorPropertiesOnly,
 
  437                                  nonIndexedPropertiesOnly, &accumulator)) {
 
  441    std::unique_ptr<PropertyDescriptor> descriptor =
 
  442        PropertyDescriptor::create()
 
  443            .setName(mirror.name)
 
  444            .setConfigurable(mirror.configurable)
 
  445            .setEnumerable(mirror.enumerable)
 
  446            .setIsOwn(mirror.isOwn)
 
  448    std::unique_ptr<RemoteObject> remoteObject;
 
  453      if (!response.IsSuccess()) 
return response;
 
  454      descriptor->setValue(std::move(remoteObject));
 
  455      descriptor->setWritable(mirror.writable);
 
  459          mirror.getter->buildRemoteObject(context, wrapOptions, &remoteObject);
 
  460      if (!response.IsSuccess()) 
return response;
 
  462                                          mirror.getter->v8Value(isolate),
 
  463                                          groupName, remoteObject.get());
 
  464      if (!response.IsSuccess()) 
return response;
 
  465      descriptor->setGet(std::move(remoteObject));
 
  469          mirror.setter->buildRemoteObject(context, wrapOptions, &remoteObject);
 
  470      if (!response.IsSuccess()) 
return response;
 
  472                                          mirror.setter->v8Value(isolate),
 
  473                                          groupName, remoteObject.get());
 
  474      if (!response.IsSuccess()) 
return response;
 
  475      descriptor->setSet(std::move(remoteObject));
 
  479          mirror.symbol->buildRemoteObject(context, wrapOptions, &remoteObject);
 
  480      if (!response.IsSuccess()) 
return response;
 
  482                                          mirror.symbol->v8Value(isolate),
 
  483                                          groupName, remoteObject.get());
 
  484      if (!response.IsSuccess()) 
return response;
 
  485      descriptor->setSymbol(std::move(remoteObject));
 
  487    if (mirror.exception) {
 
  488      Response response = mirror.exception->buildRemoteObject(
 
  489          context, wrapOptions, &remoteObject);
 
  490      if (!response.IsSuccess()) 
return response;
 
  492                                          mirror.exception->v8Value(isolate),
 
  493                                          groupName, remoteObject.get());
 
  494      if (!response.IsSuccess()) 
return response;
 
  495      descriptor->setValue(std::move(remoteObject));
 
  496      descriptor->setWasThrown(
true);
 
  498    (*properties)->emplace_back(std::move(descriptor));
 
  500  return Response::Success();
 
 
  505    bool accessorPropertiesOnly,
 
  506    std::unique_ptr<protocol::Array<InternalPropertyDescriptor>>*
 
  508    std::unique_ptr<protocol::Array<PrivatePropertyDescriptor>>*
 
  510  *internalProperties = std::make_unique<Array<InternalPropertyDescriptor>>();
 
  511  *privateProperties = std::make_unique<Array<PrivatePropertyDescriptor>>();
 
  513  if (!value->IsObject()) 
return Response::Success();
 
  520  if (!accessorPropertiesOnly) {
 
  521    std::vector<InternalPropertyMirror> internalPropertiesWrappers;
 
  523                                       &internalPropertiesWrappers);
 
  524    for (
const auto& internalProperty : internalPropertiesWrappers) {
 
  525      std::unique_ptr<RemoteObject> remoteObject;
 
  526      Response response = internalProperty.value->buildRemoteObject(
 
  529      if (!response.IsSuccess()) 
return response;
 
  532          internalProperty.value->v8Value(context->GetIsolate()), groupName,
 
  534      if (!response.IsSuccess()) 
return response;
 
  535      (*internalProperties)
 
  536          ->emplace_back(InternalPropertyDescriptor::create()
 
  537                             .setName(internalProperty.name)
 
  538                             .setValue(std::move(remoteObject))
 
  543  std::vector<PrivatePropertyMirror> privatePropertyWrappers =
 
  545                                        accessorPropertiesOnly);
 
  546  for (
const auto& privateProperty : privatePropertyWrappers) {
 
  547    std::unique_ptr<PrivatePropertyDescriptor> descriptor =
 
  548        PrivatePropertyDescriptor::create()
 
  549            .setName(privateProperty.name)
 
  552    std::unique_ptr<RemoteObject> remoteObject;
 
  553    DCHECK((privateProperty.getter || privateProperty.setter) ^
 
  554           (!!privateProperty.value));
 
  555    if (privateProperty.value) {
 
  556      Response response = privateProperty.value->buildRemoteObject(
 
  558      if (!response.IsSuccess()) 
return response;
 
  561          privateProperty.value->v8Value(context->GetIsolate()), groupName,
 
  563      if (!response.IsSuccess()) 
return response;
 
  564      descriptor->setValue(std::move(remoteObject));
 
  567    if (privateProperty.getter) {
 
  568      Response response = privateProperty.getter->buildRemoteObject(
 
  570      if (!response.IsSuccess()) 
return response;
 
  573          privateProperty.getter->v8Value(context->GetIsolate()), groupName,
 
  575      if (!response.IsSuccess()) 
return response;
 
  576      descriptor->setGet(std::move(remoteObject));
 
  579    if (privateProperty.setter) {
 
  580      Response response = privateProperty.setter->buildRemoteObject(
 
  582      if (!response.IsSuccess()) 
return response;
 
  585          privateProperty.setter->v8Value(context->GetIsolate()), groupName,
 
  587      if (!response.IsSuccess()) 
return response;
 
  588      descriptor->setSet(std::move(remoteObject));
 
  591    (*privateProperties)->emplace_back(std::move(descriptor));
 
  593  return Response::Success();
 
 
  597  std::unique_ptr<RemoteObjectId> remoteId;
 
 
  605    std::unique_ptr<protocol::Runtime::RemoteObject>* 
result) {
 
 
  614    std::unique_ptr<protocol::Runtime::RemoteObject>* 
result) {
 
  618  if (!mirror) 
return Response::InternalError();
 
  619  return wrapObjectMirror(*mirror, groupName, wrapOptions, customPreviewConfig,
 
  620                          maxCustomPreviewDepth, 
result);
 
 
  627    std::unique_ptr<protocol::Runtime::RemoteObject>* 
result) {
 
  633  if (!response.IsSuccess()) 
return response;
 
  637  if (!response.IsSuccess()) 
return response;
 
  638  if (customPreviewEnabled && value->IsObject()) {
 
  639    std::unique_ptr<protocol::Runtime::CustomPreview> customPreview;
 
  642                          maxCustomPreviewDepth, &customPreview);
 
  643    if (customPreview) (*result)->setCustomPreview(std::move(customPreview));
 
  648    std::unique_ptr<protocol::DictionaryValue> deepSerializedValueDict;
 
  653        duplicateTracker, &deepSerializedValueDict);
 
  654    if (!response.IsSuccess()) 
return response;
 
  657    deepSerializedValueDict->getString(
"type", &type);
 
  659    std::unique_ptr<protocol::Runtime::DeepSerializedValue>
 
  660        deepSerializedValue = protocol::Runtime::DeepSerializedValue::create()
 
  664    protocol::Value* maybeValue = deepSerializedValueDict->get(
"value");
 
  665    if (maybeValue != 
nullptr) {
 
  666      deepSerializedValue->setValue(maybeValue->clone());
 
  669    int weakLocalObjectReference;
 
  670    if (deepSerializedValueDict->getInteger(
"weakLocalObjectReference",
 
  671                                            &weakLocalObjectReference)) {
 
  672      deepSerializedValue->setWeakLocalObjectReference(
 
  673          weakLocalObjectReference);
 
  676    if (!response.IsSuccess()) 
return response;
 
  677    (*result)->setDeepSerializedValue(std::move(deepSerializedValue));
 
  680  return Response::Success();
 
 
  685  using protocol::Array;
 
  686  using protocol::Runtime::ObjectPreview;
 
  687  using protocol::Runtime::PropertyPreview;
 
  688  using protocol::Runtime::RemoteObject;
 
  694  std::unique_ptr<RemoteObject> remoteObject;
 
  697  if (!remoteObject || !response.IsSuccess()) 
return nullptr;
 
  700  std::unique_ptr<ObjectPreview> preview;
 
  702  mirror->buildObjectPreview(context, 
true ,
 
  703                             &limit, &limit, &preview);
 
  704  if (!preview) 
return nullptr;
 
  706  std::vector<String16> selectedColumns;
 
  707  std::unordered_set<String16> columnSet;
 
  709  if (maybeColumns.
ToLocal(&v8Columns)) {
 
  710    for (uint32_t 
i = 0; 
i < v8Columns->Length(); ++
i) {
 
  712      if (v8Columns->Get(context, 
i).ToLocal(&column) && column->IsString()) {
 
  714        if (columnSet.find(name) == columnSet.end()) {
 
  715          columnSet.insert(name);
 
  716          selectedColumns.push_back(name);
 
  721  if (!selectedColumns.empty()) {
 
  722    for (
const std::unique_ptr<PropertyPreview>& prop :
 
  723         *preview->getProperties()) {
 
  724      ObjectPreview* columnPreview = prop->getValuePreview(
nullptr);
 
  725      if (!columnPreview) 
continue;
 
  728      std::unordered_map<String16, PropertyPreview*> columnMap;
 
  729      for (
const std::unique_ptr<PropertyPreview>& property :
 
  730           *columnPreview->getProperties()) {
 
  731        if (columnSet.find(property->getName()) == columnSet.end()) 
continue;
 
  732        columnMap[
property->getName()] = 
property.get();
 
  734      auto filtered = std::make_unique<Array<PropertyPreview>>();
 
  735      for (
const String16& column : selectedColumns) {
 
  736        if (columnMap.find(column) == columnMap.end()) 
continue;
 
  737        filtered->push_back(columnMap[column]->Clone());
 
  739      columnPreview->setProperties(std::move(filtered));
 
  742  remoteObject->setPreview(std::move(preview));
 
 
  748    const String16& objectGroup, std::unique_ptr<WrapOptions> wrapOptions,
 
  749    bool replMode, 
bool throwOnSideEffect,
 
  750    std::shared_ptr<EvaluateCallback> 
callback) {
 
  755  std::weak_ptr<EvaluateCallback> weak_callback = 
callback;
 
  757  CHECK_EQ(weak_callback.use_count(), 1);
 
  759  if (value.IsEmpty()) {
 
  761                                  Response::InternalError());
 
  769                              objectGroup, std::move(wrapOptions), replMode,
 
  770                              throwOnSideEffect, weak_callback);
 
 
  780        Response::ServerError(
"Execution context was destroyed."));
 
 
  786    std::shared_ptr<EvaluateCallback> 
callback) {
 
 
  796    return Response::ServerError(
"Could not find object with given id");
 
  798  return Response::Success();
 
 
  809  if (objectGroup.
isEmpty()) 
return;
 
 
  832    protocol::Runtime::CallArgument* callArgument,
 
  834  if (callArgument->hasObjectId()) {
 
  835    std::unique_ptr<RemoteObjectId> remoteObjectId;
 
  838    if (!response.IsSuccess()) 
return response;
 
  841      return Response::ServerError(
 
  842          "Argument should belong to the same JavaScript world as target " 
  847  if (callArgument->hasValue() || callArgument->hasUnserializableValue()) {
 
  849    if (callArgument->hasValue()) {
 
  850      std::vector<uint8_t> json;
 
  851      v8_crdtp::json::ConvertCBORToJSON(
 
  852          v8_crdtp::SpanFrom(callArgument->getValue(
nullptr)->Serialize()),
 
  856          String16(
reinterpret_cast<const char*
>(json.data()), json.size()) +
 
  859      String16 unserializableValue = callArgument->getUnserializableValue(
"");
 
  861      if (isResolvableNumberLike(unserializableValue))
 
  862        value = 
"Number(\"" + unserializableValue + 
"\")";
 
  864        value = unserializableValue;
 
  870      return Response::ServerError(
 
  871          "Couldn't parse value object in call argument");
 
  873    return Response::Success();
 
  876  return Response::Success();
 
 
  881    protocol::Runtime::ExceptionDetails* exceptionDetails,
 
  883  if (exception.IsEmpty()) 
return Response::Success();
 
  884  std::unique_ptr<protocol::Runtime::RemoteObject> wrapped;
 
  890  if (!response.IsSuccess()) 
return response;
 
  891  exceptionDetails->setException(std::move(wrapped));
 
  892  return Response::Success();
 
 
  897    std::unique_ptr<protocol::Runtime::ExceptionDetails>* 
result) {
 
  898  if (!tryCatch.
HasCaught()) 
return Response::InternalError();
 
 
  907    std::unique_ptr<protocol::Runtime::ExceptionDetails>* 
result) {
 
  912  std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails =
 
  913      protocol::Runtime::ExceptionDetails::create()
 
  915          .setText(exception.IsEmpty() ? messageText : 
String16(
"Uncaught"))
 
  926  if (!message.IsEmpty()) {
 
  927    exceptionDetails->setScriptId(
 
  930    if (!stackTrace.
IsEmpty() && stackTrace->GetFrameCount() > 0) {
 
  931      std::unique_ptr<V8StackTraceImpl> v8StackTrace =
 
  934        exceptionDetails->setStackTrace(v8StackTrace->buildInspectorObjectImpl(
 
  941  if (!response.IsSuccess()) 
return response;
 
  942  *
result = std::move(exceptionDetails);
 
  943  return Response::Success();
 
 
  949    bool throwOnSideEffect,
 
  950    std::unique_ptr<protocol::Runtime::RemoteObject>* 
result,
 
  951    std::unique_ptr<protocol::Runtime::ExceptionDetails>* exceptionDetails) {
 
  954    if (!maybeResultValue.
ToLocal(&resultValue)) {
 
  956        return Response::ServerError(
"Execution was terminated");
 
  958      return Response::InternalError();
 
  962    if (!response.IsSuccess()) 
return response;
 
  963    if (objectGroup == 
"console") {
 
  969      return Response::ServerError(
"Execution was terminated");
 
  972    if (!throwOnSideEffect) {
 
  976    Response response = 
wrapObject(exception, objectGroup,
 
  977                                   exception->IsNativeError()
 
  981    if (!response.IsSuccess()) 
return response;
 
  985    if (!response.IsSuccess()) 
return response;
 
  987  return Response::Success();
 
 
 1004      m_injectedScript(nullptr),
 
 1007      m_ignoreExceptionsAndMuteConsole(false),
 
 1008      m_previousPauseOnExceptionsState(
v8::debug::NoBreakOnException),
 
 1009      m_userGesture(false),
 
 1011      m_contextGroupId(session->contextGroupId()),
 
 1012      m_sessionId(session->sessionId()) {}
 
 
 1018  if (!session) 
return Response::InternalError();
 
 1019  Response response = findInjectedScript(session);
 
 1020  if (!response.IsSuccess()) 
return response;
 
 1023  if (m_allowEval) 
m_context->AllowCodeGenerationFromStrings(
true);
 
 1024  return Response::Success();
 
 
 1029         !m_commandLineAPIScope.get());
 
 
 1040  DCHECK(!m_ignoreExceptionsAndMuteConsole);
 
 1041  m_ignoreExceptionsAndMuteConsole = 
true;
 
 1042  m_inspector->client()->muteMetrics(m_contextGroupId);
 
 1044  m_previousPauseOnExceptionsState =
 
 
 1050  if (!
m_inspector->debugger()->enabled()) 
return newState;
 
 1052      m_inspector->debugger()->getPauseOnExceptionsState();
 
 1053  if (presentState != newState)
 
 1054    m_inspector->debugger()->setPauseOnExceptionsState(newState);
 
 1055  return presentState;
 
 
 1060  m_userGesture = 
true;
 
 
 1066  if (
m_context->IsCodeGenerationFromStringsAllowed()) 
return;
 
 1068  m_context->AllowCodeGenerationFromStrings(
true);
 
 
 1076  m_commandLineAPIScope.reset();
 
 1078    if (m_allowEval) 
m_context->AllowCodeGenerationFromStrings(
false);
 
 
 1085  if (m_ignoreExceptionsAndMuteConsole) {
 
 1086    setPauseOnExceptionsState(m_previousPauseOnExceptionsState);
 
 1087    m_inspector->client()->unmuteMetrics(m_contextGroupId);
 
 1090  if (m_userGesture) 
m_inspector->client()->endUserGesture();
 
 
 1095                                           int executionContextId)
 
 1097      m_executionContextId(executionContextId) {}
 
 
 1114  std::unique_ptr<RemoteObjectId> remoteId;
 
 1116  if (!response.IsSuccess()) 
return response;
 
 1119  if (!response.IsSuccess()) 
return response;
 
 1121  response = injectedScript->
findObject(*remoteId, &m_object);
 
 1122  if (!response.IsSuccess()) 
return response;
 
 1123  m_injectedScript = injectedScript;
 
 1124  return Response::Success();
 
 
 1135  std::unique_ptr<RemoteCallFrameId> remoteId;
 
 1137  if (!response.IsSuccess()) 
return response;
 
 1138  m_frameOrdinal = 
static_cast<size_t>(remoteId->frameOrdinal());
 
 
 1148  if (!groupName.
isEmpty() && 
id > 0) {
 
 
 1159    const String16& groupName, protocol::Runtime::RemoteObject* remoteObject) {
 
 1160  if (!remoteObject) 
return Response::Success();
 
 1161  if (remoteObject->hasValue()) 
return Response::Success();
 
 1162  if (remoteObject->hasUnserializableValue()) 
return Response::Success();
 
 1163  if (remoteObject->getType() != RemoteObject::TypeEnum::Undefined) {
 
 1172    if (!injectedScript) {
 
 1173      return Response::ServerError(
"Cannot find context with specified id");
 
 1175    remoteObject->setObjectId(injectedScript->
bindObject(value, groupName));
 
 1177  return Response::Success();
 
 
 1189template <
typename... Args>
 
 1191  Id id = m_lastUsedId++;
 
 1194                                                 std::forward<Args>(
args)...);
 
 1195  m_promiseHandlers.emplace(
id, handler);
 
 
 1200  auto iter = m_promiseHandlers.find(
id);
 
 1201  CHECK_NE(iter, m_promiseHandlers.end());
 
 1205    case DiscardReason::kPromiseCollected:
 
 1206      sendFailure(handler, Response::ServerError(
"Promise was collected"));
 
 1208    case DiscardReason::kTearDown:
 
 1209      sendFailure(handler, Response::ServerError(
 
 1210                               "Tearing down inspector/session/context"));
 
 1212    case DiscardReason::kFulfilled:
 
 1217  m_promiseHandlers.erase(
id);
 
 
 1222  auto iter = m_promiseHandlers.find(
id);
 
 1223  if (iter == m_promiseHandlers.end()) 
return nullptr;
 
 1225  return iter->second.get();
 
 
 1230    const protocol::DispatchResponse& response)
 const {
 
 1233      inspector->
sessionById(handler->m_contextGroupId, handler->m_sessionId);
 
 1234  if (!session) 
return;
 
 1237  if (!res.IsSuccess()) 
return;
 
 
 1243  while (!m_promiseHandlers.empty()) {
 
 1244    discard(m_promiseHandlers.begin()->first, DiscardReason::kTearDown);
 
 1246  CHECK(m_promiseHandlers.empty());
 
 
static Local< StackTrace > GetStackTrace(Local< Value > exception)
static MaybeLocal< Function > New(Local< Context > context, FunctionCallback callback, Local< Value > data=Local< Value >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect)
V8_INLINE Local< S > As() const
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
static Local< Number > New(Isolate *isolate, double value)
V8_INLINE void AnnotateStrongRetainer(const char *label)
V8_INLINE Local< T > Get(Isolate *isolate) const
V8_INLINE P * ClearWeak()
V8_INLINE void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
static V8_WARN_UNUSED_RESULT MaybeLocal< Resolver > New(Local< Context > context)
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromOneByte(Isolate *isolate, const uint8_t *data, NewStringType type=NewStringType::kNormal, int length=-1)
void SetVerbose(bool value)
Local< v8::Message > Message() const
bool HasTerminated() const
Local< Value > Exception() const
V8_INLINE bool IsEmpty() const
static void sendFailure(std::weak_ptr< EvaluateCallback > callback, InjectedScript *injectedScript, const protocol::DispatchResponse &response)
static void sendSuccess(std::weak_ptr< EvaluateCallback > callback, InjectedScript *injectedScript, std::unique_ptr< protocol::Runtime::RemoteObject > result, std::unique_ptr< protocol::Runtime::ExceptionDetails > exceptionDetails)
Response findInjectedScript(V8InspectorSessionImpl *) override
CallFrameScope(V8InspectorSessionImpl *, const String16 &remoteCallFrameId)
~CallFrameScope() override
Response findInjectedScript(V8InspectorSessionImpl *) override
ContextScope(V8InspectorSessionImpl *, int executionContextId)
ObjectScope(V8InspectorSessionImpl *, const String16 &remoteObjectId)
Response findInjectedScript(V8InspectorSessionImpl *) override
std::weak_ptr< EvaluateCallback > m_callback
static void thenCallback(const v8::FunctionCallbackInfo< v8::Value > &info)
static v8::Local< v8::String > GetDotReplResultString(v8::Isolate *isolate)
static void cleanup(const v8::WeakCallbackInfo< PromiseHandlerTracker::Id > &data)
v8::Global< v8::Promise > m_evaluationResult
void thenCallback(v8::Local< v8::Value > value)
static void add(V8InspectorSessionImpl *session, v8::Local< v8::Context > context, v8::Local< v8::Value > value, int executionContextId, const String16 &objectGroup, std::unique_ptr< WrapOptions > wrapOptions, bool replMode, bool throwOnSideEffect, std::weak_ptr< EvaluateCallback > callback)
void catchCallback(v8::Local< v8::Value > result)
static void catchCallback(const v8::FunctionCallbackInfo< v8::Value > &info)
std::unique_ptr< WrapOptions > m_wrapOptions
ProtocolPromiseHandler(PromiseHandlerTracker::Id id, V8InspectorSessionImpl *session, int executionContextId, const String16 &objectGroup, std::unique_ptr< WrapOptions > wrapOptions, bool replMode, bool throwOnSideEffect, std::weak_ptr< EvaluateCallback > callback, v8::Local< v8::Promise > evaluationResult)
V8InspectorImpl * m_inspector
v8::Local< v8::Context > context() const
InjectedScript * injectedScript() const
void pretendUserGesture()
v8::debug::ExceptionBreakState setPauseOnExceptionsState(v8::debug::ExceptionBreakState)
void ignoreExceptionsAndMuteConsole()
Scope(V8InspectorSessionImpl *)
void installCommandLineAPI()
void allowCodeGenerationFromStrings()
void setTryCatchVerbose()
InspectedContext * m_context
v8::Local< v8::Value > lastEvaluationResult() const
std::unordered_map< String16, std::vector< int > > m_nameToObjectGroup
Response wrapObject(v8::Local< v8::Value >, const String16 &groupName, const WrapOptions &wrapOptions, std::unique_ptr< protocol::Runtime::RemoteObject > *result)
Response getProperties(v8::Local< v8::Object >, const String16 &groupName, bool ownProperties, bool accessorPropertiesOnly, bool nonIndexedPropertiesOnly, const WrapOptions &wrapOptions, std::unique_ptr< protocol::Array< protocol::Runtime::PropertyDescriptor > > *result, std::unique_ptr< protocol::Runtime::ExceptionDetails > *)
static Response bindRemoteObjectIfNeeded(int sessionId, v8::Local< v8::Context > context, v8::Local< v8::Value >, const String16 &groupName, protocol::Runtime::RemoteObject *remoteObject)
void setLastEvaluationResult(v8::Local< v8::Value > result)
v8::Global< v8::Object > m_commandLineAPI
void setCustomObjectFormatterEnabled(bool)
void releaseObjectGroup(const String16 &)
Response resolveCallArgument(protocol::Runtime::CallArgument *, v8::Local< v8::Value > *result)
std::unordered_map< int, v8::Global< v8::Value > > m_idToWrappedObject
InjectedScript(InspectedContext *, int sessionId)
String16 bindObject(v8::Local< v8::Value >, const String16 &groupName)
v8::Local< v8::Object > commandLineAPI()
void addPromiseCallback(V8InspectorSessionImpl *session, v8::MaybeLocal< v8::Value > value, const String16 &objectGroup, std::unique_ptr< WrapOptions > wrapOptions, bool replMode, bool throwOnSideEffect, std::shared_ptr< EvaluateCallback > callback)
Response wrapEvaluateResult(v8::MaybeLocal< v8::Value > maybeResultValue, const v8::TryCatch &, const String16 &objectGroup, const WrapOptions &wrapOptions, bool throwOnSideEffect, std::unique_ptr< protocol::Runtime::RemoteObject > *result, std::unique_ptr< protocol::Runtime::ExceptionDetails > *)
Response addExceptionToDetails(v8::Local< v8::Value > exception, protocol::Runtime::ExceptionDetails *exceptionDetails, const String16 &objectGroup)
Response getInternalAndPrivateProperties(v8::Local< v8::Value >, const String16 &groupName, bool accessorPropertiesOnly, std::unique_ptr< protocol::Array< protocol::Runtime::InternalPropertyDescriptor > > *internalProperties, std::unique_ptr< protocol::Array< protocol::Runtime::PrivatePropertyDescriptor > > *privateProperties)
void unbindObject(int id)
void releaseObject(const String16 &objectId)
Response wrapObjectMirror(const ValueMirror &mirror, const String16 &groupName, const WrapOptions &wrapOptions, v8::MaybeLocal< v8::Value > customPreviewConfig, int maxCustomPreviewDepth, std::unique_ptr< protocol::Runtime::RemoteObject > *result)
Response findObject(const RemoteObjectId &, v8::Local< v8::Value > *) const
v8::Global< v8::Value > m_lastEvaluationResult
Response createExceptionDetails(const v8::TryCatch &, const String16 &groupName, std::unique_ptr< protocol::Runtime::ExceptionDetails > *result)
std::unique_ptr< protocol::Runtime::RemoteObject > wrapTable(v8::Local< v8::Object > table, v8::MaybeLocal< v8::Array > columns)
String16 objectGroupName(const RemoteObjectId &) const
void discardEvaluateCallbacks()
bool m_customPreviewEnabled
std::unordered_set< std::shared_ptr< EvaluateCallback > > m_evaluateCallbacks
std::unordered_map< int, String16 > m_idToObjectGroupName
void deleteEvaluateCallback(std::shared_ptr< EvaluateCallback > callback)
v8::Local< v8::Context > context() const
static int contextId(v8::Local< v8::Context >)
InjectedScript * getInjectedScript(int sessionId)
V8InspectorImpl * inspector() const
v8::Isolate * isolate() const
InjectedScript::ProtocolPromiseHandler * get(Id id) const
void discard(Id id, DiscardReason reason)
Id create(Args &&... args)
void sendFailure(InjectedScript::ProtocolPromiseHandler *handler, const protocol::DispatchResponse &response) const
static Response parse(const String16 &, std::unique_ptr< RemoteCallFrameId > *)
static Response parse(const String16 &, std::unique_ptr< RemoteObjectId > *)
static String16 serialize(uint64_t isolateId, int injectedScriptId, int id)
static String16 fromInteger(int)
v8::Local< v8::Object > createCommandLineAPI(v8::Local< v8::Context > context, int sessionId)
std::unique_ptr< V8StackTraceImpl > createStackTrace(v8::Local< v8::StackTrace >)
std::unique_ptr< V8StackTraceImpl > captureStackTrace(bool fullStack)
virtual void dispatchError(v8::Local< v8::Context >, v8::Local< v8::Message >, v8::Local< v8::Value >)
v8::MaybeLocal< v8::Value > compileAndRunInternalScript(v8::Local< v8::Context >, v8::Local< v8::String >)
v8::Isolate * isolate() const
InspectedContext * getContext(int groupId, int contextId) const
V8_EXPORT_PRIVATE V8Console * console()
uint64_t isolateId() override
PromiseHandlerTracker & promiseHandlerTracker()
V8InspectorClient * client()
unsigned nextExceptionId()
V8InspectorSessionImpl * sessionById(int contextGroupId, int sessionId)
V8Inspector::ClientTrustLevel clientTrustLevel()
Response findInjectedScript(int contextId, InjectedScript *&)
V8InspectorImpl * inspector() const
static std::unique_ptr< ValueMirror > create(v8::Local< v8::Context > context, v8::Local< v8::Value > value)
virtual v8::Local< v8::Value > v8Value(v8::Isolate *isolate) const =0
virtual Response buildDeepSerializedValue(v8::Local< v8::Context > context, int maxDepth, v8::Local< v8::Object > additionalParameters, V8SerializationDuplicateTracker &duplicateTracker, std::unique_ptr< protocol::DictionaryValue > *result) const =0
static bool getProperties(v8::Local< v8::Context > context, v8::Local< v8::Object > object, bool ownProperties, bool accessorPropertiesOnly, bool nonIndexedPropertiesOnly, PropertyAccumulator *accumulator)
virtual protocol::Response buildRemoteObject(v8::Local< v8::Context > context, const WrapOptions &wrapOptions, std::unique_ptr< protocol::Runtime::RemoteObject > *result) const =0
static void getInternalProperties(v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::vector< InternalPropertyMirror > *mirrors)
static std::vector< PrivatePropertyMirror > getPrivateProperties(v8::Local< v8::Context > context, v8::Local< v8::Object > object, bool accessorPropertiesOnly)
base::Vector< const DirectHandle< Object > > args
std::vector< PropertyMirror > * m_mirrors
ZoneVector< RpoNumber > & result
ZoneStack< RpoNumber > & stack
MaybeLocal< Message > GetMessageFromPromise(Local< Promise > p)
v8_inspector::V8Inspector * GetInspector(Isolate *isolate)
void generateCustomPreview(v8::Isolate *isolate, int sessionId, const String16 &groupName, v8::Local< v8::Object > object, v8::MaybeLocal< v8::Value > maybeConfig, int maxDepth, std::unique_ptr< CustomPreview > *preview)
String16 toProtocolString(v8::Isolate *isolate, v8::Local< v8::String > value)
const int kMaxCustomPreviewDepth
v8::Local< v8::String > toV8String(v8::Isolate *isolate, const String16 &string)
V8_INLINE Local< Primitive > Undefined(Isolate *isolate)
#define CHECK_NE(lhs, rhs)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
WrapSerializationOptions serializationOptions
v8::Global< v8::Object > additionalParameters
v8::Local< v8::Context > m_context
V8InspectorImpl * m_inspector
std::unique_ptr< ValueMirror > value