| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/inspector/MainThreadDebugger.h" | 31 #include "core/inspector/MainThreadDebugger.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/BindingSecurity.h" | 33 #include "bindings/core/v8/BindingSecurity.h" |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 36 #include "bindings/core/v8/SourceLocation.h" |
| 36 #include "bindings/core/v8/V8Node.h" | 37 #include "bindings/core/v8/V8Node.h" |
| 37 #include "bindings/core/v8/V8Window.h" | 38 #include "bindings/core/v8/V8Window.h" |
| 38 #include "core/dom/ContainerNode.h" | 39 #include "core/dom/ContainerNode.h" |
| 39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 40 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
| 41 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
| 42 #include "core/dom/StaticNodeList.h" | 43 #include "core/dom/StaticNodeList.h" |
| 43 #include "core/frame/FrameConsole.h" | 44 #include "core/frame/FrameConsole.h" |
| 44 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
| 45 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 46 #include "core/frame/UseCounter.h" | 47 #include "core/frame/UseCounter.h" |
| 48 #include "core/inspector/ConsoleMessage.h" |
| 47 #include "core/inspector/IdentifiersFactory.h" | 49 #include "core/inspector/IdentifiersFactory.h" |
| 48 #include "core/inspector/InspectedFrames.h" | 50 #include "core/inspector/InspectedFrames.h" |
| 49 #include "core/inspector/InspectorTaskRunner.h" | 51 #include "core/inspector/InspectorTaskRunner.h" |
| 50 #include "core/timing/MemoryInfo.h" | 52 #include "core/timing/MemoryInfo.h" |
| 51 #include "core/workers/MainThreadWorkletGlobalScope.h" | 53 #include "core/workers/MainThreadWorkletGlobalScope.h" |
| 52 #include "core/xml/XPathEvaluator.h" | 54 #include "core/xml/XPathEvaluator.h" |
| 53 #include "core/xml/XPathResult.h" | 55 #include "core/xml/XPathResult.h" |
| 54 #include "platform/UserGestureIndicator.h" | 56 #include "platform/UserGestureIndicator.h" |
| 55 #include "platform/v8_inspector/public/V8Debugger.h" | 57 #include "platform/v8_inspector/public/V8Debugger.h" |
| 56 #include "wtf/PtrUtil.h" | 58 #include "wtf/PtrUtil.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 162 } |
| 161 | 163 |
| 162 void MainThreadDebugger::quitMessageLoopOnPause() | 164 void MainThreadDebugger::quitMessageLoopOnPause() |
| 163 { | 165 { |
| 164 if (m_clientMessageLoop) | 166 if (m_clientMessageLoop) |
| 165 m_clientMessageLoop->quitNow(); | 167 m_clientMessageLoop->quitNow(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 void MainThreadDebugger::muteWarningsAndDeprecations() | 170 void MainThreadDebugger::muteWarningsAndDeprecations() |
| 169 { | 171 { |
| 170 FrameConsole::mute(); | |
| 171 UseCounter::muteForInspector(); | 172 UseCounter::muteForInspector(); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void MainThreadDebugger::unmuteWarningsAndDeprecations() | 175 void MainThreadDebugger::unmuteWarningsAndDeprecations() |
| 175 { | 176 { |
| 176 FrameConsole::unmute(); | |
| 177 UseCounter::unmuteForInspector(); | 177 UseCounter::unmuteForInspector(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void MainThreadDebugger::muteConsole() | |
| 181 { | |
| 182 FrameConsole::mute(); | |
| 183 } | |
| 184 | |
| 185 void MainThreadDebugger::unmuteConsole() | |
| 186 { | |
| 187 FrameConsole::unmute(); | |
| 188 } | |
| 189 | |
| 190 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c
alling, v8::Local<v8::Context> target) | 180 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c
alling, v8::Local<v8::Context> target) |
| 191 { | 181 { |
| 192 ExecutionContext* executionContext = toExecutionContext(target); | 182 ExecutionContext* executionContext = toExecutionContext(target); |
| 193 ASSERT(executionContext); | 183 ASSERT(executionContext); |
| 194 | 184 |
| 195 if (executionContext->isMainThreadWorkletGlobalScope()) { | 185 if (executionContext->isMainThreadWorkletGlobalScope()) { |
| 196 MainThreadWorkletGlobalScope* globalScope = toMainThreadWorkletGlobalSco
pe(executionContext); | 186 MainThreadWorkletGlobalScope* globalScope = toMainThreadWorkletGlobalSco
pe(executionContext); |
| 197 return globalScope && BindingSecurity::shouldAllowAccessTo(m_isolate, to
LocalDOMWindow(toDOMWindow(calling)), globalScope, DoNotReportSecurityError); | 187 return globalScope && BindingSecurity::shouldAllowAccessTo(m_isolate, to
LocalDOMWindow(toDOMWindow(calling)), globalScope, DoNotReportSecurityError); |
| 198 } | 188 } |
| 199 | 189 |
| 200 DOMWindow* window = toDOMWindow(target); | 190 DOMWindow* window = toDOMWindow(target); |
| 201 return window && BindingSecurity::shouldAllowAccessTo(m_isolate, toLocalDOMW
indow(toDOMWindow(calling)), window, DoNotReportSecurityError); | 191 return window && BindingSecurity::shouldAllowAccessTo(m_isolate, toLocalDOMW
indow(toDOMWindow(calling)), window, DoNotReportSecurityError); |
| 202 } | 192 } |
| 203 | 193 |
| 204 int MainThreadDebugger::ensureDefaultContextInGroup(int contextGroupId) | 194 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte
xtGroupId) |
| 195 { |
| 196 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
| 197 ScriptState* scriptState = frame ? ScriptState::forMainWorld(frame) : nullpt
r; |
| 198 return scriptState ? scriptState->context() : v8::Local<v8::Context>(); |
| 199 } |
| 200 |
| 201 void MainThreadDebugger::messageAddedToConsole(int contextGroupId, MessageSource
source, MessageLevel level, const String16& message, const String16& url, unsig
ned lineNumber, unsigned columnNumber, V8StackTrace* stackTrace) |
| 205 { | 202 { |
| 206 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 203 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
| 207 if (!frame) | 204 if (!frame) |
| 208 return 0; | |
| 209 ScriptState* scriptState = ScriptState::forMainWorld(frame); | |
| 210 if (!scriptState) | |
| 211 return 0; | |
| 212 v8::HandleScope scopes(scriptState->isolate()); | |
| 213 return V8Debugger::contextId(scriptState->context()); | |
| 214 } | |
| 215 | |
| 216 void MainThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context,
ConsoleMessage* consoleMessage) | |
| 217 { | |
| 218 ExecutionContext* executionContext = toExecutionContext(context); | |
| 219 ASSERT(executionContext); | |
| 220 if (executionContext->isWorkletGlobalScope()) { | |
| 221 executionContext->addConsoleMessage(consoleMessage); | |
| 222 return; | 205 return; |
| 223 } | 206 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa
ge, SourceLocation::create(url, lineNumber, columnNumber, stackTrace ? stackTrac
e->clone() : nullptr, 0)); |
| 224 | 207 frame->console().reportMessageToClient(consoleMessage); |
| 225 DOMWindow* window = toDOMWindow(context); | |
| 226 if (!window) | |
| 227 return; | |
| 228 LocalDOMWindow* localDomWindow = toLocalDOMWindow(window); | |
| 229 if (!localDomWindow) | |
| 230 return; | |
| 231 LocalFrame* frame = localDomWindow->frame(); | |
| 232 if (!frame) | |
| 233 return; | |
| 234 frame->console().addMessage(consoleMessage); | |
| 235 } | 208 } |
| 236 | 209 |
| 237 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) | 210 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) |
| 238 { | 211 { |
| 239 ExecutionContext* executionContext = toExecutionContext(context); | 212 ExecutionContext* executionContext = toExecutionContext(context); |
| 240 ASSERT_UNUSED(executionContext, executionContext); | 213 ASSERT_UNUSED(executionContext, executionContext); |
| 241 ASSERT(executionContext->isDocument()); | 214 ASSERT(executionContext->isDocument()); |
| 242 return toV8(MemoryInfo::create(), context->Global(), isolate); | 215 return toV8(MemoryInfo::create(), context->Global(), isolate); |
| 243 } | 216 } |
| 244 | 217 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return; | 312 return; |
| 340 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 313 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
| 341 return; | 314 return; |
| 342 } | 315 } |
| 343 info.GetReturnValue().Set(nodes); | 316 info.GetReturnValue().Set(nodes); |
| 344 } | 317 } |
| 345 exceptionState.throwIfNeeded(); | 318 exceptionState.throwIfNeeded(); |
| 346 } | 319 } |
| 347 | 320 |
| 348 } // namespace blink | 321 } // namespace blink |
| OLD | NEW |