本文整理汇总了C++中ErrorEvent::setUnsanitizedMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorEvent::setUnsanitizedMessage方法的具体用法?C++ ErrorEvent::setUnsanitizedMessage怎么用?C++ ErrorEvent::setUnsanitizedMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorEvent
的用法示例。
在下文中一共展示了ErrorEvent::setUnsanitizedMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Local<v8::Message> message,
v8::Local<v8::Value> data) {
ASSERT(isMainThread());
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (isolate->GetEnteredContext().IsEmpty())
return;
// If called during context initialization, there will be no entered context.
ScriptState* scriptState = ScriptState::current(isolate);
if (!scriptState->contextIsValid())
return;
ExecutionContext* context = scriptState->getExecutionContext();
std::unique_ptr<SourceLocation> location =
SourceLocation::fromMessage(isolate, message, context);
AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
if (message->IsOpaque())
accessControlStatus = OpaqueResource;
else if (message->IsSharedCrossOrigin())
accessControlStatus = SharableCrossOrigin;
ErrorEvent* event =
ErrorEvent::create(toCoreStringWithNullCheck(message->Get()),
std::move(location), &scriptState->world());
String messageForConsole = extractMessageForConsole(isolate, data);
if (!messageForConsole.isEmpty())
event->setUnsanitizedMessage("Uncaught " + messageForConsole);
// This method might be called while we're creating a new context. In this
// case, we avoid storing the exception object, as we can't create a wrapper
// during context creation.
// FIXME: Can we even get here during initialization now that we bail out when
// GetEntered returns an empty handle?
if (context->isDocument()) {
LocalFrame* frame = toDocument(context)->frame();
if (frame && frame->script().existingWindowProxy(scriptState->world())) {
V8ErrorHandler::storeExceptionOnErrorEventWrapper(
scriptState, event, data, scriptState->context()->Global());
}
}
if (scriptState->world().isPrivateScriptIsolatedWorld()) {
// We allow a private script to dispatch error events even in a
// EventDispatchForbiddenScope scope. Without having this ability, it's
// hard to debug the private script because syntax errors in the private
// script are not reported to console (the private script just crashes
// silently). Allowing error events in private scripts is safe because
// error events don't propagate to other isolated worlds (which means that
// the error events won't fire any event listeners in user's scripts).
EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;
context->dispatchErrorEvent(event, accessControlStatus);
} else {
context->dispatchErrorEvent(event, accessControlStatus);
}
}