| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 else if (message->IsSharedCrossOrigin()) | 151 else if (message->IsSharedCrossOrigin()) |
| 152 accessControlStatus = SharableCrossOrigin; | 152 accessControlStatus = SharableCrossOrigin; |
| 153 | 153 |
| 154 ScriptState* scriptState = ScriptState::current(isolate); | 154 ScriptState* scriptState = ScriptState::current(isolate); |
| 155 String errorMessage = toCoreStringWithNullCheck(message->Get()); | 155 String errorMessage = toCoreStringWithNullCheck(message->Get()); |
| 156 int lineNumber = 0; | 156 int lineNumber = 0; |
| 157 int columnNumber = 0; | 157 int columnNumber = 0; |
| 158 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) | 158 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) |
| 159 && v8Call(message->GetStartColumn(scriptState->context()), columnNumber)
) | 159 && v8Call(message->GetStartColumn(scriptState->context()), columnNumber)
) |
| 160 ++columnNumber; | 160 ++columnNumber; |
| 161 RawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resourceName, li
neNumber, columnNumber, &scriptState->world()); | 161 ErrorEvent* event = ErrorEvent::create(errorMessage, resourceName, lineNumbe
r, columnNumber, &scriptState->world()); |
| 162 | 162 |
| 163 String messageForConsole = extractMessageForConsole(isolate, data); | 163 String messageForConsole = extractMessageForConsole(isolate, data); |
| 164 if (!messageForConsole.isEmpty()) | 164 if (!messageForConsole.isEmpty()) |
| 165 event->setUnsanitizedMessage("Uncaught " + messageForConsole); | 165 event->setUnsanitizedMessage("Uncaught " + messageForConsole); |
| 166 | 166 |
| 167 // This method might be called while we're creating a new context. In this c
ase, we | 167 // This method might be called while we're creating a new context. In this c
ase, we |
| 168 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. | 168 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. |
| 169 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? | 169 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? |
| 170 LocalFrame* frame = enteredWindow->document()->frame(); | 170 LocalFrame* frame = enteredWindow->document()->frame(); |
| 171 if (frame && frame->script().existingWindowProxy(scriptState->world())) { | 171 if (frame && frame->script().existingWindowProxy(scriptState->world())) { |
| 172 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event.get
(), data, scriptState->context()->Global()); | 172 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event, da
ta, scriptState->context()->Global()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 if (scriptState->world().isPrivateScriptIsolatedWorld()) { | 175 if (scriptState->world().isPrivateScriptIsolatedWorld()) { |
| 176 // We allow a private script to dispatch error events even in a EventDis
patchForbiddenScope scope. | 176 // We allow a private script to dispatch error events even in a EventDis
patchForbiddenScope scope. |
| 177 // Without having this ability, it's hard to debug the private script be
cause syntax errors | 177 // Without having this ability, it's hard to debug the private script be
cause syntax errors |
| 178 // in the private script are not reported to console (the private script
just crashes silently). | 178 // in the private script are not reported to console (the private script
just crashes silently). |
| 179 // Allowing error events in private scripts is safe because error events
don't propagate to | 179 // Allowing error events in private scripts is safe because error events
don't propagate to |
| 180 // other isolated worlds (which means that the error events won't fire a
ny event listeners | 180 // other isolated worlds (which means that the error events won't fire a
ny event listeners |
| 181 // in user's scripts). | 181 // in user's scripts). |
| 182 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; | 182 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
| 183 enteredWindow->document()->reportException(event.release(), scriptId, ca
llStack, accessControlStatus); | 183 enteredWindow->document()->reportException(event, scriptId, callStack, a
ccessControlStatus); |
| 184 } else { | 184 } else { |
| 185 enteredWindow->document()->reportException(event.release(), scriptId, ca
llStack, accessControlStatus); | 185 enteredWindow->document()->reportException(event, scriptId, callStack, a
ccessControlStatus); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 namespace { | 189 namespace { |
| 190 | 190 |
| 191 static RejectedPromises& rejectedPromisesOnMainThread() | 191 static RejectedPromises& rejectedPromisesOnMainThread() |
| 192 { | 192 { |
| 193 ASSERT(isMainThread()); | 193 ASSERT(isMainThread()); |
| 194 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, (RejectedPro
mises::create())); | 194 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, (RejectedPro
mises::create())); |
| 195 return *rejectedPromises; | 195 return *rejectedPromises; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 String errorMessage = toCoreStringWithNullCheck(message->Get()); | 424 String errorMessage = toCoreStringWithNullCheck(message->Get()); |
| 425 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); | 425 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); |
| 426 int scriptId = 0; | 426 int scriptId = 0; |
| 427 RefPtr<ScriptCallStack> callStack = extractCallStack(isolate, message, &
scriptId); | 427 RefPtr<ScriptCallStack> callStack = extractCallStack(isolate, message, &
scriptId); |
| 428 | 428 |
| 429 int lineNumber = 0; | 429 int lineNumber = 0; |
| 430 int columnNumber = 0; | 430 int columnNumber = 0; |
| 431 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) | 431 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) |
| 432 && v8Call(message->GetStartColumn(scriptState->context()), columnNum
ber)) | 432 && v8Call(message->GetStartColumn(scriptState->context()), columnNum
ber)) |
| 433 ++columnNumber; | 433 ++columnNumber; |
| 434 RawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, l
ineNumber, columnNumber, &DOMWrapperWorld::current(isolate)); | 434 ErrorEvent* event = ErrorEvent::create(errorMessage, sourceURL, lineNumb
er, columnNumber, &DOMWrapperWorld::current(isolate)); |
| 435 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 435 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
| 436 | 436 |
| 437 // If execution termination has been triggered as part of constructing | 437 // If execution termination has been triggered as part of constructing |
| 438 // the error event from the v8::Message, quietly leave. | 438 // the error event from the v8::Message, quietly leave. |
| 439 if (!isolate->IsExecutionTerminating()) { | 439 if (!isolate->IsExecutionTerminating()) { |
| 440 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event
.get(), data, scriptState->context()->Global()); | 440 V8ErrorHandler::storeExceptionOnErrorEventWrapper(scriptState, event
, data, scriptState->context()->Global()); |
| 441 context->reportException(event.release(), scriptId, callStack, corsS
tatus); | 441 context->reportException(event, scriptId, callStack, corsStatus); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 perIsolateData->setReportingException(false); | 445 perIsolateData->setReportingException(false); |
| 446 } | 446 } |
| 447 | 447 |
| 448 static const int kWorkerMaxStackSize = 500 * 1024; | 448 static const int kWorkerMaxStackSize = 500 * 1024; |
| 449 | 449 |
| 450 // This function uses a local stack variable to determine the isolate's stack li
mit. AddressSanitizer may | 450 // This function uses a local stack variable to determine the isolate's stack li
mit. AddressSanitizer may |
| 451 // relocate that local variable to a fake stack, which may lead to problems duri
ng JavaScript execution. | 451 // relocate that local variable to a fake stack, which may lead to problems duri
ng JavaScript execution. |
| 452 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker(). | 452 // Therefore we disable AddressSanitizer for V8Initializer::initializeWorker(). |
| 453 NO_SANITIZE_ADDRESS | 453 NO_SANITIZE_ADDRESS |
| 454 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 454 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
| 455 { | 455 { |
| 456 initializeV8Common(isolate); | 456 initializeV8Common(isolate); |
| 457 | 457 |
| 458 isolate->AddMessageListener(messageHandlerInWorker); | 458 isolate->AddMessageListener(messageHandlerInWorker); |
| 459 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 459 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
| 460 | 460 |
| 461 uint32_t here; | 461 uint32_t here; |
| 462 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 462 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
| 463 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 463 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace blink | 466 } // namespace blink |
| OLD | NEW |