| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 frames->addItem(callFrame.release()); | 100 frames->addItem(callFrame.release()); |
| 101 } | 101 } |
| 102 exceptionDetails->setStackTrace(frames.release()); | 102 exceptionDetails->setStackTrace(frames.release()); |
| 103 } | 103 } |
| 104 if (originScriptId) | 104 if (originScriptId) |
| 105 exceptionDetails->setScriptId(String::number(originScriptId)); | 105 exceptionDetails->setScriptId(String::number(originScriptId)); |
| 106 return exceptionDetails.release(); | 106 return exceptionDetails.release(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 InjectedScript::InjectedScript(ScriptValue injectedScriptObject, V8DebuggerClien
t* client, PassRefPtr<InjectedScriptNative> injectedScriptNative, int contextId) | 109 InjectedScript::InjectedScript(v8::Local<v8::Object> injectedScriptObject, V8Deb
uggerClient* client, PassRefPtr<InjectedScriptNative> injectedScriptNative, int
contextId) |
| 110 : m_isolate(injectedScriptObject.isolate()) | 110 : m_isolate(injectedScriptObject->CreationContext()->GetIsolate()) |
| 111 , m_injectedScriptObject(injectedScriptObject) | 111 , m_injectedScriptObject(ScriptValue(ScriptState::from(injectedScriptObject-
>CreationContext()), injectedScriptObject)) |
| 112 , m_client(client) | 112 , m_client(client) |
| 113 , m_native(injectedScriptNative) | 113 , m_native(injectedScriptNative) |
| 114 , m_contextId(contextId) | 114 , m_contextId(contextId) |
| 115 { | 115 { |
| 116 } | 116 } |
| 117 | 117 |
| 118 InjectedScript::~InjectedScript() | 118 InjectedScript::~InjectedScript() |
| 119 { | 119 { |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 function.appendArgument(asyncOrdinal); | 340 function.appendArgument(asyncOrdinal); |
| 341 bool hadException = false; | 341 bool hadException = false; |
| 342 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); | 342 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function,
hadException); |
| 343 ASSERT(!hadException); | 343 ASSERT(!hadException); |
| 344 RefPtr<JSONValue> result = toJSONValue(context, callFramesValue); | 344 RefPtr<JSONValue> result = toJSONValue(context, callFramesValue); |
| 345 if (result && result->type() == JSONValue::TypeArray) | 345 if (result && result->type() == JSONValue::TypeArray) |
| 346 return Array<CallFrame>::runtimeCast(result); | 346 return Array<CallFrame>::runtimeCast(result); |
| 347 return Array<CallFrame>::create(); | 347 return Array<CallFrame>::create(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const | 350 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Lo
cal<v8::Value> value, const String& groupName, bool generatePreview) const |
| 351 { | 351 { |
| 352 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); | 352 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); |
| 353 v8::Local<v8::Context> context = v8Context(); | 353 v8::Local<v8::Context> context = v8Context(); |
| 354 ScriptFunctionCall function(m_client, context, v8Value(), "wrapObject"); | 354 ScriptFunctionCall function(m_client, context, v8Value(), "wrapObject"); |
| 355 function.appendArgument(value.v8Value()); | 355 function.appendArgument(value); |
| 356 function.appendArgument(groupName); | 356 function.appendArgument(groupName); |
| 357 function.appendArgument(canAccessInspectedWindow()); | 357 function.appendArgument(canAccessInspectedWindow()); |
| 358 function.appendArgument(generatePreview); | 358 function.appendArgument(generatePreview); |
| 359 bool hadException = false; | 359 bool hadException = false; |
| 360 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; | 360 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; |
| 361 if (hadException) | 361 if (hadException) |
| 362 return nullptr; | 362 return nullptr; |
| 363 RefPtr<JSONObject> rawResult = toJSONValue(context, r)->asObject(); | 363 RefPtr<JSONObject> rawResult = toJSONValue(context, r)->asObject(); |
| 364 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 364 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 365 } | 365 } |
| 366 | 366 |
| 367 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S
criptValue& table, const ScriptValue& columns) const | 367 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Loc
al<v8::Value> table, v8::Local<v8::Value> columns) const |
| 368 { | 368 { |
| 369 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); | 369 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); |
| 370 v8::Local<v8::Context> context = v8Context(); | 370 v8::Local<v8::Context> context = v8Context(); |
| 371 ScriptFunctionCall function(m_client, context, v8Value(), "wrapTable"); | 371 ScriptFunctionCall function(m_client, context, v8Value(), "wrapTable"); |
| 372 function.appendArgument(canAccessInspectedWindow()); | 372 function.appendArgument(canAccessInspectedWindow()); |
| 373 function.appendArgument(table.v8Value()); | 373 function.appendArgument(table); |
| 374 if (columns.isEmpty()) | 374 if (columns.IsEmpty()) |
| 375 function.appendArgument(false); | 375 function.appendArgument(false); |
| 376 else | 376 else |
| 377 function.appendArgument(columns.v8Value()); | 377 function.appendArgument(columns); |
| 378 bool hadException = false; | 378 bool hadException = false; |
| 379 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException
); | 379 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException
); |
| 380 if (hadException) | 380 if (hadException) |
| 381 return nullptr; | 381 return nullptr; |
| 382 RefPtr<JSONObject> rawResult = toJSONValue(context, r)->asObject(); | 382 RefPtr<JSONObject> rawResult = toJSONValue(context, r)->asObject(); |
| 383 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 383 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 384 } | 384 } |
| 385 | 385 |
| 386 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const | 386 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const |
| 387 { | 387 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); | 419 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); |
| 420 ScriptFunctionCall function(m_client, v8Context(), v8Value(), "setCustomObje
ctFormatterEnabled"); | 420 ScriptFunctionCall function(m_client, v8Context(), v8Value(), "setCustomObje
ctFormatterEnabled"); |
| 421 function.appendArgument(enabled); | 421 function.appendArgument(enabled); |
| 422 RefPtr<JSONValue> result; | 422 RefPtr<JSONValue> result; |
| 423 makeCall(function, &result); | 423 makeCall(function, &result); |
| 424 } | 424 } |
| 425 | 425 |
| 426 bool InjectedScript::canAccessInspectedWindow() const | 426 bool InjectedScript::canAccessInspectedWindow() const |
| 427 { | 427 { |
| 428 ScriptState* scriptState = m_injectedScriptObject.scriptState(); | 428 ScriptState* scriptState = m_injectedScriptObject.scriptState(); |
| 429 return scriptState && m_client->canAccessContext(scriptState->context()); | 429 return scriptState && m_client->callingContextCanAccessContext(scriptState->
context()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 v8::Local<v8::Context> InjectedScript::v8Context() const | 432 v8::Local<v8::Context> InjectedScript::v8Context() const |
| 433 { | 433 { |
| 434 return m_injectedScriptObject.context(); | 434 return m_injectedScriptObject.context(); |
| 435 } | 435 } |
| 436 | 436 |
| 437 v8::Local<v8::Value> InjectedScript::v8Value() const | 437 v8::Local<v8::Value> InjectedScript::v8Value() const |
| 438 { | 438 { |
| 439 return m_injectedScriptObject.v8Value(); | 439 return m_injectedScriptObject.v8Value(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 String text = !message.IsEmpty() ? toCoreStringWithUndefinedOrNullCheck(
message->Get()) : "Internal error"; | 515 String text = !message.IsEmpty() ? toCoreStringWithUndefinedOrNullCheck(
message->Get()) : "Internal error"; |
| 516 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); | 516 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); |
| 517 } else { | 517 } else { |
| 518 *result = toJSONValue(function.context(), resultValue); | 518 *result = toJSONValue(function.context(), resultValue); |
| 519 if (!*result) | 519 if (!*result) |
| 520 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); | 520 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 } // namespace blink | 524 } // namespace blink |
| OLD | NEW |