本文整理汇总了C++中ExecutionContext::addConsoleMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionContext::addConsoleMessage方法的具体用法?C++ ExecutionContext::addConsoleMessage怎么用?C++ ExecutionContext::addConsoleMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext::addConsoleMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: revoke
void revoke()
{
ExecutionContext* executionContext = m_scriptState->executionContext();
if (!executionContext)
return;
ScriptState::Scope scope(m_scriptState);
v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate());
v8::Local<v8::Value> reason = m_exception.newLocal(m_scriptState->isolate());
// Either collected or https://crbug.com/450330
if (value.IsEmpty() || !value->IsPromise())
return;
EventTarget* target = executionContext->errorEventTarget();
if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target && !executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) {
PromiseRejectionEventInit init;
init.setPromise(ScriptPromise(m_scriptState, value));
init.setReason(ScriptValue(m_scriptState, reason));
RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEvent::create(m_scriptState, EventTypeNames::rejectionhandled, init);
target->dispatchEvent(event);
}
if (m_shouldLogToConsole) {
RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSource, RevokedErrorMessageLevel, "Handler added to rejected promise");
consoleMessage->setRelatedMessageId(m_consoleMessageId);
executionContext->addConsoleMessage(consoleMessage.release());
}
}
示例2: report
void report()
{
if (!m_scriptState->contextIsValid())
return;
// If execution termination has been triggered, quietly bail out.
if (v8::V8::IsExecutionTerminating(m_scriptState->isolate()))
return;
ExecutionContext* executionContext = m_scriptState->executionContext();
if (!executionContext)
return;
ScriptState::Scope scope(m_scriptState);
v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate());
v8::Local<v8::Value> reason = m_exception.newLocal(m_scriptState->isolate());
// Either collected or https://crbug.com/450330
if (value.IsEmpty() || !value->IsPromise())
return;
ASSERT(!hasHandler());
EventTarget* target = executionContext->errorEventTarget();
if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target && !executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) {
PromiseRejectionEventInit init;
init.setPromise(ScriptPromise(m_scriptState, value));
init.setReason(ScriptValue(m_scriptState, reason));
init.setCancelable(true);
RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEvent::create(m_scriptState, EventTypeNames::unhandledrejection, init);
// Log to console if event was not preventDefault()'ed.
m_shouldLogToConsole = target->dispatchEvent(event);
}
if (m_shouldLogToConsole) {
const String errorMessage = "Uncaught (in promise)";
Vector<ScriptValue> args;
args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isolate(), errorMessage)));
args.append(ScriptValue(m_scriptState, reason));
RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::create(m_scriptState, args);
String embedderErrorMessage = m_errorMessage;
if (embedderErrorMessage.isEmpty())
embedderErrorMessage = errorMessage;
else if (embedderErrorMessage.startsWith("Uncaught "))
embedderErrorMessage.insert(" (in promise)", 8);
RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, embedderErrorMessage, m_resourceName, m_lineNumber, m_columnNumber);
consoleMessage->setScriptArguments(arguments);
consoleMessage->setCallStack(m_callStack);
consoleMessage->setScriptId(m_scriptId);
m_consoleMessageId = consoleMessage->assignMessageId();
executionContext->addConsoleMessage(consoleMessage.release());
}
m_callStack.clear();
}