OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/inspector/ThreadDebugger.h" | 5 #include "core/inspector/ThreadDebugger.h" |
6 | 6 |
7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
8 #include "bindings/core/v8/V8DOMException.h" | 8 #include "bindings/core/v8/V8DOMException.h" |
9 #include "bindings/core/v8/V8DOMTokenList.h" | 9 #include "bindings/core/v8/V8DOMTokenList.h" |
10 #include "bindings/core/v8/V8HTMLAllCollection.h" | 10 #include "bindings/core/v8/V8HTMLAllCollection.h" |
11 #include "bindings/core/v8/V8HTMLCollection.h" | 11 #include "bindings/core/v8/V8HTMLCollection.h" |
12 #include "bindings/core/v8/V8Node.h" | 12 #include "bindings/core/v8/V8Node.h" |
13 #include "bindings/core/v8/V8NodeList.h" | 13 #include "bindings/core/v8/V8NodeList.h" |
| 14 #include "bindings/core/v8/V8RecursionScope.h" |
| 15 #include "bindings/core/v8/V8ScriptRunner.h" |
| 16 #include "core/dom/Microtask.h" |
14 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 17 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
15 #include "platform/ScriptForbiddenScope.h" | |
16 #include "wtf/CurrentTime.h" | 18 #include "wtf/CurrentTime.h" |
17 | 19 |
18 namespace blink { | 20 namespace blink { |
19 | 21 |
20 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) | 22 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) |
21 : m_isolate(isolate) | 23 : m_isolate(isolate) |
22 , m_debugger(V8Debugger::create(isolate, this)) | 24 , m_debugger(V8Debugger::create(isolate, this)) |
23 { | 25 { |
24 } | 26 } |
25 | 27 |
26 ThreadDebugger::~ThreadDebugger() | 28 ThreadDebugger::~ThreadDebugger() |
27 { | 29 { |
28 } | 30 } |
29 | 31 |
30 void ThreadDebugger::eventListeners(v8::Local<v8::Value> value, V8EventListenerI
nfoList& result) | 32 void ThreadDebugger::eventListeners(v8::Local<v8::Value> value, V8EventListenerI
nfoList& result) |
31 { | 33 { |
32 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(m_isolate, value, res
ult); | 34 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(m_isolate, value, res
ult); |
33 } | 35 } |
34 | 36 |
| 37 v8::MaybeLocal<v8::Object> ThreadDebugger::instantiateObject(v8::Local<v8::Funct
ion> function) |
| 38 { |
| 39 return V8ScriptRunner::instantiateObject(m_isolate, function); |
| 40 } |
| 41 |
| 42 v8::MaybeLocal<v8::Value> ThreadDebugger::runCompiledScript(v8::Local<v8::Contex
t> context, v8::Local<v8::Script> script) |
| 43 { |
| 44 return V8ScriptRunner::runCompiledScript(m_isolate, script, toExecutionConte
xt(context)); |
| 45 } |
| 46 |
| 47 v8::MaybeLocal<v8::Value> ThreadDebugger::compileAndRunInternalScript(v8::Local<
v8::String> script) |
| 48 { |
| 49 return V8ScriptRunner::compileAndRunInternalScript(script, m_isolate); |
| 50 } |
| 51 |
| 52 v8::MaybeLocal<v8::Value> ThreadDebugger::callFunction(v8::Local<v8::Function> f
unction, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc
, v8::Local<v8::Value> info[]) |
| 53 { |
| 54 return V8ScriptRunner::callFunction(function, toExecutionContext(context), r
eceiver, argc, info, m_isolate); |
| 55 } |
| 56 |
| 57 v8::MaybeLocal<v8::Value> ThreadDebugger::callInternalFunction(v8::Local<v8::Fun
ction> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> i
nfo[]) |
| 58 { |
| 59 return V8ScriptRunner::callInternalFunction(function, receiver, argc, info,
m_isolate); |
| 60 } |
| 61 |
35 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) | 62 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) |
36 { | 63 { |
37 if (V8Node::hasInstance(value, m_isolate)) | 64 if (V8Node::hasInstance(value, m_isolate)) |
38 return "node"; | 65 return "node"; |
39 if (V8NodeList::hasInstance(value, m_isolate) | 66 if (V8NodeList::hasInstance(value, m_isolate) |
40 || V8DOMTokenList::hasInstance(value, m_isolate) | 67 || V8DOMTokenList::hasInstance(value, m_isolate) |
41 || V8HTMLCollection::hasInstance(value, m_isolate) | 68 || V8HTMLCollection::hasInstance(value, m_isolate) |
42 || V8HTMLAllCollection::hasInstance(value, m_isolate)) { | 69 || V8HTMLAllCollection::hasInstance(value, m_isolate)) { |
43 return "array"; | 70 return "array"; |
44 } | 71 } |
45 if (V8DOMException::hasInstance(value, m_isolate)) | 72 if (V8DOMException::hasInstance(value, m_isolate)) |
46 return "error"; | 73 return "error"; |
47 return String(); | 74 return String(); |
48 } | 75 } |
49 | 76 |
50 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value) | 77 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value) |
51 { | 78 { |
52 return V8DOMWrapper::isWrapper(m_isolate, value); | 79 return V8DOMWrapper::isWrapper(m_isolate, value); |
53 } | 80 } |
54 | 81 |
55 bool ThreadDebugger::hasRecursionLevel() | 82 bool ThreadDebugger::hasRecursionLevel() |
56 { | 83 { |
57 return !!v8::MicrotasksScope::GetCurrentDepth(m_isolate); | 84 return !!V8RecursionScope::recursionLevel(m_isolate); |
58 } | |
59 | |
60 bool ThreadDebugger::isExecutionAllowed() | |
61 { | |
62 return !ScriptForbiddenScope::isScriptForbidden(); | |
63 } | 85 } |
64 | 86 |
65 double ThreadDebugger::currentTimeMS() | 87 double ThreadDebugger::currentTimeMS() |
66 { | 88 { |
67 return WTF::currentTimeMS(); | 89 return WTF::currentTimeMS(); |
68 } | 90 } |
69 | 91 |
70 | 92 |
71 } // namespace blink | 93 } // namespace blink |
OLD | NEW |