| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Inject javascript into the context. The compiled script is supposed to ev
aluate into | 82 // Inject javascript into the context. The compiled script is supposed to ev
aluate into |
| 83 // a single anonymous function(it's anonymous to avoid cluttering the global
object with | 83 // a single anonymous function(it's anonymous to avoid cluttering the global
object with |
| 84 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, | 84 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, |
| 85 // injected script id and explicit reference to the inspected global object.
The function is expected | 85 // injected script id and explicit reference to the inspected global object.
The function is expected |
| 86 // to create and configure InjectedScript instance that is going to be used
by the inspector. | 86 // to create and configure InjectedScript instance that is going to be used
by the inspector. |
| 87 String16 injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSo
urce_js), sizeof(InjectedScriptSource_js)); | 87 String16 injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSo
urce_js), sizeof(InjectedScriptSource_js)); |
| 88 v8::Local<v8::Value> value; | 88 v8::Local<v8::Value> value; |
| 89 if (!inspectedContext->debugger()->compileAndRunInternalScript(context, toV8
String(isolate, injectedScriptSource)).ToLocal(&value)) | 89 if (!inspectedContext->debugger()->compileAndRunInternalScript(context, toV8
String(isolate, injectedScriptSource)).ToLocal(&value)) |
| 90 return nullptr; | 90 return nullptr; |
| 91 ASSERT(value->IsFunction()); | 91 DCHECK(value->IsFunction()); |
| 92 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 92 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 93 v8::Local<v8::Object> windowGlobal = context->Global(); | 93 v8::Local<v8::Object> windowGlobal = context->Global(); |
| 94 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(isolate, inspectedContext->contextId()) }; | 94 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(isolate, inspectedContext->contextId()) }; |
| 95 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); | 95 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); |
| 96 v8::Local<v8::Value> injectedScriptValue; | 96 v8::Local<v8::Value> injectedScriptValue; |
| 97 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) | 97 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) |
| 98 return nullptr; | 98 return nullptr; |
| 99 if (!injectedScriptValue->IsObject()) | 99 if (!injectedScriptValue->IsObject()) |
| 100 return nullptr; | 100 return nullptr; |
| 101 return adoptPtr(new InjectedScript(inspectedContext, injectedScriptValue.As<
v8::Object>(), std::move(injectedScriptNative))); | 101 return adoptPtr(new InjectedScript(inspectedContext, injectedScriptValue.As<
v8::Object>(), std::move(injectedScriptNative))); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 m_lastEvaluationResult.Reset(); | 261 m_lastEvaluationResult.Reset(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) | 264 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) |
| 265 { | 265 { |
| 266 v8::HandleScope handles(m_context->isolate()); | 266 v8::HandleScope handles(m_context->isolate()); |
| 267 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "setCustomObjectFormatterEnabled"); | 267 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "setCustomObjectFormatterEnabled"); |
| 268 function.appendArgument(enabled); | 268 function.appendArgument(enabled); |
| 269 bool hadException = false; | 269 bool hadException = false; |
| 270 function.call(hadException); | 270 function.call(hadException); |
| 271 ASSERT(!hadException); | 271 DCHECK(!hadException); |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool InjectedScript::canAccessInspectedWindow() const | 274 bool InjectedScript::canAccessInspectedWindow() const |
| 275 { | 275 { |
| 276 v8::Local<v8::Context> callingContext = m_context->isolate()->GetCallingCont
ext(); | 276 v8::Local<v8::Context> callingContext = m_context->isolate()->GetCallingCont
ext(); |
| 277 if (callingContext.IsEmpty()) | 277 if (callingContext.IsEmpty()) |
| 278 return true; | 278 return true; |
| 279 return m_context->debugger()->client()->callingContextCanAccessContext(calli
ngContext, m_context->context()); | 279 return m_context->debugger()->client()->callingContextCanAccessContext(calli
ngContext, m_context->context()); |
| 280 } | 280 } |
| 281 | 281 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 if (!global->SetPrivate(m_context, m_extensionPrivate, extensionObject).From
Maybe(false)) { | 422 if (!global->SetPrivate(m_context, m_extensionPrivate, extensionObject).From
Maybe(false)) { |
| 423 *m_errorString = "Internal error"; | 423 *m_errorString = "Internal error"; |
| 424 return false; | 424 return false; |
| 425 } | 425 } |
| 426 m_global = global; | 426 m_global = global; |
| 427 return true; | 427 return true; |
| 428 } | 428 } |
| 429 | 429 |
| 430 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() | 430 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() |
| 431 { | 431 { |
| 432 ASSERT(!m_ignoreExceptionsAndMuteConsole); | 432 DCHECK(!m_ignoreExceptionsAndMuteConsole); |
| 433 m_ignoreExceptionsAndMuteConsole = true; | 433 m_ignoreExceptionsAndMuteConsole = true; |
| 434 m_debugger->client()->muteConsole(); | 434 m_debugger->client()->muteConsole(); |
| 435 m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl:
:DontPauseOnExceptions); | 435 m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl:
:DontPauseOnExceptions); |
| 436 } | 436 } |
| 437 | 437 |
| 438 V8DebuggerImpl::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptio
nsState(V8DebuggerImpl::PauseOnExceptionsState newState) | 438 V8DebuggerImpl::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptio
nsState(V8DebuggerImpl::PauseOnExceptionsState newState) |
| 439 { | 439 { |
| 440 if (!m_debugger->enabled()) | 440 if (!m_debugger->enabled()) |
| 441 return newState; | 441 return newState; |
| 442 V8DebuggerImpl::PauseOnExceptionsState presentState = m_debugger->getPauseOn
ExceptionsState(); | 442 V8DebuggerImpl::PauseOnExceptionsState presentState = m_debugger->getPauseOn
ExceptionsState(); |
| 443 if (presentState != newState) | 443 if (presentState != newState) |
| 444 m_debugger->setPauseOnExceptionsState(newState); | 444 m_debugger->setPauseOnExceptionsState(newState); |
| 445 return presentState; | 445 return presentState; |
| 446 } | 446 } |
| 447 | 447 |
| 448 void InjectedScript::Scope::pretendUserGesture() | 448 void InjectedScript::Scope::pretendUserGesture() |
| 449 { | 449 { |
| 450 ASSERT(!m_userGesture); | 450 DCHECK(!m_userGesture); |
| 451 m_userGesture = true; | 451 m_userGesture = true; |
| 452 m_debugger->client()->beginUserGesture(); | 452 m_debugger->client()->beginUserGesture(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void InjectedScript::Scope::cleanup() | 455 void InjectedScript::Scope::cleanup() |
| 456 { | 456 { |
| 457 v8::Local<v8::Object> global; | 457 v8::Local<v8::Object> global; |
| 458 if (m_global.ToLocal(&global)) { | 458 if (m_global.ToLocal(&global)) { |
| 459 ASSERT(!m_context.IsEmpty()); | 459 DCHECK(!m_context.IsEmpty()); |
| 460 global->DeletePrivate(m_context, m_extensionPrivate); | 460 global->DeletePrivate(m_context, m_extensionPrivate); |
| 461 m_global = v8::MaybeLocal<v8::Object>(); | 461 m_global = v8::MaybeLocal<v8::Object>(); |
| 462 } | 462 } |
| 463 if (!m_context.IsEmpty()) { | 463 if (!m_context.IsEmpty()) { |
| 464 m_context->Exit(); | 464 m_context->Exit(); |
| 465 m_context.Clear(); | 465 m_context.Clear(); |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 InjectedScript::Scope::~Scope() | 469 InjectedScript::Scope::~Scope() |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) | 529 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) |
| 530 { | 530 { |
| 531 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); | 531 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); |
| 532 if (!remoteId) | 532 if (!remoteId) |
| 533 return; | 533 return; |
| 534 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 534 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
| 535 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); | 535 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace blink | 538 } // namespace blink |
| OLD | NEW |