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/core/v8/ScriptFunctionCall.h" | 36 #include "bindings/core/v8/ScriptFunctionCall.h" |
37 #include "bindings/core/v8/V8Binding.h" | |
37 #include "core/inspector/InjectedScriptHost.h" | 38 #include "core/inspector/InjectedScriptHost.h" |
38 #include "core/inspector/JSONParser.h" | 39 #include "core/inspector/JSONParser.h" |
39 #include "platform/JSONValues.h" | 40 #include "platform/JSONValues.h" |
40 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
41 | 42 |
42 using blink::TypeBuilder::Array; | 43 using blink::TypeBuilder::Array; |
43 using blink::TypeBuilder::Debugger::CallFrame; | 44 using blink::TypeBuilder::Debugger::CallFrame; |
44 using blink::TypeBuilder::Debugger::CollectionEntry; | 45 using blink::TypeBuilder::Debugger::CollectionEntry; |
45 using blink::TypeBuilder::Debugger::FunctionDetails; | 46 using blink::TypeBuilder::Debugger::FunctionDetails; |
46 using blink::TypeBuilder::Debugger::GeneratorObjectDetails; | 47 using blink::TypeBuilder::Debugger::GeneratorObjectDetails; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 274 |
274 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& callFrames, int asyncOrdinal) | 275 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& callFrames, int asyncOrdinal) |
275 { | 276 { |
276 ASSERT(!isEmpty()); | 277 ASSERT(!isEmpty()); |
277 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); | 278 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); |
278 function.appendArgument(callFrames); | 279 function.appendArgument(callFrames); |
279 function.appendArgument(asyncOrdinal); | 280 function.appendArgument(asyncOrdinal); |
280 bool hadException = false; | 281 bool hadException = false; |
281 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion); | 282 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion); |
282 ASSERT(!hadException); | 283 ASSERT(!hadException); |
283 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); | 284 ScriptState* state = scriptState(); |
285 ScriptState::Scope scope(state); | |
haraken
2015/03/19 23:26:13
You sometimes enter a ScriptState::Scope but somet
| |
286 NonThrowableExceptionState exceptionState; | |
bashi
2015/03/19 23:53:41
It would be better not to use NonThrowableExceptio
| |
287 RefPtr<JSONValue> result = ScriptValue::to<JSONValuePtr>(state->isolate(), c allFramesValue, exceptionState); | |
284 if (result && result->type() == JSONValue::TypeArray) | 288 if (result && result->type() == JSONValue::TypeArray) |
285 return Array<CallFrame>::runtimeCast(result); | 289 return Array<CallFrame>::runtimeCast(result); |
286 return Array<CallFrame>::create(); | 290 return Array<CallFrame>::create(); |
287 } | 291 } |
288 | 292 |
289 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const | 293 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const |
290 { | 294 { |
291 ASSERT(!isEmpty()); | 295 ASSERT(!isEmpty()); |
292 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); | 296 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); |
293 wrapFunction.appendArgument(value); | 297 wrapFunction.appendArgument(value); |
294 wrapFunction.appendArgument(groupName); | 298 wrapFunction.appendArgument(groupName); |
295 wrapFunction.appendArgument(canAccessInspectedWindow()); | 299 wrapFunction.appendArgument(canAccessInspectedWindow()); |
296 wrapFunction.appendArgument(generatePreview); | 300 wrapFunction.appendArgument(generatePreview); |
297 bool hadException = false; | 301 bool hadException = false; |
298 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 302 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
299 if (hadException) | 303 if (hadException) |
300 return nullptr; | 304 return nullptr; |
301 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 305 ScriptState* state = scriptState(); |
306 ScriptState::Scope scope(state); | |
307 NonThrowableExceptionState exceptionState; | |
308 RefPtr<JSONObject> rawResult = ScriptValue::to<JSONValuePtr>(state->isolate( ), r, exceptionState)->asObject(); | |
302 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 309 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
303 } | 310 } |
304 | 311 |
305 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S criptValue& table, const ScriptValue& columns) const | 312 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S criptValue& table, const ScriptValue& columns) const |
306 { | 313 { |
307 ASSERT(!isEmpty()); | 314 ASSERT(!isEmpty()); |
308 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); | 315 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); |
309 wrapFunction.appendArgument(canAccessInspectedWindow()); | 316 wrapFunction.appendArgument(canAccessInspectedWindow()); |
310 wrapFunction.appendArgument(table); | 317 wrapFunction.appendArgument(table); |
311 if (columns.isEmpty()) | 318 if (columns.isEmpty()) |
312 wrapFunction.appendArgument(false); | 319 wrapFunction.appendArgument(false); |
313 else | 320 else |
314 wrapFunction.appendArgument(columns); | 321 wrapFunction.appendArgument(columns); |
315 bool hadException = false; | 322 bool hadException = false; |
316 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 323 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
317 if (hadException) | 324 if (hadException) |
318 return nullptr; | 325 return nullptr; |
319 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 326 ScriptState* state = scriptState(); |
327 ScriptState::Scope scope(state); | |
328 NonThrowableExceptionState exceptionState; | |
329 RefPtr<JSONObject> rawResult = ScriptValue::to<JSONValuePtr>(state->isolate( ), r, exceptionState)->asObject(); | |
320 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 330 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
321 } | 331 } |
322 | 332 |
323 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no de, const String& groupName) | 333 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no de, const String& groupName) |
324 { | 334 { |
325 return wrapObject(nodeAsScriptValue(node), groupName); | 335 return wrapObject(nodeAsScriptValue(node), groupName); |
326 } | 336 } |
327 | 337 |
328 ScriptValue InjectedScript::findObjectById(const String& objectId) const | 338 ScriptValue InjectedScript::findObjectById(const String& objectId) const |
329 { | 339 { |
(...skipping 28 matching lines...) Expand all Loading... | |
358 { | 368 { |
359 ASSERT(!isEmpty()); | 369 ASSERT(!isEmpty()); |
360 ScriptFunctionCall function(injectedScriptObject(), "setCustomObjectFormatte rEnabled"); | 370 ScriptFunctionCall function(injectedScriptObject(), "setCustomObjectFormatte rEnabled"); |
361 function.appendArgument(enabled); | 371 function.appendArgument(enabled); |
362 RefPtr<JSONValue> result; | 372 RefPtr<JSONValue> result; |
363 makeCall(function, &result); | 373 makeCall(function, &result); |
364 } | 374 } |
365 | 375 |
366 } // namespace blink | 376 } // namespace blink |
367 | 377 |
OLD | NEW |