| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 ExecutionContext* context = scriptState->getExecutionContext(); | 122 ExecutionContext* context = scriptState->getExecutionContext(); |
| 123 OwnPtr<SourceLocation> location = SourceLocation::fromMessage(isolate, messa
ge, context); | 123 OwnPtr<SourceLocation> location = SourceLocation::fromMessage(isolate, messa
ge, context); |
| 124 | 124 |
| 125 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; | 125 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; |
| 126 if (message->IsOpaque()) | 126 if (message->IsOpaque()) |
| 127 accessControlStatus = OpaqueResource; | 127 accessControlStatus = OpaqueResource; |
| 128 else if (message->IsSharedCrossOrigin()) | 128 else if (message->IsSharedCrossOrigin()) |
| 129 accessControlStatus = SharableCrossOrigin; | 129 accessControlStatus = SharableCrossOrigin; |
| 130 | 130 |
| 131 ErrorEvent* event = ErrorEvent::create(toCoreStringWithNullCheck(message->Ge
t()), location->url(), location->lineNumber(), location->columnNumber(), &script
State->world()); | 131 ErrorEvent* event = ErrorEvent::create(toCoreStringWithNullCheck(message->Ge
t()), std::move(location), &scriptState->world()); |
| 132 | 132 |
| 133 String messageForConsole = extractMessageForConsole(isolate, data); | 133 String messageForConsole = extractMessageForConsole(isolate, data); |
| 134 if (!messageForConsole.isEmpty()) | 134 if (!messageForConsole.isEmpty()) |
| 135 event->setUnsanitizedMessage("Uncaught " + messageForConsole); | 135 event->setUnsanitizedMessage("Uncaught " + messageForConsole); |
| 136 | 136 |
| 137 // This method might be called while we're creating a new context. In this c
ase, we | 137 // This method might be called while we're creating a new context. In this c
ase, we |
| 138 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. | 138 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. |
| 139 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? | 139 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? |
| 140 if (context->isDocument()) { | 140 if (context->isDocument()) { |
| 141 LocalFrame* frame = toDocument(context)->frame(); | 141 LocalFrame* frame = toDocument(context)->frame(); |
| 142 if (frame && frame->script().existingWindowProxy(scriptState->world()))
{ | 142 if (frame && frame->script().existingWindowProxy(scriptState->world()))
{ |
| 143 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event
, data, scriptState->context()->Global()); | 143 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event
, data, scriptState->context()->Global()); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 if (scriptState->world().isPrivateScriptIsolatedWorld()) { | 147 if (scriptState->world().isPrivateScriptIsolatedWorld()) { |
| 148 // We allow a private script to dispatch error events even in a EventDis
patchForbiddenScope scope. | 148 // We allow a private script to dispatch error events even in a EventDis
patchForbiddenScope scope. |
| 149 // Without having this ability, it's hard to debug the private script be
cause syntax errors | 149 // Without having this ability, it's hard to debug the private script be
cause syntax errors |
| 150 // in the private script are not reported to console (the private script
just crashes silently). | 150 // in the private script are not reported to console (the private script
just crashes silently). |
| 151 // Allowing error events in private scripts is safe because error events
don't propagate to | 151 // Allowing error events in private scripts is safe because error events
don't propagate to |
| 152 // other isolated worlds (which means that the error events won't fire a
ny event listeners | 152 // other isolated worlds (which means that the error events won't fire a
ny event listeners |
| 153 // in user's scripts). | 153 // in user's scripts). |
| 154 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; | 154 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
| 155 context->reportException(event, std::move(location), accessControlStatus
); | 155 context->reportException(event, accessControlStatus); |
| 156 } else { | 156 } else { |
| 157 context->reportException(event, std::move(location), accessControlStatus
); | 157 context->reportException(event, accessControlStatus); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 namespace { | 161 namespace { |
| 162 | 162 |
| 163 static RejectedPromises& rejectedPromisesOnMainThread() | 163 static RejectedPromises& rejectedPromisesOnMainThread() |
| 164 { | 164 { |
| 165 ASSERT(isMainThread()); | 165 ASSERT(isMainThread()); |
| 166 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, (RejectedPro
mises::create())); | 166 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, (RejectedPro
mises::create())); |
| 167 return *rejectedPromises; | 167 return *rejectedPromises; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 // Exceptions that occur in error handler should be ignored since in that ca
se | 394 // Exceptions that occur in error handler should be ignored since in that ca
se |
| 395 // WorkerGlobalScope::reportException will send the exception to the worker
object. | 395 // WorkerGlobalScope::reportException will send the exception to the worker
object. |
| 396 if (perIsolateData->isReportingException()) | 396 if (perIsolateData->isReportingException()) |
| 397 return; | 397 return; |
| 398 | 398 |
| 399 perIsolateData->setReportingException(true); | 399 perIsolateData->setReportingException(true); |
| 400 | 400 |
| 401 ExecutionContext* context = scriptState->getExecutionContext(); | 401 ExecutionContext* context = scriptState->getExecutionContext(); |
| 402 OwnPtr<SourceLocation> location = SourceLocation::fromMessage(isolate, messa
ge, context); | 402 OwnPtr<SourceLocation> location = SourceLocation::fromMessage(isolate, messa
ge, context); |
| 403 ErrorEvent* event = ErrorEvent::create(toCoreStringWithNullCheck(message->Ge
t()), location->url(), location->lineNumber(), location->columnNumber(), &script
State->world()); | 403 ErrorEvent* event = ErrorEvent::create(toCoreStringWithNullCheck(message->Ge
t()), std::move(location), &scriptState->world()); |
| 404 | 404 |
| 405 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; | 405 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; |
| 406 | 406 |
| 407 // If execution termination has been triggered as part of constructing | 407 // If execution termination has been triggered as part of constructing |
| 408 // the error event from the v8::Message, quietly leave. | 408 // the error event from the v8::Message, quietly leave. |
| 409 if (!isolate->IsExecutionTerminating()) { | 409 if (!isolate->IsExecutionTerminating()) { |
| 410 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event, da
ta, scriptState->context()->Global()); | 410 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event, da
ta, scriptState->context()->Global()); |
| 411 scriptState->getExecutionContext()->reportException(event, std::move(loc
ation), corsStatus); | 411 scriptState->getExecutionContext()->reportException(event, corsStatus); |
| 412 } | 412 } |
| 413 | 413 |
| 414 perIsolateData->setReportingException(false); | 414 perIsolateData->setReportingException(false); |
| 415 } | 415 } |
| 416 | 416 |
| 417 static const int kWorkerMaxStackSize = 500 * 1024; | 417 static const int kWorkerMaxStackSize = 500 * 1024; |
| 418 | 418 |
| 419 // This function uses a local stack variable to determine the isolate's stack li
mit. AddressSanitizer may | 419 // This function uses a local stack variable to determine the isolate's stack li
mit. AddressSanitizer may |
| 420 // relocate that local variable to a fake stack, which may lead to problems duri
ng JavaScript execution. | 420 // relocate that local variable to a fake stack, which may lead to problems duri
ng JavaScript execution. |
| 421 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker(). | 421 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker(). |
| 422 NO_SANITIZE_ADDRESS | 422 NO_SANITIZE_ADDRESS |
| 423 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 423 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
| 424 { | 424 { |
| 425 initializeV8Common(isolate); | 425 initializeV8Common(isolate); |
| 426 | 426 |
| 427 isolate->AddMessageListener(messageHandlerInWorker); | 427 isolate->AddMessageListener(messageHandlerInWorker); |
| 428 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 428 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
| 429 | 429 |
| 430 uint32_t here; | 430 uint32_t here; |
| 431 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 431 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
| 432 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 432 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace blink | 435 } // namespace blink |
| OLD | NEW |