| Index: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| index 511642a838a24ce41f442df29f764fa13a5f3f69..c15b2d660aea49d265bc9b8ae77eb62a08e5ef46 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| @@ -145,9 +145,18 @@ static void messageHandlerInMainThread(v8::Local<v8::Message> message,
|
| else if (message->IsSharedCrossOrigin())
|
| accessControlStatus = SharableCrossOrigin;
|
|
|
| + ScriptState* errorEventScriptState = scriptState;
|
| + if (ScriptStateForErrorEvent::current())
|
| + errorEventScriptState = ScriptStateForErrorEvent::current()->scriptState();
|
| +
|
| + if (!errorEventScriptState->contextIsValid())
|
| + return;
|
| +
|
| + ExecutionContext* errorEventContext =
|
| + errorEventScriptState->getExecutionContext();
|
| ErrorEvent* event =
|
| ErrorEvent::create(toCoreStringWithNullCheck(message->Get()),
|
| - std::move(location), &scriptState->world());
|
| + std::move(location), &errorEventScriptState->world());
|
|
|
| String messageForConsole = extractMessageForConsole(isolate, data);
|
| if (!messageForConsole.isEmpty())
|
| @@ -158,15 +167,17 @@ static void messageHandlerInMainThread(v8::Local<v8::Message> message,
|
| // 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())) {
|
| + if (errorEventContext->isDocument()) {
|
| + LocalFrame* frame = toDocument(errorEventContext)->frame();
|
| + if (frame &&
|
| + frame->script().existingWindowProxy(errorEventScriptState->world())) {
|
| V8ErrorHandler::storeExceptionOnErrorEventWrapper(
|
| - scriptState, event, data, scriptState->context()->Global());
|
| + errorEventScriptState, event, data,
|
| + errorEventScriptState->context()->Global());
|
| }
|
| }
|
|
|
| - if (scriptState->world().isPrivateScriptIsolatedWorld()) {
|
| + if (errorEventScriptState->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
|
| @@ -175,9 +186,9 @@ static void messageHandlerInMainThread(v8::Local<v8::Message> message,
|
| // 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);
|
| + errorEventContext->dispatchErrorEvent(event, accessControlStatus);
|
| } else {
|
| - context->dispatchErrorEvent(event, accessControlStatus);
|
| + errorEventContext->dispatchErrorEvent(event, accessControlStatus);
|
| }
|
| }
|
|
|
|
|