Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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/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
| |
| 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 && frame->script().existingWindowProxy(errorEventScriptState->worl d())) { |
| 164 V8ErrorHandler::storeExceptionOnErrorEventWrapper( | 173 V8ErrorHandler::storeExceptionOnErrorEventWrapper( |
| 165 scriptState, event, data, scriptState->context()->Global()); | 174 errorEventScriptState, event, data, errorEventScriptState->context()-> Global()); |
| 166 } | 175 } |
| 167 } | 176 } |
| 168 | 177 |
| 169 if (scriptState->world().isPrivateScriptIsolatedWorld()) { | 178 if (errorEventScriptState->world().isPrivateScriptIsolatedWorld()) { |
| 170 // We allow a private script to dispatch error events even in a | 179 // We allow a private script to dispatch error events even in a |
| 171 // EventDispatchForbiddenScope scope. Without having this ability, it's | 180 // EventDispatchForbiddenScope scope. Without having this ability, it's |
| 172 // hard to debug the private script because syntax errors in the private | 181 // hard to debug the private script because syntax errors in the private |
| 173 // script are not reported to console (the private script just crashes | 182 // script are not reported to console (the private script just crashes |
| 174 // silently). Allowing error events in private scripts is safe because | 183 // silently). Allowing error events in private scripts is safe because |
| 175 // error events don't propagate to other isolated worlds (which means that | 184 // 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). | 185 // the error events won't fire any event listeners in user's scripts). |
| 177 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; | 186 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
| 178 context->dispatchErrorEvent(event, accessControlStatus); | 187 errorEventContext->dispatchErrorEvent(event, accessControlStatus); |
| 179 } else { | 188 } else { |
| 180 context->dispatchErrorEvent(event, accessControlStatus); | 189 errorEventContext->dispatchErrorEvent(event, accessControlStatus); |
| 181 } | 190 } |
| 182 } | 191 } |
| 183 | 192 |
| 184 namespace { | 193 namespace { |
| 185 | 194 |
| 186 static RejectedPromises& rejectedPromisesOnMainThread() { | 195 static RejectedPromises& rejectedPromisesOnMainThread() { |
| 187 ASSERT(isMainThread()); | 196 ASSERT(isMainThread()); |
| 188 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, | 197 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, |
| 189 (RejectedPromises::create())); | 198 (RejectedPromises::create())); |
| 190 return *rejectedPromises; | 199 return *rejectedPromises; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 isolate->AddMessageListener(messageHandlerInWorker); | 510 isolate->AddMessageListener(messageHandlerInWorker); |
| 502 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 511 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
| 503 | 512 |
| 504 uint32_t here; | 513 uint32_t here; |
| 505 isolate->SetStackLimit(reinterpret_cast<uintptr_t>( | 514 isolate->SetStackLimit(reinterpret_cast<uintptr_t>( |
| 506 &here - kWorkerMaxStackSize / sizeof(uint32_t*))); | 515 &here - kWorkerMaxStackSize / sizeof(uint32_t*))); |
| 507 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 516 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 508 } | 517 } |
| 509 | 518 |
| 510 } // namespace blink | 519 } // namespace blink |
| OLD | NEW |