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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 "platform/v8_inspector/InjectedScript.h" | 31 #include "platform/v8_inspector/InjectedScript.h" |
32 | 32 |
33 #include "platform/inspector_protocol/Parser.h" | 33 #include "platform/inspector_protocol/Parser.h" |
| 34 #include "platform/inspector_protocol/String16.h" |
34 #include "platform/inspector_protocol/Values.h" | 35 #include "platform/inspector_protocol/Values.h" |
35 #include "platform/v8_inspector/InjectedScriptHost.h" | 36 #include "platform/v8_inspector/InjectedScriptHost.h" |
36 #include "platform/v8_inspector/InjectedScriptManager.h" | 37 #include "platform/v8_inspector/InjectedScriptManager.h" |
37 #include "platform/v8_inspector/RemoteObjectId.h" | 38 #include "platform/v8_inspector/RemoteObjectId.h" |
38 #include "platform/v8_inspector/V8FunctionCall.h" | 39 #include "platform/v8_inspector/V8FunctionCall.h" |
39 #include "platform/v8_inspector/V8StringUtil.h" | 40 #include "platform/v8_inspector/V8StringUtil.h" |
40 #include "platform/v8_inspector/public/V8Debugger.h" | 41 #include "platform/v8_inspector/public/V8Debugger.h" |
41 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
42 #include "platform/v8_inspector/public/V8ToProtocolValue.h" | 43 #include "platform/v8_inspector/public/V8ToProtocolValue.h" |
43 #include "wtf/text/WTFString.h" | |
44 | 44 |
45 using blink::protocol::Array; | 45 using blink::protocol::Array; |
46 using blink::protocol::Debugger::CallFrame; | 46 using blink::protocol::Debugger::CallFrame; |
47 using blink::protocol::Debugger::CollectionEntry; | 47 using blink::protocol::Debugger::CollectionEntry; |
48 using blink::protocol::Debugger::FunctionDetails; | 48 using blink::protocol::Debugger::FunctionDetails; |
49 using blink::protocol::Debugger::GeneratorObjectDetails; | 49 using blink::protocol::Debugger::GeneratorObjectDetails; |
50 using blink::protocol::Runtime::PropertyDescriptor; | 50 using blink::protocol::Runtime::PropertyDescriptor; |
51 using blink::protocol::Runtime::InternalPropertyDescriptor; | 51 using blink::protocol::Runtime::InternalPropertyDescriptor; |
52 using blink::protocol::Runtime::RemoteObject; | 52 using blink::protocol::Runtime::RemoteObject; |
53 using blink::protocol::Maybe; | 53 using blink::protocol::Maybe; |
54 | 54 |
55 namespace blink { | 55 namespace blink { |
56 | 56 |
57 static PassOwnPtr<protocol::Runtime::ExceptionDetails> toExceptionDetails(protoc
ol::DictionaryValue* object) | 57 static PassOwnPtr<protocol::Runtime::ExceptionDetails> toExceptionDetails(protoc
ol::DictionaryValue* object) |
58 { | 58 { |
59 String text; | 59 String16 text; |
60 if (!object->getString("text", &text)) | 60 if (!object->getString("text", &text)) |
61 return nullptr; | 61 return nullptr; |
62 | 62 |
63 OwnPtr<protocol::Runtime::ExceptionDetails> exceptionDetails = protocol::Run
time::ExceptionDetails::create().setText(text).build(); | 63 OwnPtr<protocol::Runtime::ExceptionDetails> exceptionDetails = protocol::Run
time::ExceptionDetails::create().setText(text).build(); |
64 String url; | 64 String16 url; |
65 if (object->getString("url", &url)) | 65 if (object->getString("url", &url)) |
66 exceptionDetails->setUrl(url); | 66 exceptionDetails->setUrl(url); |
67 int line = 0; | 67 int line = 0; |
68 if (object->getNumber("line", &line)) | 68 if (object->getNumber("line", &line)) |
69 exceptionDetails->setLine(line); | 69 exceptionDetails->setLine(line); |
70 int column = 0; | 70 int column = 0; |
71 if (object->getNumber("column", &column)) | 71 if (object->getNumber("column", &column)) |
72 exceptionDetails->setColumn(column); | 72 exceptionDetails->setColumn(column); |
73 int originScriptId = 0; | 73 int originScriptId = 0; |
74 object->getNumber("scriptId", &originScriptId); | 74 object->getNumber("scriptId", &originScriptId); |
75 | 75 |
76 protocol::ListValue* stackTrace = object->getArray("stackTrace"); | 76 protocol::ListValue* stackTrace = object->getArray("stackTrace"); |
77 if (stackTrace && stackTrace->size() > 0) { | 77 if (stackTrace && stackTrace->size() > 0) { |
78 OwnPtr<protocol::Array<protocol::Runtime::CallFrame>> frames = protocol:
:Array<protocol::Runtime::CallFrame>::create(); | 78 OwnPtr<protocol::Array<protocol::Runtime::CallFrame>> frames = protocol:
:Array<protocol::Runtime::CallFrame>::create(); |
79 for (unsigned i = 0; i < stackTrace->size(); ++i) { | 79 for (unsigned i = 0; i < stackTrace->size(); ++i) { |
80 protocol::DictionaryValue* stackFrame = protocol::DictionaryValue::c
ast(stackTrace->at(i)); | 80 protocol::DictionaryValue* stackFrame = protocol::DictionaryValue::c
ast(stackTrace->at(i)); |
81 int lineNumber = 0; | 81 int lineNumber = 0; |
82 stackFrame->getNumber("lineNumber", &lineNumber); | 82 stackFrame->getNumber("lineNumber", &lineNumber); |
83 int column = 0; | 83 int column = 0; |
84 stackFrame->getNumber("column", &column); | 84 stackFrame->getNumber("column", &column); |
85 int scriptId = 0; | 85 int scriptId = 0; |
86 stackFrame->getNumber("scriptId", &scriptId); | 86 stackFrame->getNumber("scriptId", &scriptId); |
87 if (i == 0 && scriptId == originScriptId) | 87 if (i == 0 && scriptId == originScriptId) |
88 originScriptId = 0; | 88 originScriptId = 0; |
89 | 89 |
90 String sourceURL; | 90 String16 sourceURL; |
91 stackFrame->getString("scriptNameOrSourceURL", &sourceURL); | 91 stackFrame->getString("scriptNameOrSourceURL", &sourceURL); |
92 String functionName; | 92 String16 functionName; |
93 stackFrame->getString("functionName", &functionName); | 93 stackFrame->getString("functionName", &functionName); |
94 | 94 |
95 OwnPtr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime::
CallFrame::create() | 95 OwnPtr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime::
CallFrame::create() |
96 .setFunctionName(functionName) | 96 .setFunctionName(functionName) |
97 .setScriptId(String::number(scriptId)) | 97 .setScriptId(String16::number(scriptId)) |
98 .setUrl(sourceURL) | 98 .setUrl(sourceURL) |
99 .setLineNumber(lineNumber) | 99 .setLineNumber(lineNumber) |
100 .setColumnNumber(column).build(); | 100 .setColumnNumber(column).build(); |
101 | 101 |
102 frames->addItem(callFrame.release()); | 102 frames->addItem(callFrame.release()); |
103 } | 103 } |
104 OwnPtr<protocol::Runtime::StackTrace> stack = protocol::Runtime::StackTr
ace::create() | 104 OwnPtr<protocol::Runtime::StackTrace> stack = protocol::Runtime::StackTr
ace::create() |
105 .setCallFrames(frames.release()).build(); | 105 .setCallFrames(frames.release()).build(); |
106 exceptionDetails->setStack(stack.release()); | 106 exceptionDetails->setStack(stack.release()); |
107 } | 107 } |
108 if (originScriptId) | 108 if (originScriptId) |
109 exceptionDetails->setScriptId(String::number(originScriptId)); | 109 exceptionDetails->setScriptId(String16::number(originScriptId)); |
110 return exceptionDetails.release(); | 110 return exceptionDetails.release(); |
111 } | 111 } |
112 | 112 |
113 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) | 113 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) |
114 { | 114 { |
115 data.GetParameter()->dispose(); | 115 data.GetParameter()->dispose(); |
116 } | 116 } |
117 | 117 |
118 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con
text> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPt
r<InjectedScriptNative> injectedScriptNative, int contextId) | 118 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con
text> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPt
r<InjectedScriptNative> injectedScriptNative, int contextId) |
119 : m_manager(manager) | 119 : m_manager(manager) |
120 , m_isolate(context->GetIsolate()) | 120 , m_isolate(context->GetIsolate()) |
121 , m_context(m_isolate, context) | 121 , m_context(m_isolate, context) |
122 , m_value(m_isolate, object) | 122 , m_value(m_isolate, object) |
123 , m_client(client) | 123 , m_client(client) |
124 , m_native(injectedScriptNative) | 124 , m_native(injectedScriptNative) |
125 , m_contextId(contextId) | 125 , m_contextId(contextId) |
126 { | 126 { |
127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); | 127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); |
128 } | 128 } |
129 | 129 |
130 InjectedScript::~InjectedScript() | 130 InjectedScript::~InjectedScript() |
131 { | 131 { |
132 } | 132 } |
133 | 133 |
134 void InjectedScript::evaluate(ErrorString* errorString, const String& expression
, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, boo
l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>*
wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 134 void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi
on, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue,
bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bo
ol>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
135 { | 135 { |
136 v8::HandleScope handles(m_isolate); | 136 v8::HandleScope handles(m_isolate); |
137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); | 137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); |
138 function.appendArgument(expression); | 138 function.appendArgument(expression); |
139 function.appendArgument(objectGroup); | 139 function.appendArgument(objectGroup); |
140 function.appendArgument(includeCommandLineAPI); | 140 function.appendArgument(includeCommandLineAPI); |
141 function.appendArgument(returnByValue); | 141 function.appendArgument(returnByValue); |
142 function.appendArgument(generatePreview); | 142 function.appendArgument(generatePreview); |
143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
144 } | 144 } |
145 | 145 |
146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje
ctId, const String& expression, const String& arguments, bool returnByValue, boo
l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>*
wasThrown) | 146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob
jectId, const String16& expression, const String16& arguments, bool returnByValu
e, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<
bool>* wasThrown) |
147 { | 147 { |
148 v8::HandleScope handles(m_isolate); | 148 v8::HandleScope handles(m_isolate); |
149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); | 149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); |
150 function.appendArgument(objectId); | 150 function.appendArgument(objectId); |
151 function.appendArgument(expression); | 151 function.appendArgument(expression); |
152 function.appendArgument(arguments); | 152 function.appendArgument(arguments); |
153 function.appendArgument(returnByValue); | 153 function.appendArgument(returnByValue); |
154 function.appendArgument(generatePreview); | 154 function.appendArgument(generatePreview); |
155 *result = makeEvalCall(errorString, function, wasThrown); | 155 *result = makeEvalCall(errorString, function, wasThrown); |
156 } | 156 } |
157 | 157 |
158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8:
:Object> callFrames, const String& callFrameId, const String& expression, const
String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool genera
tePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol:
:Runtime::ExceptionDetails>* exceptionDetails) | 158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8:
:Object> callFrames, const String16& callFrameId, const String16& expression, co
nst String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool
generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<pro
tocol::Runtime::ExceptionDetails>* exceptionDetails) |
159 { | 159 { |
160 v8::HandleScope handles(m_isolate); | 160 v8::HandleScope handles(m_isolate); |
161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame
"); | 161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame
"); |
162 function.appendArgument(callFrames); | 162 function.appendArgument(callFrames); |
163 function.appendArgument(callFrameId); | 163 function.appendArgument(callFrameId); |
164 function.appendArgument(expression); | 164 function.appendArgument(expression); |
165 function.appendArgument(objectGroup); | 165 function.appendArgument(objectGroup); |
166 function.appendArgument(includeCommandLineAPI); | 166 function.appendArgument(includeCommandLineAPI); |
167 function.appendArgument(returnByValue); | 167 function.appendArgument(returnByValue); |
168 function.appendArgument(generatePreview); | 168 function.appendArgument(generatePreview); |
169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
170 } | 170 } |
171 | 171 |
172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object
> callFrames, const String& callFrameId) | 172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object
> callFrames, const String16& callFrameId) |
173 { | 173 { |
174 v8::HandleScope handles(m_isolate); | 174 v8::HandleScope handles(m_isolate); |
175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); | 175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); |
176 function.appendArgument(callFrames); | 176 function.appendArgument(callFrames); |
177 function.appendArgument(callFrameId); | 177 function.appendArgument(callFrameId); |
178 OwnPtr<protocol::Value> resultValue = makeCall(function); | 178 OwnPtr<protocol::Value> resultValue = makeCall(function); |
179 if (resultValue) { | 179 if (resultValue) { |
180 if (resultValue->type() == protocol::Value::TypeString) { | 180 if (resultValue->type() == protocol::Value::TypeString) { |
181 resultValue->asString(errorString); | 181 resultValue->asString(errorString); |
182 } else { | 182 } else { |
183 bool value; | 183 bool value; |
184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); | 184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); |
185 } | 185 } |
186 return; | 186 return; |
187 } | 187 } |
188 *errorString = "Internal error"; | 188 *errorString = "Internal error"; |
189 } | 189 } |
190 | 190 |
191 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::
Object> callFrames, const String& callFrameId, Maybe<Array<protocol::Debugger::L
ocation>>* positions) | 191 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::
Object> callFrames, const String16& callFrameId, Maybe<Array<protocol::Debugger:
:Location>>* positions) |
192 { | 192 { |
193 v8::HandleScope handles(m_isolate); | 193 v8::HandleScope handles(m_isolate); |
194 V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"
); | 194 V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"
); |
195 function.appendArgument(callFrames); | 195 function.appendArgument(callFrames); |
196 function.appendArgument(callFrameId); | 196 function.appendArgument(callFrameId); |
197 OwnPtr<protocol::Value> resultValue = makeCall(function); | 197 OwnPtr<protocol::Value> resultValue = makeCall(function); |
198 if (resultValue) { | 198 if (resultValue) { |
199 if (resultValue->type() == protocol::Value::TypeString) { | 199 if (resultValue->type() == protocol::Value::TypeString) { |
200 resultValue->asString(errorString); | 200 resultValue->asString(errorString); |
201 return; | 201 return; |
202 } | 202 } |
203 if (resultValue->type() == protocol::Value::TypeArray) { | 203 if (resultValue->type() == protocol::Value::TypeArray) { |
204 protocol::ErrorSupport errors(errorString); | 204 protocol::ErrorSupport errors(errorString); |
205 *positions = Array<protocol::Debugger::Location>::parse(resultValue.
get(), &errors); | 205 *positions = Array<protocol::Debugger::Location>::parse(resultValue.
get(), &errors); |
206 return; | 206 return; |
207 } | 207 } |
208 } | 208 } |
209 *errorString = "Internal error"; | 209 *errorString = "Internal error"; |
210 } | 210 } |
211 | 211 |
212 void InjectedScript::setVariableValue(ErrorString* errorString, | 212 void InjectedScript::setVariableValue(ErrorString* errorString, |
213 v8::Local<v8::Object> callFrames, | 213 v8::Local<v8::Object> callFrames, |
214 const protocol::Maybe<String>& callFrameIdOpt, | 214 const protocol::Maybe<String16>& callFrameIdOpt, |
215 const protocol::Maybe<String>& functionObjectIdOpt, | 215 const protocol::Maybe<String16>& functionObjectIdOpt, |
216 int scopeNumber, | 216 int scopeNumber, |
217 const String& variableName, | 217 const String16& variableName, |
218 const String& newValueStr) | 218 const String16& newValueStr) |
219 { | 219 { |
220 v8::HandleScope handles(m_isolate); | 220 v8::HandleScope handles(m_isolate); |
221 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); | 221 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); |
222 if (callFrameIdOpt.isJust()) { | 222 if (callFrameIdOpt.isJust()) { |
223 function.appendArgument(callFrames); | 223 function.appendArgument(callFrames); |
224 function.appendArgument(callFrameIdOpt.fromJust()); | 224 function.appendArgument(callFrameIdOpt.fromJust()); |
225 } else { | 225 } else { |
226 function.appendArgument(false); | 226 function.appendArgument(false); |
227 function.appendArgument(false); | 227 function.appendArgument(false); |
228 } | 228 } |
229 if (functionObjectIdOpt.isJust()) | 229 if (functionObjectIdOpt.isJust()) |
230 function.appendArgument(functionObjectIdOpt.fromJust()); | 230 function.appendArgument(functionObjectIdOpt.fromJust()); |
231 else | 231 else |
232 function.appendArgument(false); | 232 function.appendArgument(false); |
233 function.appendArgument(scopeNumber); | 233 function.appendArgument(scopeNumber); |
234 function.appendArgument(variableName); | 234 function.appendArgument(variableName); |
235 function.appendArgument(newValueStr); | 235 function.appendArgument(newValueStr); |
236 OwnPtr<protocol::Value> resultValue = makeCall(function); | 236 OwnPtr<protocol::Value> resultValue = makeCall(function); |
237 if (!resultValue) { | 237 if (!resultValue) { |
238 *errorString = "Internal error"; | 238 *errorString = "Internal error"; |
239 return; | 239 return; |
240 } | 240 } |
241 if (resultValue->type() == protocol::Value::TypeString) { | 241 if (resultValue->type() == protocol::Value::TypeString) { |
242 resultValue->asString(errorString); | 242 resultValue->asString(errorString); |
243 return; | 243 return; |
244 } | 244 } |
245 // Normal return. | 245 // Normal return. |
246 } | 246 } |
247 | 247 |
248 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String&
functionId, OwnPtr<FunctionDetails>* result) | 248 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16
& functionId, OwnPtr<FunctionDetails>* result) |
249 { | 249 { |
250 v8::HandleScope handles(m_isolate); | 250 v8::HandleScope handles(m_isolate); |
251 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); | 251 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); |
252 function.appendArgument(functionId); | 252 function.appendArgument(functionId); |
253 OwnPtr<protocol::Value> resultValue = makeCall(function); | 253 OwnPtr<protocol::Value> resultValue = makeCall(function); |
254 protocol::ErrorSupport errors(errorString); | 254 protocol::ErrorSupport errors(errorString); |
255 *result = FunctionDetails::parse(resultValue.get(), &errors); | 255 *result = FunctionDetails::parse(resultValue.get(), &errors); |
256 } | 256 } |
257 | 257 |
258 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S
tring& objectId, OwnPtr<GeneratorObjectDetails>* result) | 258 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S
tring16& objectId, OwnPtr<GeneratorObjectDetails>* result) |
259 { | 259 { |
260 v8::HandleScope handles(m_isolate); | 260 v8::HandleScope handles(m_isolate); |
261 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD
etails"); | 261 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD
etails"); |
262 function.appendArgument(objectId); | 262 function.appendArgument(objectId); |
263 OwnPtr<protocol::Value> resultValue = makeCall(function); | 263 OwnPtr<protocol::Value> resultValue = makeCall(function); |
264 protocol::ErrorSupport errors(errorString); | 264 protocol::ErrorSupport errors(errorString); |
265 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); | 265 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); |
266 } | 266 } |
267 | 267 |
268 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String
& objectId, OwnPtr<Array<CollectionEntry>>* result) | 268 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String
16& objectId, OwnPtr<Array<CollectionEntry>>* result) |
269 { | 269 { |
270 v8::HandleScope handles(m_isolate); | 270 v8::HandleScope handles(m_isolate); |
271 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie
s"); | 271 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie
s"); |
272 function.appendArgument(objectId); | 272 function.appendArgument(objectId); |
273 OwnPtr<protocol::Value> resultValue = makeCall(function); | 273 OwnPtr<protocol::Value> resultValue = makeCall(function); |
274 protocol::ErrorSupport errors(errorString); | 274 protocol::ErrorSupport errors(errorString); |
275 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); | 275 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); |
276 } | 276 } |
277 | 277 |
278 void InjectedScript::getProperties(ErrorString* errorString, const String& objec
tId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnP
tr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDet
ails>* exceptionDetails) | 278 void InjectedScript::getProperties(ErrorString* errorString, const String16& obj
ectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow
nPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionD
etails>* exceptionDetails) |
279 { | 279 { |
280 v8::HandleScope handles(m_isolate); | 280 v8::HandleScope handles(m_isolate); |
281 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); | 281 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); |
282 function.appendArgument(objectId); | 282 function.appendArgument(objectId); |
283 function.appendArgument(ownProperties); | 283 function.appendArgument(ownProperties); |
284 function.appendArgument(accessorPropertiesOnly); | 284 function.appendArgument(accessorPropertiesOnly); |
285 function.appendArgument(generatePreview); | 285 function.appendArgument(generatePreview); |
286 | 286 |
287 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 287 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
288 if (exceptionDetails->isJust()) { | 288 if (exceptionDetails->isJust()) { |
289 // FIXME: make properties optional | 289 // FIXME: make properties optional |
290 *properties = Array<PropertyDescriptor>::create(); | 290 *properties = Array<PropertyDescriptor>::create(); |
291 return; | 291 return; |
292 } | 292 } |
293 protocol::ErrorSupport errors(errorString); | 293 protocol::ErrorSupport errors(errorString); |
294 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); | 294 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); |
295 } | 295 } |
296 | 296 |
297 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protoco
l::Runtime::ExceptionDetails>* exceptionDetails) | 297 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) |
298 { | 298 { |
299 v8::HandleScope handles(m_isolate); | 299 v8::HandleScope handles(m_isolate); |
300 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti
es"); | 300 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti
es"); |
301 function.appendArgument(objectId); | 301 function.appendArgument(objectId); |
302 | 302 |
303 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 303 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
304 if (exceptionDetails->isJust()) | 304 if (exceptionDetails->isJust()) |
305 return; | 305 return; |
306 protocol::ErrorSupport errors(errorString); | 306 protocol::ErrorSupport errors(errorString); |
307 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc
riptor>::parse(result.get(), &errors); | 307 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc
riptor>::parse(result.get(), &errors); |
308 if (!errors.hasErrors() && array->length() > 0) | 308 if (!errors.hasErrors() && array->length() > 0) |
309 *properties = array.release(); | 309 *properties = array.release(); |
310 } | 310 } |
311 | 311 |
312 void InjectedScript::releaseObject(const String& objectId) | 312 void InjectedScript::releaseObject(const String16& objectId) |
313 { | 313 { |
314 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); | 314 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); |
315 if (!parsedObjectId) | 315 if (!parsedObjectId) |
316 return; | 316 return; |
317 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); | 317 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); |
318 if (!object) | 318 if (!object) |
319 return; | 319 return; |
320 int boundId = 0; | 320 int boundId = 0; |
321 if (!object->getNumber("id", &boundId)) | 321 if (!object->getNumber("id", &boundId)) |
322 return; | 322 return; |
(...skipping 27 matching lines...) Expand all Loading... |
350 bool hadException = false; | 350 bool hadException = false; |
351 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); | 351 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); |
352 ASSERT(!hadException); | 352 ASSERT(!hadException); |
353 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue)
; | 353 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue)
; |
354 protocol::ErrorSupport errors; | 354 protocol::ErrorSupport errors; |
355 if (result && result->type() == protocol::Value::TypeArray) | 355 if (result && result->type() == protocol::Value::TypeArray) |
356 return Array<CallFrame>::parse(result.get(), &errors); | 356 return Array<CallFrame>::parse(result.get(), &errors); |
357 return Array<CallFrame>::create(); | 357 return Array<CallFrame>::create(); |
358 } | 358 } |
359 | 359 |
360 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local
<v8::Value> value, const String& groupName, bool generatePreview) const | 360 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local
<v8::Value> value, const String16& groupName, bool generatePreview) const |
361 { | 361 { |
362 v8::HandleScope handles(m_isolate); | 362 v8::HandleScope handles(m_isolate); |
363 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); | 363 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); |
364 function.appendArgument(value); | 364 function.appendArgument(value); |
365 function.appendArgument(groupName); | 365 function.appendArgument(groupName); |
366 function.appendArgument(canAccessInspectedWindow()); | 366 function.appendArgument(canAccessInspectedWindow()); |
367 function.appendArgument(generatePreview); | 367 function.appendArgument(generatePreview); |
368 bool hadException = false; | 368 bool hadException = false; |
369 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; | 369 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; |
370 if (hadException) | 370 if (hadException) |
(...skipping 18 matching lines...) Expand all Loading... |
389 return nullptr; | 389 return nullptr; |
390 protocol::ErrorSupport errors; | 390 protocol::ErrorSupport errors; |
391 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); | 391 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); |
392 } | 392 } |
393 | 393 |
394 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const | 394 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const |
395 { | 395 { |
396 return m_native->objectForId(objectId.id()); | 396 return m_native->objectForId(objectId.id()); |
397 } | 397 } |
398 | 398 |
399 String InjectedScript::objectGroupName(const RemoteObjectId& objectId) const | 399 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const |
400 { | 400 { |
401 return m_native->groupName(objectId.id()); | 401 return m_native->groupName(objectId.id()); |
402 } | 402 } |
403 | 403 |
404 void InjectedScript::releaseObjectGroup(const String& objectGroup) | 404 void InjectedScript::releaseObjectGroup(const String16& objectGroup) |
405 { | 405 { |
406 v8::HandleScope handles(m_isolate); | 406 v8::HandleScope handles(m_isolate); |
407 m_native->releaseObjectGroup(objectGroup); | 407 m_native->releaseObjectGroup(objectGroup); |
408 if (objectGroup == "console") { | 408 if (objectGroup == "console") { |
409 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua
tionResult"); | 409 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua
tionResult"); |
410 bool hadException = false; | 410 bool hadException = false; |
411 callFunctionWithEvalEnabled(function, hadException); | 411 callFunctionWithEvalEnabled(function, hadException); |
412 ASSERT(!hadException); | 412 ASSERT(!hadException); |
413 } | 413 } |
414 } | 414 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 return nullptr; | 461 return nullptr; |
462 } | 462 } |
463 | 463 |
464 bool hadException = false; | 464 bool hadException = false; |
465 v8::Local<v8::Value> resultValue = callFunctionWithEvalEnabled(function, had
Exception); | 465 v8::Local<v8::Value> resultValue = callFunctionWithEvalEnabled(function, had
Exception); |
466 | 466 |
467 ASSERT(!hadException); | 467 ASSERT(!hadException); |
468 if (!hadException) { | 468 if (!hadException) { |
469 result = toProtocolValue(function.context(), resultValue); | 469 result = toProtocolValue(function.context(), resultValue); |
470 if (!result) | 470 if (!result) |
471 result = protocol::StringValue::create(String::format("Object has to
o long reference chain(must not be longer than %d)", protocol::Value::maxDepth))
; | 471 result = protocol::StringValue::create("Object has too long referenc
e chain(must not be longer than " + String16::number(protocol::Value::maxDepth)
+ ")"); |
472 } else { | 472 } else { |
473 result = protocol::StringValue::create("Exception while making a call.")
; | 473 result = protocol::StringValue::create("Exception while making a call.")
; |
474 } | 474 } |
475 return result.release(); | 475 return result.release(); |
476 } | 476 } |
477 | 477 |
478 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::makeEvalCall(ErrorSt
ring* errorString, V8FunctionCall& function, Maybe<bool>* wasThrown, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) | 478 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::makeEvalCall(ErrorSt
ring* errorString, V8FunctionCall& function, Maybe<bool>* wasThrown, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) |
479 { | 479 { |
480 OwnPtr<protocol::Value> result = makeCall(function); | 480 OwnPtr<protocol::Value> result = makeCall(function); |
481 if (!result) { | 481 if (!result) { |
(...skipping 28 matching lines...) Expand all Loading... |
510 | 510 |
511 PassOwnPtr<protocol::Value> InjectedScript::makeCallWithExceptionDetails(V8Funct
ionCall& function, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 511 PassOwnPtr<protocol::Value> InjectedScript::makeCallWithExceptionDetails(V8Funct
ionCall& function, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
512 { | 512 { |
513 OwnPtr<protocol::Value> result; | 513 OwnPtr<protocol::Value> result; |
514 v8::HandleScope handles(m_isolate); | 514 v8::HandleScope handles(m_isolate); |
515 v8::Context::Scope scope(context()); | 515 v8::Context::Scope scope(context()); |
516 v8::TryCatch tryCatch(m_isolate); | 516 v8::TryCatch tryCatch(m_isolate); |
517 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); | 517 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); |
518 if (tryCatch.HasCaught()) { | 518 if (tryCatch.HasCaught()) { |
519 v8::Local<v8::Message> message = tryCatch.Message(); | 519 v8::Local<v8::Message> message = tryCatch.Message(); |
520 String text = !message.IsEmpty() ? toWTFStringWithTypeCheck(message->Get
()) : "Internal error"; | 520 String16 text = !message.IsEmpty() ? toProtocolStringWithTypeCheck(messa
ge->Get()) : "Internal error"; |
521 *exceptionDetails = protocol::Runtime::ExceptionDetails::create().setTex
t(text).build(); | 521 *exceptionDetails = protocol::Runtime::ExceptionDetails::create().setTex
t(text).build(); |
522 } else { | 522 } else { |
523 result = toProtocolValue(function.context(), resultValue); | 523 result = toProtocolValue(function.context(), resultValue); |
524 if (!result) | 524 if (!result) |
525 result = protocol::StringValue::create(String::format("Object has to
o long reference chain(must not be longer than %d)", protocol::Value::maxDepth))
; | 525 result = protocol::StringValue::create("Object has too long referenc
e chain(must not be longer than " + String16::number(protocol::Value::maxDepth)
+ ")"); |
526 } | 526 } |
527 return result.release(); | 527 return result.release(); |
528 } | 528 } |
529 | 529 |
530 void InjectedScript::dispose() | 530 void InjectedScript::dispose() |
531 { | 531 { |
532 m_manager->discardInjectedScript(m_contextId); | 532 m_manager->discardInjectedScript(m_contextId); |
533 } | 533 } |
534 | 534 |
535 } // namespace blink | 535 } // namespace blink |
OLD | NEW |