| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/frame/FrameHost.h" | 49 #include "core/frame/FrameHost.h" |
| 50 #include "core/frame/LocalDOMWindow.h" | 50 #include "core/frame/LocalDOMWindow.h" |
| 51 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 53 #include "core/frame/UseCounter.h" | 53 #include "core/frame/UseCounter.h" |
| 54 #include "core/inspector/ConsoleMessage.h" | 54 #include "core/inspector/ConsoleMessage.h" |
| 55 #include "core/inspector/ConsoleMessageStorage.h" | 55 #include "core/inspector/ConsoleMessageStorage.h" |
| 56 #include "core/inspector/IdentifiersFactory.h" | 56 #include "core/inspector/IdentifiersFactory.h" |
| 57 #include "core/inspector/InspectedFrames.h" | 57 #include "core/inspector/InspectedFrames.h" |
| 58 #include "core/inspector/InspectorTaskRunner.h" | 58 #include "core/inspector/InspectorTaskRunner.h" |
| 59 #include "core/inspector/V8InspectorStringConversion.h" |
| 60 #include "core/inspector/protocol/InspectorProtocol.h" |
| 59 #include "core/timing/MemoryInfo.h" | 61 #include "core/timing/MemoryInfo.h" |
| 60 #include "core/workers/MainThreadWorkletGlobalScope.h" | 62 #include "core/workers/MainThreadWorkletGlobalScope.h" |
| 61 #include "core/xml/XPathEvaluator.h" | 63 #include "core/xml/XPathEvaluator.h" |
| 62 #include "core/xml/XPathResult.h" | 64 #include "core/xml/XPathResult.h" |
| 63 #include "platform/UserGestureIndicator.h" | 65 #include "platform/UserGestureIndicator.h" |
| 64 #include "platform/v8_inspector/public/V8Inspector.h" | 66 #include "platform/v8_inspector/public/V8Inspector.h" |
| 65 #include "wtf/PtrUtil.h" | 67 #include "wtf/PtrUtil.h" |
| 66 #include "wtf/ThreadingPrimitives.h" | 68 #include "wtf/ThreadingPrimitives.h" |
| 67 #include <memory> | 69 #include <memory> |
| 68 | 70 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 143 } |
| 142 | 144 |
| 143 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) | 145 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) |
| 144 { | 146 { |
| 145 ASSERT(isMainThread()); | 147 ASSERT(isMainThread()); |
| 146 v8::HandleScope handles(scriptState->isolate()); | 148 v8::HandleScope handles(scriptState->isolate()); |
| 147 DOMWrapperWorld& world = scriptState->world(); | 149 DOMWrapperWorld& world = scriptState->world(); |
| 148 std::unique_ptr<protocol::DictionaryValue> auxData = protocol::DictionaryVal
ue::create(); | 150 std::unique_ptr<protocol::DictionaryValue> auxData = protocol::DictionaryVal
ue::create(); |
| 149 auxData->setBoolean("isDefault", world.isMainWorld()); | 151 auxData->setBoolean("isDefault", world.isMainWorld()); |
| 150 auxData->setString("frameId", IdentifiersFactory::frameId(frame)); | 152 auxData->setString("frameId", IdentifiersFactory::frameId(frame)); |
| 151 v8_inspector::V8ContextInfo contextInfo(scriptState->context(), contextGroup
Id(frame), world.isIsolatedWorld() ? world.isolatedWorldHumanReadableName() : ""
); | 153 v8_inspector::V8ContextInfo contextInfo(scriptState->context(), contextGroup
Id(frame), world.isIsolatedWorld() ? toV8InspectorString(world.isolatedWorldHuma
nReadableName()) : v8_inspector::String16()); |
| 152 if (origin) | 154 if (origin) |
| 153 contextInfo.origin = origin->toRawString(); | 155 contextInfo.origin = toV8InspectorString(origin->toRawString()); |
| 154 contextInfo.auxData = auxData->toJSONString(); | 156 contextInfo.auxData = toV8InspectorString(auxData->toJSONString()); |
| 155 contextInfo.hasMemoryOnConsole = scriptState->getExecutionContext()->isDocum
ent(); | 157 contextInfo.hasMemoryOnConsole = scriptState->getExecutionContext()->isDocum
ent(); |
| 156 v8Inspector()->contextCreated(contextInfo); | 158 v8Inspector()->contextCreated(contextInfo); |
| 157 } | 159 } |
| 158 | 160 |
| 159 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) | 161 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) |
| 160 { | 162 { |
| 161 v8::HandleScope handles(scriptState->isolate()); | 163 v8::HandleScope handles(scriptState->isolate()); |
| 162 v8Inspector()->contextDestroyed(scriptState->context()); | 164 v8Inspector()->contextDestroyed(scriptState->context()); |
| 163 } | 165 } |
| 164 | 166 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 frame = toMainThreadWorkletGlobalScope(context)->frame(); | 177 frame = toMainThreadWorkletGlobalScope(context)->frame(); |
| 176 if (!frame) | 178 if (!frame) |
| 177 return; | 179 return; |
| 178 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController(
)->getScriptState(); | 180 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController(
)->getScriptState(); |
| 179 } else { | 181 } else { |
| 180 NOTREACHED(); | 182 NOTREACHED(); |
| 181 } | 183 } |
| 182 | 184 |
| 183 frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, e
vent->messageForConsole(), event->location()); | 185 frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, e
vent->messageForConsole(), event->location()); |
| 184 | 186 |
| 185 const String16 defaultMessage = "Uncaught"; | 187 const v8_inspector::String16 defaultMessage = "Uncaught"; |
| 186 if (scriptState && scriptState->contextIsValid()) { | 188 if (scriptState && scriptState->contextIsValid()) { |
| 187 ScriptState::Scope scope(scriptState); | 189 ScriptState::Scope scope(scriptState); |
| 188 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE
ventWrapper(scriptState, event, scriptState->context()->Global()); | 190 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE
ventWrapper(scriptState, event, scriptState->context()->Global()); |
| 189 SourceLocation* location = event->location(); | 191 SourceLocation* location = event->location(); |
| 190 v8Inspector()->exceptionThrown(scriptState->context(), defaultMessage, e
xception, event->messageForConsole(), location->url(), location->lineNumber(), l
ocation->columnNumber(), location->takeStackTrace(), location->scriptId()); | 192 v8Inspector()->exceptionThrown(scriptState->context(), defaultMessage, e
xception, toV8InspectorString(event->messageForConsole()), toV8InspectorString(l
ocation->url()), location->lineNumber(), location->columnNumber(), location->tak
eStackTrace(), location->scriptId()); |
| 191 } | 193 } |
| 192 } | 194 } |
| 193 | 195 |
| 194 int MainThreadDebugger::contextGroupId(LocalFrame* frame) | 196 int MainThreadDebugger::contextGroupId(LocalFrame* frame) |
| 195 { | 197 { |
| 196 LocalFrame* localFrameRoot = frame->localFrameRoot(); | 198 LocalFrame* localFrameRoot = frame->localFrameRoot(); |
| 197 return frameId(localFrameRoot); | 199 return frameId(localFrameRoot); |
| 198 } | 200 } |
| 199 | 201 |
| 200 MainThreadDebugger* MainThreadDebugger::instance() | 202 MainThreadDebugger* MainThreadDebugger::instance() |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return frame->script().canExecuteScripts(NotAboutToExecuteScript); | 282 return frame->script().canExecuteScripts(NotAboutToExecuteScript); |
| 281 } | 283 } |
| 282 | 284 |
| 283 void MainThreadDebugger::runIfWaitingForDebugger(int contextGroupId) | 285 void MainThreadDebugger::runIfWaitingForDebugger(int contextGroupId) |
| 284 { | 286 { |
| 285 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 287 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
| 286 if (m_clientMessageLoop) | 288 if (m_clientMessageLoop) |
| 287 m_clientMessageLoop->runIfWaitingForDebugger(frame); | 289 m_clientMessageLoop->runIfWaitingForDebugger(frame); |
| 288 } | 290 } |
| 289 | 291 |
| 290 void MainThreadDebugger::consoleAPIMessage(int contextGroupId, v8_inspector::V8C
onsoleAPIType type, const String16& message, const String16& url, unsigned lineN
umber, unsigned columnNumber, v8_inspector::V8StackTrace* stackTrace) | 292 void MainThreadDebugger::consoleAPIMessage(int contextGroupId, v8_inspector::V8C
onsoleAPIType type, const v8_inspector::String16& message, const v8_inspector::S
tring16& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8StackT
race* stackTrace) |
| 291 { | 293 { |
| 292 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 294 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
| 293 if (!frame) | 295 if (!frame) |
| 294 return; | 296 return; |
| 295 if (type == v8_inspector::V8ConsoleAPIType::kClear && frame->host()) | 297 if (type == v8_inspector::V8ConsoleAPIType::kClear && frame->host()) |
| 296 frame->host()->consoleMessageStorage().clear(); | 298 frame->host()->consoleMessageStorage().clear(); |
| 297 std::unique_ptr<SourceLocation> location = SourceLocation::create(url, lineN
umber, columnNumber, stackTrace ? stackTrace->clone() : nullptr, 0); | 299 std::unique_ptr<SourceLocation> location = SourceLocation::create(toCoreStri
ng(url), lineNumber, columnNumber, stackTrace ? stackTrace->clone() : nullptr, 0
); |
| 298 frame->console().reportMessageToClient(ConsoleAPIMessageSource, consoleAPITy
peToMessageLevel(type), message, location.get()); | 300 frame->console().reportMessageToClient(ConsoleAPIMessageSource, consoleAPITy
peToMessageLevel(type), toCoreString(message), location.get()); |
| 299 } | 301 } |
| 300 | 302 |
| 301 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) | 303 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) |
| 302 { | 304 { |
| 303 ExecutionContext* executionContext = toExecutionContext(context); | 305 ExecutionContext* executionContext = toExecutionContext(context); |
| 304 ASSERT_UNUSED(executionContext, executionContext); | 306 ASSERT_UNUSED(executionContext, executionContext); |
| 305 ASSERT(executionContext->isDocument()); | 307 ASSERT(executionContext->isDocument()); |
| 306 return toV8(MemoryInfo::create(), context->Global(), isolate); | 308 return toV8(MemoryInfo::create(), context->Global(), isolate); |
| 307 } | 309 } |
| 308 | 310 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 return; | 405 return; |
| 404 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 406 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
| 405 return; | 407 return; |
| 406 } | 408 } |
| 407 info.GetReturnValue().Set(nodes); | 409 info.GetReturnValue().Set(nodes); |
| 408 } | 410 } |
| 409 exceptionState.throwIfNeeded(); | 411 exceptionState.throwIfNeeded(); |
| 410 } | 412 } |
| 411 | 413 |
| 412 } // namespace blink | 414 } // namespace blink |
| OLD | NEW |