| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } // namespace | 196 } // namespace |
| 197 | 197 |
| 198 void V8Initializer::reportRejectedPromisesOnMainThread() | 198 void V8Initializer::reportRejectedPromisesOnMainThread() |
| 199 { | 199 { |
| 200 rejectedPromisesOnMainThread().processQueue(); | 200 rejectedPromisesOnMainThread().processQueue(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data) | 203 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data) |
| 204 { | 204 { |
| 205 ASSERT(isMainThread()); | 205 ASSERT(isMainThread()); |
| 206 if (data.GetEvent() == v8::kPromiseHandlerAddedAfterReject) { | 206 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) |
| 207 rejectedPromisesOnMainThread().handlerAdded(data); | |
| 208 return; | 207 return; |
| 209 } | |
| 210 | |
| 211 ASSERT(data.GetEvent() == v8::kPromiseRejectWithNoHandler); | |
| 212 | |
| 213 v8::Handle<v8::Promise> promise = data.GetPromise(); | 208 v8::Handle<v8::Promise> promise = data.GetPromise(); |
| 214 | 209 |
| 215 v8::Isolate* isolate = promise->GetIsolate(); | 210 v8::Isolate* isolate = promise->GetIsolate(); |
| 216 // There is no entered window during microtask callbacks from V8, | 211 // There is no entered window during microtask callbacks from V8, |
| 217 // thus we call toDOMWindow() instead of enteredDOMWindow(). | 212 // thus we call toDOMWindow() instead of enteredDOMWindow(). |
| 218 LocalDOMWindow* window = currentDOMWindow(isolate); | 213 LocalDOMWindow* window = currentDOMWindow(isolate); |
| 219 if (!window || !window->isCurrentlyDisplayedInFrame()) | 214 if (!window || !window->isCurrentlyDisplayedInFrame()) |
| 220 return; | 215 return; |
| 221 | 216 |
| 222 v8::Handle<v8::Value> exception = data.GetValue(); | 217 v8::Handle<v8::Value> exception = data.GetValue(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 247 } else if (!exception.IsEmpty() && exception->IsInt32()) { | 242 } else if (!exception.IsEmpty() && exception->IsInt32()) { |
| 248 // For Smi's the message would be empty. | 243 // For Smi's the message would be empty. |
| 249 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()-
>Value()); | 244 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()-
>Value()); |
| 250 } | 245 } |
| 251 | 246 |
| 252 String messageForConsole = extractMessageForConsole(isolate, data.GetValue()
); | 247 String messageForConsole = extractMessageForConsole(isolate, data.GetValue()
); |
| 253 if (!messageForConsole.isEmpty()) | 248 if (!messageForConsole.isEmpty()) |
| 254 errorMessage = "Uncaught " + messageForConsole; | 249 errorMessage = "Uncaught " + messageForConsole; |
| 255 | 250 |
| 256 ScriptState* scriptState = ScriptState::current(isolate); | 251 ScriptState* scriptState = ScriptState::current(isolate); |
| 257 rejectedPromisesOnMainThread().rejectedWithNoHandler(scriptState, data, erro
rMessage, resourceName, scriptId, lineNumber, columnNumber, callStack); | 252 rejectedPromisesOnMainThread().add(scriptState, data, errorMessage, resource
Name, scriptId, lineNumber, columnNumber, callStack); |
| 258 } | 253 } |
| 259 | 254 |
| 260 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data) | 255 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data) |
| 261 { | 256 { |
| 257 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) |
| 258 return; |
| 259 |
| 262 v8::Handle<v8::Promise> promise = data.GetPromise(); | 260 v8::Handle<v8::Promise> promise = data.GetPromise(); |
| 263 | 261 |
| 264 // Bail out if called during context initialization. | 262 // Bail out if called during context initialization. |
| 265 v8::Isolate* isolate = promise->GetIsolate(); | 263 v8::Isolate* isolate = promise->GetIsolate(); |
| 266 ScriptState* scriptState = ScriptState::current(isolate); | 264 ScriptState* scriptState = ScriptState::current(isolate); |
| 267 if (!scriptState->contextIsValid()) | 265 if (!scriptState->contextIsValid()) |
| 268 return; | 266 return; |
| 269 | 267 |
| 270 ExecutionContext* executionContext = scriptState->executionContext(); | 268 ExecutionContext* executionContext = scriptState->executionContext(); |
| 271 if (!executionContext) | 269 if (!executionContext) |
| 272 return; | 270 return; |
| 273 | 271 |
| 274 ASSERT(executionContext->isWorkerGlobalScope()); | 272 ASSERT(executionContext->isWorkerGlobalScope()); |
| 275 WorkerScriptController* scriptController = toWorkerGlobalScope(executionCont
ext)->script(); | 273 WorkerScriptController* scriptController = toWorkerGlobalScope(executionCont
ext)->script(); |
| 276 ASSERT(scriptController); | 274 ASSERT(scriptController); |
| 277 | 275 |
| 278 if (data.GetEvent() == v8::kPromiseHandlerAddedAfterReject) { | |
| 279 scriptController->rejectedPromises()->handlerAdded(data); | |
| 280 return; | |
| 281 } | |
| 282 | |
| 283 ASSERT(data.GetEvent() == v8::kPromiseRejectWithNoHandler); | |
| 284 | |
| 285 int scriptId = 0; | 276 int scriptId = 0; |
| 286 int lineNumber = 0; | 277 int lineNumber = 0; |
| 287 int columnNumber = 0; | 278 int columnNumber = 0; |
| 288 String resourceName; | 279 String resourceName; |
| 289 String errorMessage; | 280 String errorMessage; |
| 290 | 281 |
| 291 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue
()); | 282 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue
()); |
| 292 if (!message.IsEmpty()) { | 283 if (!message.IsEmpty()) { |
| 293 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin
().ResourceName()); | 284 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin
().ResourceName()); |
| 294 scriptId = message->GetScriptOrigin().ScriptID()->Value(); | 285 scriptId = message->GetScriptOrigin().ScriptID()->Value(); |
| 295 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) | 286 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) |
| 296 && v8Call(message->GetStartColumn(scriptState->context()), columnNum
ber)) | 287 && v8Call(message->GetStartColumn(scriptState->context()), columnNum
ber)) |
| 297 ++columnNumber; | 288 ++columnNumber; |
| 298 // message->Get() can be empty here. https://crbug.com/450330 | 289 // message->Get() can be empty here. https://crbug.com/450330 |
| 299 errorMessage = toCoreStringWithNullCheck(message->Get()); | 290 errorMessage = toCoreStringWithNullCheck(message->Get()); |
| 300 } | 291 } |
| 301 scriptController->rejectedPromises()->rejectedWithNoHandler(scriptState, dat
a, errorMessage, resourceName, scriptId, lineNumber, columnNumber, nullptr); | 292 scriptController->rejectedPromises()->add(scriptState, data, errorMessage, r
esourceName, scriptId, lineNumber, columnNumber, nullptr); |
| 302 } | 293 } |
| 303 | 294 |
| 304 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 295 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
| 305 { | 296 { |
| 306 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 297 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 307 Frame* target = findFrame(isolate, host, data); | 298 Frame* target = findFrame(isolate, host, data); |
| 308 if (!target) | 299 if (!target) |
| 309 return; | 300 return; |
| 310 DOMWindow* targetWindow = target->domWindow(); | 301 DOMWindow* targetWindow = target->domWindow(); |
| 311 | 302 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 461 |
| 471 v8::V8::AddMessageListener(messageHandlerInWorker); | 462 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 472 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 463 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 473 | 464 |
| 474 uint32_t here; | 465 uint32_t here; |
| 475 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 466 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
| 476 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 467 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 477 } | 468 } |
| 478 | 469 |
| 479 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |