OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 16 matching lines...) Expand all Loading... | |
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 "config.h" | 31 #include "config.h" |
32 | 32 |
33 | 33 |
34 #include "core/inspector/InjectedScript.h" | 34 #include "core/inspector/InjectedScript.h" |
35 | 35 |
36 #include "bindings/v8/ScriptFunctionCall.h" | 36 #include "bindings/v8/ScriptFunctionCall.h" |
37 #include "bindings/v8/V8PerIsolateData.h" | |
37 #include "core/inspector/InjectedScriptHost.h" | 38 #include "core/inspector/InjectedScriptHost.h" |
38 #include "platform/JSONValues.h" | 39 #include "platform/JSONValues.h" |
39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
40 | 41 |
42 #include <v8-debug.h> | |
43 | |
41 using WebCore::TypeBuilder::Array; | 44 using WebCore::TypeBuilder::Array; |
42 using WebCore::TypeBuilder::Debugger::CallFrame; | 45 using WebCore::TypeBuilder::Debugger::CallFrame; |
43 using WebCore::TypeBuilder::Runtime::PropertyDescriptor; | 46 using WebCore::TypeBuilder::Runtime::PropertyDescriptor; |
44 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; | 47 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; |
45 using WebCore::TypeBuilder::Debugger::FunctionDetails; | 48 using WebCore::TypeBuilder::Debugger::FunctionDetails; |
46 using WebCore::TypeBuilder::Runtime::RemoteObject; | 49 using WebCore::TypeBuilder::Runtime::RemoteObject; |
47 | 50 |
48 namespace WebCore { | 51 namespace WebCore { |
49 | 52 |
50 V8InjectedScript::V8InjectedScript() | 53 V8InjectedScript::V8InjectedScript() |
(...skipping 23 matching lines...) Expand all Loading... | |
74 function.appendArgument(objectId); | 77 function.appendArgument(objectId); |
75 function.appendArgument(expression); | 78 function.appendArgument(expression); |
76 function.appendArgument(arguments); | 79 function.appendArgument(arguments); |
77 function.appendArgument(returnByValue); | 80 function.appendArgument(returnByValue); |
78 function.appendArgument(generatePreview); | 81 function.appendArgument(generatePreview); |
79 makeEvalCall(errorString, function, result, wasThrown); | 82 makeEvalCall(errorString, function, result, wasThrown); |
80 } | 83 } |
81 | 84 |
82 void V8InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Stack Trace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String& call FrameId, const String& expression, const String& objectGroup, bool includeComman dLineAPI, bool returnByValue, bool generatePreview, RefPtr<RemoteObject>* result , TypeBuilder::OptOutput<bool>* wasThrown) | 85 void V8InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Stack Trace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String& call FrameId, const String& expression, const String& objectGroup, bool includeComman dLineAPI, bool returnByValue, bool generatePreview, RefPtr<RemoteObject>* result , TypeBuilder::OptOutput<bool>* wasThrown) |
83 { | 86 { |
87 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | |
88 | |
84 ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"); | 89 ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"); |
85 function.appendArgument(callFrames.asJavaScript()); | 90 function.appendArgument(callFrames.asJavaScript()); |
86 Vector<ScriptValue> asyncCallStacksJavaScript; | 91 Vector<ScriptValue> asyncCallStacksJavaScript; |
87 for (size_t i = 0; i < asyncCallStacks.size(); i++) { | 92 for (size_t i = 0; i < asyncCallStacks.size(); i++) { |
88 if (asyncCallStacks[i].isJavaScript()) | 93 if (asyncCallStacks[i].hasJavaScript()) |
89 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); | 94 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); |
90 } | 95 } |
91 function.appendArgument(asyncCallStacksJavaScript); | 96 function.appendArgument(asyncCallStacksJavaScript); |
92 function.appendArgument(callFrameId); | 97 function.appendArgument(callFrameId); |
93 function.appendArgument(expression); | 98 function.appendArgument(expression); |
94 function.appendArgument(objectGroup); | 99 function.appendArgument(objectGroup); |
95 function.appendArgument(includeCommandLineAPI); | 100 function.appendArgument(includeCommandLineAPI); |
96 function.appendArgument(returnByValue); | 101 function.appendArgument(returnByValue); |
97 function.appendArgument(generatePreview); | 102 function.appendArgument(generatePreview); |
98 makeEvalCall(errorString, function, result, wasThrown); | 103 makeEvalCall(errorString, function, result, wasThrown); |
99 } | 104 } |
100 | 105 |
101 void V8InjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, const StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String & callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* re sult) | 106 void V8InjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, const StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String & callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* re sult) |
102 { | 107 { |
103 ScriptFunctionCall function(injectedScriptObject(), "getCompletionsOnCallFra me"); | 108 ScriptFunctionCall function(injectedScriptObject(), "getCompletionsOnCallFra me"); |
104 function.appendArgument(callFrames.asJavaScript()); | 109 function.appendArgument(callFrames.asJavaScript()); |
105 Vector<ScriptValue> asyncCallStacksJavaScript; | 110 Vector<ScriptValue> asyncCallStacksJavaScript; |
106 for (size_t i = 0; i < asyncCallStacks.size(); i++) { | 111 for (size_t i = 0; i < asyncCallStacks.size(); i++) { |
107 if (asyncCallStacks[i].isJavaScript()) | 112 if (asyncCallStacks[i].hasJavaScript()) |
108 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); | 113 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); |
109 } | 114 } |
110 function.appendArgument(asyncCallStacksJavaScript); | 115 function.appendArgument(asyncCallStacksJavaScript); |
111 function.appendArgument(callFrameId); | 116 function.appendArgument(callFrameId); |
112 function.appendArgument(expression); | 117 function.appendArgument(expression); |
113 RefPtr<JSONValue> resultValue; | 118 RefPtr<JSONValue> resultValue; |
114 makeCall(function, &resultValue); | 119 makeCall(function, &resultValue); |
115 if (!resultValue || resultValue->type() != JSONValue::TypeArray) { | 120 if (!resultValue || resultValue->type() != JSONValue::TypeArray) { |
116 *errorString = "Internal error"; | 121 *errorString = "Internal error"; |
117 return; | 122 return; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 PassRefPtr<Array<CallFrame> > V8InjectedScript::wrapCallFrames(const StackTrace& callFrames, int asyncOrdinal) | 288 PassRefPtr<Array<CallFrame> > V8InjectedScript::wrapCallFrames(const StackTrace& callFrames, int asyncOrdinal) |
284 { | 289 { |
285 ASSERT(!isEmpty()); | 290 ASSERT(!isEmpty()); |
286 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); | 291 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); |
287 function.appendArgument(callFrames.asJavaScript()); | 292 function.appendArgument(callFrames.asJavaScript()); |
288 function.appendArgument(asyncOrdinal); | 293 function.appendArgument(asyncOrdinal); |
289 bool hadException = false; | 294 bool hadException = false; |
290 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion); | 295 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion); |
291 ASSERT(!hadException); | 296 ASSERT(!hadException); |
292 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); | 297 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); |
293 if (result && result->type() == JSONValue::TypeArray) | 298 if (result && result->type() == JSONValue::TypeArray) { |
299 // FIXMEDART: set timestamps for async callstacks as well. | |
300 if (asyncOrdinal < 1) { | |
301 // Bread the CallFrame JSON with timestamps. | |
vsm
2014/08/29 08:42:08
Bread?
Jacob
2014/09/05 23:35:56
This code has been removed.
| |
302 StackTraceTimestampTracker* tracker = V8PerIsolateData::from(v8::Iso late::GetCurrent())->stackTraceTimestampTracker(); | |
303 RefPtr<JSONArray> arr; | |
304 result->asArray(&arr); | |
305 for (size_t i = 0, length = arr->length(); i < length; i++) | |
306 CallFrame::runtimeCast(arr->get(i))->setTimestamp(tracker->getTi mestamp(length - i - 1)); | |
307 } | |
294 return Array<CallFrame>::runtimeCast(result); | 308 return Array<CallFrame>::runtimeCast(result); |
309 } | |
295 return Array<CallFrame>::create(); | 310 return Array<CallFrame>::create(); |
296 } | 311 } |
297 | 312 |
298 PassRefPtr<TypeBuilder::Runtime::RemoteObject> V8InjectedScript::wrapObject(cons t ScriptValue& value, const String& groupName, bool generatePreview) | 313 PassRefPtr<TypeBuilder::Runtime::RemoteObject> V8InjectedScript::wrapObject(cons t ScriptValue& value, const String& groupName, bool generatePreview) |
299 { | 314 { |
300 ASSERT(!isEmpty()); | 315 ASSERT(!isEmpty()); |
301 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); | 316 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); |
302 wrapFunction.appendArgument(value); | 317 wrapFunction.appendArgument(value); |
303 wrapFunction.appendArgument(groupName); | 318 wrapFunction.appendArgument(groupName); |
304 wrapFunction.appendArgument(canAccessInspectedWindow()); | 319 wrapFunction.appendArgument(canAccessInspectedWindow()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 ASSERT(!hadException); | 380 ASSERT(!hadException); |
366 } | 381 } |
367 | 382 |
368 ScriptValue V8InjectedScript::nodeAsScriptValue(Node* node) | 383 ScriptValue V8InjectedScript::nodeAsScriptValue(Node* node) |
369 { | 384 { |
370 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); | 385 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); |
371 } | 386 } |
372 | 387 |
373 } // namespace WebCore | 388 } // namespace WebCore |
374 | 389 |
OLD | NEW |