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

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

Issue 2420223002: Dispatching errors across iframes don't match webplatform tests
Patch Set: Added nested errors test and scope class." Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 ExecutionContext* context = scriptState->getExecutionContext(); 138 ExecutionContext* context = scriptState->getExecutionContext();
139 std::unique_ptr<SourceLocation> location = 139 std::unique_ptr<SourceLocation> location =
140 SourceLocation::fromMessage(isolate, message, context); 140 SourceLocation::fromMessage(isolate, message, context);
141 141
142 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; 142 AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
143 if (message->IsOpaque()) 143 if (message->IsOpaque())
144 accessControlStatus = OpaqueResource; 144 accessControlStatus = OpaqueResource;
145 else if (message->IsSharedCrossOrigin()) 145 else if (message->IsSharedCrossOrigin())
146 accessControlStatus = SharableCrossOrigin; 146 accessControlStatus = SharableCrossOrigin;
147 147
148 ScriptState* errorEventScriptState = context->errorEventScriptState();
haraken 2016/10/27 14:56:27 Why do you need to associate the ScriptStateForErr
149 if (!errorEventScriptState)
150 errorEventScriptState = scriptState;
151
152 if (!errorEventScriptState->contextIsValid())
153 return;
154
155 ExecutionContext* errorEventContext =
156 errorEventScriptState->getExecutionContext();
148 ErrorEvent* event = 157 ErrorEvent* event =
149 ErrorEvent::create(toCoreStringWithNullCheck(message->Get()), 158 ErrorEvent::create(toCoreStringWithNullCheck(message->Get()),
150 std::move(location), &scriptState->world()); 159 std::move(location), &errorEventScriptState->world());
151 160
152 String messageForConsole = extractMessageForConsole(isolate, data); 161 String messageForConsole = extractMessageForConsole(isolate, data);
153 if (!messageForConsole.isEmpty()) 162 if (!messageForConsole.isEmpty())
154 event->setUnsanitizedMessage("Uncaught " + messageForConsole); 163 event->setUnsanitizedMessage("Uncaught " + messageForConsole);
155 164
156 // This method might be called while we're creating a new context. In this 165 // This method might be called while we're creating a new context. In this
157 // case, we avoid storing the exception object, as we can't create a wrapper 166 // case, we avoid storing the exception object, as we can't create a wrapper
158 // during context creation. 167 // during context creation.
159 // FIXME: Can we even get here during initialization now that we bail out when 168 // FIXME: Can we even get here during initialization now that we bail out when
160 // GetEntered returns an empty handle? 169 // GetEntered returns an empty handle?
161 if (context->isDocument()) { 170 if (errorEventContext->isDocument()) {
162 LocalFrame* frame = toDocument(context)->frame(); 171 LocalFrame* frame = toDocument(errorEventContext)->frame();
163 if (frame && frame->script().existingWindowProxy(scriptState->world())) { 172 if (frame &&
173 frame->script().existingWindowProxy(errorEventScriptState->world())) {
164 V8ErrorHandler::storeExceptionOnErrorEventWrapper( 174 V8ErrorHandler::storeExceptionOnErrorEventWrapper(
165 scriptState, event, data, scriptState->context()->Global()); 175 errorEventScriptState, event, data,
176 errorEventScriptState->context()->Global());
166 } 177 }
167 } 178 }
168 179
169 if (scriptState->world().isPrivateScriptIsolatedWorld()) { 180 if (errorEventScriptState->world().isPrivateScriptIsolatedWorld()) {
170 // We allow a private script to dispatch error events even in a 181 // We allow a private script to dispatch error events even in a
171 // EventDispatchForbiddenScope scope. Without having this ability, it's 182 // EventDispatchForbiddenScope scope. Without having this ability, it's
172 // hard to debug the private script because syntax errors in the private 183 // hard to debug the private script because syntax errors in the private
173 // script are not reported to console (the private script just crashes 184 // script are not reported to console (the private script just crashes
174 // silently). Allowing error events in private scripts is safe because 185 // silently). Allowing error events in private scripts is safe because
175 // error events don't propagate to other isolated worlds (which means that 186 // error events don't propagate to other isolated worlds (which means that
176 // the error events won't fire any event listeners in user's scripts). 187 // the error events won't fire any event listeners in user's scripts).
177 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; 188 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;
178 context->dispatchErrorEvent(event, accessControlStatus); 189 errorEventContext->dispatchErrorEvent(event, accessControlStatus);
179 } else { 190 } else {
180 context->dispatchErrorEvent(event, accessControlStatus); 191 errorEventContext->dispatchErrorEvent(event, accessControlStatus);
181 } 192 }
182 } 193 }
183 194
184 namespace { 195 namespace {
185 196
186 static RejectedPromises& rejectedPromisesOnMainThread() { 197 static RejectedPromises& rejectedPromisesOnMainThread() {
187 ASSERT(isMainThread()); 198 ASSERT(isMainThread());
188 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, 199 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises,
189 (RejectedPromises::create())); 200 (RejectedPromises::create()));
190 return *rejectedPromises; 201 return *rejectedPromises;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 isolate->AddMessageListener(messageHandlerInWorker); 512 isolate->AddMessageListener(messageHandlerInWorker);
502 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); 513 isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
503 514
504 uint32_t here; 515 uint32_t here;
505 isolate->SetStackLimit(reinterpret_cast<uintptr_t>( 516 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(
506 &here - kWorkerMaxStackSize / sizeof(uint32_t*))); 517 &here - kWorkerMaxStackSize / sizeof(uint32_t*)));
507 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 518 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
508 } 519 }
509 520
510 } // namespace blink 521 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8EventListener.cpp ('k') | third_party/WebKit/Source/core/dom/ExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698