OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 function->Call(context, receiver, argc, info); | 106 function->Call(context, receiver, argc, info); |
107 // Get agent from the map again, since it could have detached during script | 107 // Get agent from the map again, since it could have detached during script |
108 // execution. | 108 // execution. |
109 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | 109 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) |
110 agent->didExecuteScript(); | 110 agent->didExecuteScript(); |
111 return result; | 111 return result; |
112 } | 112 } |
113 | 113 |
114 v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript( | 114 v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript( |
115 v8::Local<v8::Context> context, v8::Local<v8::String> source) { | 115 v8::Local<v8::Context> context, v8::Local<v8::String> source) { |
116 v8::Local<v8::Script> script = | 116 v8::Local<v8::UnboundScript> unboundScript; |
117 compileScript(context, source, String16(), true); | 117 if (!v8::DebugInterface::CompileInspectorScript(m_isolate, source) |
118 if (script.IsEmpty()) return v8::MaybeLocal<v8::Value>(); | 118 .ToLocal(&unboundScript)) |
119 return v8::MaybeLocal<v8::Value>(); | |
119 v8::MicrotasksScope microtasksScope(m_isolate, | 120 v8::MicrotasksScope microtasksScope(m_isolate, |
120 v8::MicrotasksScope::kDoNotRunMicrotasks); | 121 v8::MicrotasksScope::kDoNotRunMicrotasks); |
121 return script->Run(context); | 122 return unboundScript->BindToCurrentContext()->Run(context); |
dgozman
2016/11/15 23:19:57
I think we have to enter context before bindings t
kozy
2016/11/16 00:10:50
I assume that we pass entered context into this fu
| |
122 } | 123 } |
123 | 124 |
124 v8::Local<v8::Script> V8InspectorImpl::compileScript( | 125 v8::MaybeLocal<v8::Script> V8InspectorImpl::compileScript( |
125 v8::Local<v8::Context> context, v8::Local<v8::String> code, | 126 v8::Local<v8::Context> context, const String16& code, |
126 const String16& fileName, bool markAsInternal) { | 127 const String16& fileName) { |
127 v8::ScriptOrigin origin( | 128 v8::ScriptOrigin origin( |
128 toV8String(m_isolate, fileName), v8::Integer::New(m_isolate, 0), | 129 toV8String(m_isolate, fileName), v8::Integer::New(m_isolate, 0), |
129 v8::Integer::New(m_isolate, 0), | 130 v8::Integer::New(m_isolate, 0), |
130 v8::False(m_isolate), // sharable | 131 v8::False(m_isolate), // sharable |
131 v8::Local<v8::Integer>(), | 132 v8::Local<v8::Integer>(), v8::Boolean::New(m_isolate, false), // internal |
132 v8::Boolean::New(m_isolate, markAsInternal), // internal | 133 toV8String(m_isolate, String16()), // sourceMap |
133 toV8String(m_isolate, String16()), // sourceMap | 134 v8::True(m_isolate)); // opaqueresource |
134 v8::True(m_isolate)); // opaqueresource | 135 v8::ScriptCompiler::Source source(toV8String(m_isolate, code), origin); |
135 v8::ScriptCompiler::Source source(code, origin); | 136 return v8::ScriptCompiler::Compile(context, &source, |
136 v8::Local<v8::Script> script; | 137 v8::ScriptCompiler::kNoCompileOptions); |
137 if (!v8::ScriptCompiler::Compile(context, &source, | |
138 v8::ScriptCompiler::kNoCompileOptions) | |
139 .ToLocal(&script)) | |
140 return v8::Local<v8::Script>(); | |
141 return script; | |
142 } | 138 } |
143 | 139 |
144 void V8InspectorImpl::enableStackCapturingIfNeeded() { | 140 void V8InspectorImpl::enableStackCapturingIfNeeded() { |
145 if (!m_capturingStackTracesCount) | 141 if (!m_capturingStackTracesCount) |
146 V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, | 142 V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, |
147 true); | 143 true); |
148 ++m_capturingStackTracesCount; | 144 ++m_capturingStackTracesCount; |
149 } | 145 } |
150 | 146 |
151 void V8InspectorImpl::disableStackCapturingIfNeeded() { | 147 void V8InspectorImpl::disableStackCapturingIfNeeded() { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 } | 363 } |
368 | 364 |
369 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( | 365 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( |
370 int contextGroupId) { | 366 int contextGroupId) { |
371 if (!contextGroupId) return nullptr; | 367 if (!contextGroupId) return nullptr; |
372 SessionMap::iterator iter = m_sessions.find(contextGroupId); | 368 SessionMap::iterator iter = m_sessions.find(contextGroupId); |
373 return iter == m_sessions.end() ? nullptr : iter->second; | 369 return iter == m_sessions.end() ? nullptr : iter->second; |
374 } | 370 } |
375 | 371 |
376 } // namespace v8_inspector | 372 } // namespace v8_inspector |
OLD | NEW |