Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp

Issue 2420223002: Dispatching errors across iframes don't match webplatform tests
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0a633559d9f00c1d39acb53c21107ae4c9141459 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 = context->errorEventScriptState();
haraken 2016/10/15 02:25:25 Add a comment about what this is doing.
dominicc (has gone to gerrit) 2016/10/16 08:45:57 This could be simpler if the errorEventScriptState
+ if (!errorEventScriptState)
+ errorEventScriptState = 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,15 @@ 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 +184,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);
}
}

Powered by Google App Engine
This is Rietveld 408576698