void InspectorAnimationAgent::resolveAnimation( ErrorString* errorString, const String& animationId, std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject>* result) { blink::Animation* animation = assertAnimation(errorString, animationId); if (!animation) return; if (m_idToAnimationClone.get(animationId)) animation = m_idToAnimationClone.get(animationId); const Element* element = toKeyframeEffect(animation->effect())->target(); Document* document = element->ownerDocument(); LocalFrame* frame = document ? document->frame() : nullptr; ScriptState* scriptState = frame ? ScriptState::forMainWorld(frame) : nullptr; if (!scriptState) { *errorString = "Element not associated with a document."; return; } ScriptState::Scope scope(scriptState); static const char kAnimationObjectGroup[] = "animation"; m_v8Session->releaseObjectGroup( toV8InspectorStringView(kAnimationObjectGroup)); *result = m_v8Session->wrapObject( scriptState->context(), toV8(animation, scriptState->context()->Global(), scriptState->isolate()), toV8InspectorStringView(kAnimationObjectGroup)); if (!*result) *errorString = "Element not associated with a document."; }
void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* frame, SecurityOrigin* origin) { ASSERT(isMainThread()); v8::HandleScope handles(scriptState->isolate()); DOMWrapperWorld& world = scriptState->world(); std::unique_ptr<protocol::DictionaryValue> auxDataValue = protocol::DictionaryValue::create(); auxDataValue->setBoolean("isDefault", world.isMainWorld()); auxDataValue->setString("frameId", IdentifiersFactory::frameId(frame)); String auxData = auxDataValue->toJSONString(); String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHumanReadableName() : String(); String originString = origin ? origin->toRawString() : String(); v8_inspector::V8ContextInfo contextInfo( scriptState->context(), contextGroupId(frame), toV8InspectorStringView(humanReadableName)); contextInfo.origin = toV8InspectorStringView(originString); contextInfo.auxData = toV8InspectorStringView(auxData); contextInfo.hasMemoryOnConsole = scriptState->getExecutionContext() && scriptState->getExecutionContext()->isDocument(); v8Inspector()->contextCreated(contextInfo); }
void MainThreadDebugger::exceptionThrown(ExecutionContext* context, ErrorEvent* event) { LocalFrame* frame = nullptr; ScriptState* scriptState = nullptr; if (context->isDocument()) { frame = toDocument(context)->frame(); if (!frame) return; scriptState = event->world() ? ScriptState::forWorld(frame, *event->world()) : nullptr; } else if (context->isMainThreadWorkletGlobalScope()) { frame = toMainThreadWorkletGlobalScope(context)->frame(); if (!frame) return; scriptState = toMainThreadWorkletGlobalScope(context) ->scriptController() ->getScriptState(); } else { NOTREACHED(); } frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, event->messageForConsole(), event->location()); const String defaultMessage = "Uncaught"; if (scriptState && scriptState->contextIsValid()) { ScriptState::Scope scope(scriptState); v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorEventWrapper( scriptState, event, scriptState->context()->Global()); SourceLocation* location = event->location(); String message = event->messageForConsole(); String url = location->url(); v8Inspector()->exceptionThrown( scriptState->context(), toV8InspectorStringView(defaultMessage), exception, toV8InspectorStringView(message), toV8InspectorStringView(url), location->lineNumber(), location->columnNumber(), location->takeStackTrace(), location->scriptId()); } }
std::unique_ptr<v8_inspector::StringBuffer> toV8InspectorStringBuffer( const StringView& string) { return v8_inspector::StringBuffer::create(toV8InspectorStringView(string)); }