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 String expression2 = expression; |
136 v8::HandleScope handles(m_isolate); | 137 v8::HandleScope handles(m_isolate); |
137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); | 138 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); |
138 function.appendArgument(expression); | 139 function.appendArgument(String16(expression2)); |
139 function.appendArgument(objectGroup); | 140 function.appendArgument(objectGroup); |
140 function.appendArgument(includeCommandLineAPI); | 141 function.appendArgument(includeCommandLineAPI); |
141 function.appendArgument(returnByValue); | 142 function.appendArgument(returnByValue); |
142 function.appendArgument(generatePreview); | 143 function.appendArgument(generatePreview); |
143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 144 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
144 } | 145 } |
145 | 146 |
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) | 147 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 { | 148 { |
148 v8::HandleScope handles(m_isolate); | 149 v8::HandleScope handles(m_isolate); |
149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); | 150 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); |
150 function.appendArgument(objectId); | 151 function.appendArgument(objectId); |
151 function.appendArgument(expression); | 152 function.appendArgument(expression); |
152 function.appendArgument(arguments); | 153 function.appendArgument(arguments); |
153 function.appendArgument(returnByValue); | 154 function.appendArgument(returnByValue); |
154 function.appendArgument(generatePreview); | 155 function.appendArgument(generatePreview); |
155 *result = makeEvalCall(errorString, function, wasThrown); | 156 *result = makeEvalCall(errorString, function, wasThrown); |
156 } | 157 } |
157 | 158 |
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) | 159 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 { | 160 { |
160 v8::HandleScope handles(m_isolate); | 161 v8::HandleScope handles(m_isolate); |
161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame
"); | 162 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame
"); |
162 function.appendArgument(callFrames); | 163 function.appendArgument(callFrames); |
163 function.appendArgument(callFrameId); | 164 function.appendArgument(callFrameId); |
164 function.appendArgument(expression); | 165 function.appendArgument(expression); |
165 function.appendArgument(objectGroup); | 166 function.appendArgument(objectGroup); |
166 function.appendArgument(includeCommandLineAPI); | 167 function.appendArgument(includeCommandLineAPI); |
167 function.appendArgument(returnByValue); | 168 function.appendArgument(returnByValue); |
168 function.appendArgument(generatePreview); | 169 function.appendArgument(generatePreview); |
169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 170 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
170 } | 171 } |
171 | 172 |
172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object
> callFrames, const String& callFrameId) | 173 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object
> callFrames, const String16& callFrameId) |
173 { | 174 { |
174 v8::HandleScope handles(m_isolate); | 175 v8::HandleScope handles(m_isolate); |
175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); | 176 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); |
176 function.appendArgument(callFrames); | 177 function.appendArgument(callFrames); |
177 function.appendArgument(callFrameId); | 178 function.appendArgument(callFrameId); |
178 OwnPtr<protocol::Value> resultValue = makeCall(function); | 179 OwnPtr<protocol::Value> resultValue = makeCall(function); |
179 if (resultValue) { | 180 if (resultValue) { |
180 if (resultValue->type() == protocol::Value::TypeString) { | 181 if (resultValue->type() == protocol::Value::TypeString) { |
181 resultValue->asString(errorString); | 182 resultValue->asString(errorString); |
182 } else { | 183 } else { |
183 bool value; | 184 bool value; |
184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); | 185 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); |
185 } | 186 } |
186 return; | 187 return; |
187 } | 188 } |
188 *errorString = "Internal error"; | 189 *errorString = "Internal error"; |
189 } | 190 } |
190 | 191 |
191 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::
Object> callFrames, const String& callFrameId, Maybe<Array<protocol::Debugger::L
ocation>>* positions) | 192 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::
Object> callFrames, const String16& callFrameId, Maybe<Array<protocol::Debugger:
:Location>>* positions) |
192 { | 193 { |
193 v8::HandleScope handles(m_isolate); | 194 v8::HandleScope handles(m_isolate); |
194 V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"
); | 195 V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"
); |
195 function.appendArgument(callFrames); | 196 function.appendArgument(callFrames); |
196 function.appendArgument(callFrameId); | 197 function.appendArgument(callFrameId); |
197 OwnPtr<protocol::Value> resultValue = makeCall(function); | 198 OwnPtr<protocol::Value> resultValue = makeCall(function); |
198 if (resultValue) { | 199 if (resultValue) { |
199 if (resultValue->type() == protocol::Value::TypeString) { | 200 if (resultValue->type() == protocol::Value::TypeString) { |
200 resultValue->asString(errorString); | 201 resultValue->asString(errorString); |
201 return; | 202 return; |
202 } | 203 } |
203 if (resultValue->type() == protocol::Value::TypeArray) { | 204 if (resultValue->type() == protocol::Value::TypeArray) { |
204 protocol::ErrorSupport errors(errorString); | 205 protocol::ErrorSupport errors(errorString); |
205 *positions = Array<protocol::Debugger::Location>::parse(resultValue.
get(), &errors); | 206 *positions = Array<protocol::Debugger::Location>::parse(resultValue.
get(), &errors); |
206 return; | 207 return; |
207 } | 208 } |
208 } | 209 } |
209 *errorString = "Internal error"; | 210 *errorString = "Internal error"; |
210 } | 211 } |
211 | 212 |
212 void InjectedScript::setVariableValue(ErrorString* errorString, | 213 void InjectedScript::setVariableValue(ErrorString* errorString, |
213 v8::Local<v8::Object> callFrames, | 214 v8::Local<v8::Object> callFrames, |
214 const protocol::Maybe<String>& callFrameIdOpt, | 215 const protocol::Maybe<String16>& callFrameIdOpt, |
215 const protocol::Maybe<String>& functionObjectIdOpt, | 216 const protocol::Maybe<String16>& functionObjectIdOpt, |
216 int scopeNumber, | 217 int scopeNumber, |
217 const String& variableName, | 218 const String16& variableName, |
218 const String& newValueStr) | 219 const String16& newValueStr) |
219 { | 220 { |
220 v8::HandleScope handles(m_isolate); | 221 v8::HandleScope handles(m_isolate); |
221 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); | 222 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); |
222 if (callFrameIdOpt.isJust()) { | 223 if (callFrameIdOpt.isJust()) { |
223 function.appendArgument(callFrames); | 224 function.appendArgument(callFrames); |
224 function.appendArgument(callFrameIdOpt.fromJust()); | 225 function.appendArgument(callFrameIdOpt.fromJust()); |
225 } else { | 226 } else { |
226 function.appendArgument(false); | 227 function.appendArgument(false); |
227 function.appendArgument(false); | 228 function.appendArgument(false); |
228 } | 229 } |
229 if (functionObjectIdOpt.isJust()) | 230 if (functionObjectIdOpt.isJust()) |
230 function.appendArgument(functionObjectIdOpt.fromJust()); | 231 function.appendArgument(functionObjectIdOpt.fromJust()); |
231 else | 232 else |
232 function.appendArgument(false); | 233 function.appendArgument(false); |
233 function.appendArgument(scopeNumber); | 234 function.appendArgument(scopeNumber); |
234 function.appendArgument(variableName); | 235 function.appendArgument(variableName); |
235 function.appendArgument(newValueStr); | 236 function.appendArgument(newValueStr); |
236 OwnPtr<protocol::Value> resultValue = makeCall(function); | 237 OwnPtr<protocol::Value> resultValue = makeCall(function); |
237 if (!resultValue) { | 238 if (!resultValue) { |
238 *errorString = "Internal error"; | 239 *errorString = "Internal error"; |
239 return; | 240 return; |
240 } | 241 } |
241 if (resultValue->type() == protocol::Value::TypeString) { | 242 if (resultValue->type() == protocol::Value::TypeString) { |
242 resultValue->asString(errorString); | 243 resultValue->asString(errorString); |
243 return; | 244 return; |
244 } | 245 } |
245 // Normal return. | 246 // Normal return. |
246 } | 247 } |
247 | 248 |
248 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String&
functionId, OwnPtr<FunctionDetails>* result) | 249 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16
& functionId, OwnPtr<FunctionDetails>* result) |
249 { | 250 { |
250 v8::HandleScope handles(m_isolate); | 251 v8::HandleScope handles(m_isolate); |
251 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); | 252 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); |
252 function.appendArgument(functionId); | 253 function.appendArgument(functionId); |
253 OwnPtr<protocol::Value> resultValue = makeCall(function); | 254 OwnPtr<protocol::Value> resultValue = makeCall(function); |
254 protocol::ErrorSupport errors(errorString); | 255 protocol::ErrorSupport errors(errorString); |
255 *result = FunctionDetails::parse(resultValue.get(), &errors); | 256 *result = FunctionDetails::parse(resultValue.get(), &errors); |
256 } | 257 } |
257 | 258 |
258 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S
tring& objectId, OwnPtr<GeneratorObjectDetails>* result) | 259 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S
tring16& objectId, OwnPtr<GeneratorObjectDetails>* result) |
259 { | 260 { |
260 v8::HandleScope handles(m_isolate); | 261 v8::HandleScope handles(m_isolate); |
261 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD
etails"); | 262 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD
etails"); |
262 function.appendArgument(objectId); | 263 function.appendArgument(objectId); |
263 OwnPtr<protocol::Value> resultValue = makeCall(function); | 264 OwnPtr<protocol::Value> resultValue = makeCall(function); |
264 protocol::ErrorSupport errors(errorString); | 265 protocol::ErrorSupport errors(errorString); |
265 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); | 266 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); |
266 } | 267 } |
267 | 268 |
268 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String
& objectId, OwnPtr<Array<CollectionEntry>>* result) | 269 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String
16& objectId, OwnPtr<Array<CollectionEntry>>* result) |
269 { | 270 { |
270 v8::HandleScope handles(m_isolate); | 271 v8::HandleScope handles(m_isolate); |
271 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie
s"); | 272 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie
s"); |
272 function.appendArgument(objectId); | 273 function.appendArgument(objectId); |
273 OwnPtr<protocol::Value> resultValue = makeCall(function); | 274 OwnPtr<protocol::Value> resultValue = makeCall(function); |
274 protocol::ErrorSupport errors(errorString); | 275 protocol::ErrorSupport errors(errorString); |
275 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); | 276 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); |
276 } | 277 } |
277 | 278 |
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) | 279 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 { | 280 { |
280 v8::HandleScope handles(m_isolate); | 281 v8::HandleScope handles(m_isolate); |
281 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); | 282 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); |
282 function.appendArgument(objectId); | 283 function.appendArgument(objectId); |
283 function.appendArgument(ownProperties); | 284 function.appendArgument(ownProperties); |
284 function.appendArgument(accessorPropertiesOnly); | 285 function.appendArgument(accessorPropertiesOnly); |
285 function.appendArgument(generatePreview); | 286 function.appendArgument(generatePreview); |
286 | 287 |
287 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 288 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
288 if (exceptionDetails->isJust()) { | 289 if (exceptionDetails->isJust()) { |
289 // FIXME: make properties optional | 290 // FIXME: make properties optional |
290 *properties = Array<PropertyDescriptor>::create(); | 291 *properties = Array<PropertyDescriptor>::create(); |
291 return; | 292 return; |
292 } | 293 } |
293 protocol::ErrorSupport errors(errorString); | 294 protocol::ErrorSupport errors(errorString); |
294 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); | 295 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); |
295 } | 296 } |
296 | 297 |
297 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protoco
l::Runtime::ExceptionDetails>* exceptionDetails) | 298 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) |
298 { | 299 { |
299 v8::HandleScope handles(m_isolate); | 300 v8::HandleScope handles(m_isolate); |
300 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti
es"); | 301 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti
es"); |
301 function.appendArgument(objectId); | 302 function.appendArgument(objectId); |
302 | 303 |
303 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 304 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
304 if (exceptionDetails->isJust()) | 305 if (exceptionDetails->isJust()) |
305 return; | 306 return; |
306 protocol::ErrorSupport errors(errorString); | 307 protocol::ErrorSupport errors(errorString); |
307 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc
riptor>::parse(result.get(), &errors); | 308 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc
riptor>::parse(result.get(), &errors); |
308 if (!errors.hasErrors() && array->length() > 0) | 309 if (!errors.hasErrors() && array->length() > 0) |
309 *properties = array.release(); | 310 *properties = array.release(); |
310 } | 311 } |
311 | 312 |
312 void InjectedScript::releaseObject(const String& objectId) | 313 void InjectedScript::releaseObject(const String16& objectId) |
313 { | 314 { |
314 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); | 315 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); |
315 if (!parsedObjectId) | 316 if (!parsedObjectId) |
316 return; | 317 return; |
317 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); | 318 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); |
318 if (!object) | 319 if (!object) |
319 return; | 320 return; |
320 int boundId = 0; | 321 int boundId = 0; |
321 if (!object->getNumber("id", &boundId)) | 322 if (!object->getNumber("id", &boundId)) |
322 return; | 323 return; |
(...skipping 27 matching lines...) Expand all Loading... |
350 bool hadException = false; | 351 bool hadException = false; |
351 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); | 352 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); |
352 ASSERT(!hadException); | 353 ASSERT(!hadException); |
353 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue)
; | 354 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue)
; |
354 protocol::ErrorSupport errors; | 355 protocol::ErrorSupport errors; |
355 if (result && result->type() == protocol::Value::TypeArray) | 356 if (result && result->type() == protocol::Value::TypeArray) |
356 return Array<CallFrame>::parse(result.get(), &errors); | 357 return Array<CallFrame>::parse(result.get(), &errors); |
357 return Array<CallFrame>::create(); | 358 return Array<CallFrame>::create(); |
358 } | 359 } |
359 | 360 |
360 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local
<v8::Value> value, const String& groupName, bool generatePreview) const | 361 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local
<v8::Value> value, const String16& groupName, bool generatePreview) const |
361 { | 362 { |
362 v8::HandleScope handles(m_isolate); | 363 v8::HandleScope handles(m_isolate); |
363 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); | 364 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); |
364 function.appendArgument(value); | 365 function.appendArgument(value); |
365 function.appendArgument(groupName); | 366 function.appendArgument(groupName); |
366 function.appendArgument(canAccessInspectedWindow()); | 367 function.appendArgument(canAccessInspectedWindow()); |
367 function.appendArgument(generatePreview); | 368 function.appendArgument(generatePreview); |
368 bool hadException = false; | 369 bool hadException = false; |
369 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; | 370 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; |
370 if (hadException) | 371 if (hadException) |
(...skipping 18 matching lines...) Expand all Loading... |
389 return nullptr; | 390 return nullptr; |
390 protocol::ErrorSupport errors; | 391 protocol::ErrorSupport errors; |
391 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); | 392 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); |
392 } | 393 } |
393 | 394 |
394 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const | 395 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const |
395 { | 396 { |
396 return m_native->objectForId(objectId.id()); | 397 return m_native->objectForId(objectId.id()); |
397 } | 398 } |
398 | 399 |
399 String InjectedScript::objectGroupName(const RemoteObjectId& objectId) const | 400 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const |
400 { | 401 { |
401 return m_native->groupName(objectId.id()); | 402 return m_native->groupName(objectId.id()); |
402 } | 403 } |
403 | 404 |
404 void InjectedScript::releaseObjectGroup(const String& objectGroup) | 405 void InjectedScript::releaseObjectGroup(const String16& objectGroup) |
405 { | 406 { |
406 v8::HandleScope handles(m_isolate); | 407 v8::HandleScope handles(m_isolate); |
407 m_native->releaseObjectGroup(objectGroup); | 408 m_native->releaseObjectGroup(objectGroup); |
408 if (objectGroup == "console") { | 409 if (objectGroup == "console") { |
409 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua
tionResult"); | 410 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua
tionResult"); |
410 bool hadException = false; | 411 bool hadException = false; |
411 callFunctionWithEvalEnabled(function, hadException); | 412 callFunctionWithEvalEnabled(function, hadException); |
412 ASSERT(!hadException); | 413 ASSERT(!hadException); |
413 } | 414 } |
414 } | 415 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 return nullptr; | 462 return nullptr; |
462 } | 463 } |
463 | 464 |
464 bool hadException = false; | 465 bool hadException = false; |
465 v8::Local<v8::Value> resultValue = callFunctionWithEvalEnabled(function, had
Exception); | 466 v8::Local<v8::Value> resultValue = callFunctionWithEvalEnabled(function, had
Exception); |
466 | 467 |
467 ASSERT(!hadException); | 468 ASSERT(!hadException); |
468 if (!hadException) { | 469 if (!hadException) { |
469 result = toProtocolValue(function.context(), resultValue); | 470 result = toProtocolValue(function.context(), resultValue); |
470 if (!result) | 471 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))
; | 472 result = protocol::StringValue::create("Object has too long referenc
e chain(must not be longer than " + String16::number(protocol::Value::maxDepth)
+ ")"); |
472 } else { | 473 } else { |
473 result = protocol::StringValue::create("Exception while making a call.")
; | 474 result = protocol::StringValue::create("Exception while making a call.")
; |
474 } | 475 } |
475 return result.release(); | 476 return result.release(); |
476 } | 477 } |
477 | 478 |
478 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::makeEvalCall(ErrorSt
ring* errorString, V8FunctionCall& function, Maybe<bool>* wasThrown, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) | 479 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::makeEvalCall(ErrorSt
ring* errorString, V8FunctionCall& function, Maybe<bool>* wasThrown, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) |
479 { | 480 { |
480 OwnPtr<protocol::Value> result = makeCall(function); | 481 OwnPtr<protocol::Value> result = makeCall(function); |
481 if (!result) { | 482 if (!result) { |
(...skipping 28 matching lines...) Expand all Loading... |
510 | 511 |
511 PassOwnPtr<protocol::Value> InjectedScript::makeCallWithExceptionDetails(V8Funct
ionCall& function, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 512 PassOwnPtr<protocol::Value> InjectedScript::makeCallWithExceptionDetails(V8Funct
ionCall& function, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
512 { | 513 { |
513 OwnPtr<protocol::Value> result; | 514 OwnPtr<protocol::Value> result; |
514 v8::HandleScope handles(m_isolate); | 515 v8::HandleScope handles(m_isolate); |
515 v8::Context::Scope scope(context()); | 516 v8::Context::Scope scope(context()); |
516 v8::TryCatch tryCatch(m_isolate); | 517 v8::TryCatch tryCatch(m_isolate); |
517 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); | 518 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); |
518 if (tryCatch.HasCaught()) { | 519 if (tryCatch.HasCaught()) { |
519 v8::Local<v8::Message> message = tryCatch.Message(); | 520 v8::Local<v8::Message> message = tryCatch.Message(); |
520 String text = !message.IsEmpty() ? toWTFStringWithTypeCheck(message->Get
()) : "Internal error"; | 521 String16 text = !message.IsEmpty() ? toProtocolStringWithTypeCheck(messa
ge->Get()) : "Internal error"; |
521 *exceptionDetails = protocol::Runtime::ExceptionDetails::create().setTex
t(text).build(); | 522 *exceptionDetails = protocol::Runtime::ExceptionDetails::create().setTex
t(text).build(); |
522 } else { | 523 } else { |
523 result = toProtocolValue(function.context(), resultValue); | 524 result = toProtocolValue(function.context(), resultValue); |
524 if (!result) | 525 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))
; | 526 result = protocol::StringValue::create("Object has too long referenc
e chain(must not be longer than " + String16::number(protocol::Value::maxDepth)
+ ")"); |
526 } | 527 } |
527 return result.release(); | 528 return result.release(); |
528 } | 529 } |
529 | 530 |
530 void InjectedScript::dispose() | 531 void InjectedScript::dispose() |
531 { | 532 { |
532 m_manager->discardInjectedScript(m_contextId); | 533 m_manager->discardInjectedScript(m_contextId); |
533 } | 534 } |
534 | 535 |
535 } // namespace blink | 536 } // namespace blink |
OLD | NEW |