ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->executionContext(); ScriptState::Scope scope(m_injectedScriptObject.scriptState()); v8::Local<v8::Function> functionObj = function.function(); DevToolsFunctionInfo info(functionObj); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, info.scriptId(), "InjectedScriptSource.js", info.lineNumber())); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(executionContext, info); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); InspectorInstrumentation::didCallFunction(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); return resultValue; }
ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->executionContext(); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, 0, name(), 1)); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(executionContext, 0, name(), 1); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); InspectorInstrumentation::didCallFunction(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return resultValue; }
ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ScriptState::Scope scope(m_injectedScriptObject.scriptState()); v8::Local<v8::Function> functionObj = function.function(); DevToolsFunctionInfo info(functionObj); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); return resultValue; }
void InjectedScript::makeCallWithExceptionDetails(ScriptFunctionCall& function, RefPtr<JSONValue>* result, RefPtr<TypeBuilder::Debugger::ExceptionDetails>* exceptionDetails) { ScriptState::Scope scope(injectedScriptObject().scriptState()); v8::TryCatch tryCatch; ScriptValue resultValue = function.callWithoutExceptionHandling(); if (tryCatch.HasCaught()) { v8::Local<v8::Message> message = tryCatch.Message(); String text = !message.IsEmpty() ? toCoreStringWithUndefinedOrNullCheck(message->Get()) : "Internal error"; *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().setText(text); } else { *result = toJSONValue(resultValue); if (!*result) *result = JSONString::create(String::format("Object has too long reference chain(must not be longer than %d)", JSONValue::maxDepth)); } }
void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result) { if (hasNoValue() || !canAccessInspectedWindow()) { *result = InspectorValue::null(); return; } bool hadException = false; ScriptValue resultValue = function.call(hadException); ASSERT(!hadException); if (!hadException) *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); else *result = InspectorString::create("Exception while making a call."); }
ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ScriptState* scriptState = m_injectedScriptObject.scriptState(); ScriptState::Scope scope(scriptState); bool evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); return resultValue; }
ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->executionContext(); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(executionContext, name(), 1); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); InspectorInstrumentation::didCallFunction(cookie); return resultValue; }
ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromScriptState(m_injectedScriptObject.scriptState()); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(scriptExecutionContext, "InjectedScript", 1); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !evalEnabled(scriptState); // Temporarily enable allow evals for inspector. if (evalIsDisabled) setEvalEnabled(scriptState, true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) setEvalEnabled(scriptState, false); InspectorInstrumentation::didCallFunction(cookie); return resultValue; }
PassOwnPtr<ScriptFunctionCall> InspectorFrontend::newFunctionCall(const String& functionName) { ScriptFunctionCall* function = new ScriptFunctionCall(m_scriptState, m_webInspector, "dispatch"); function->appendArgument(functionName); return function; }