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

Side by Side Diff: Source/bindings/core/v8/WorkerScriptController.cpp

Issue 625943002: Catch uncaught promise rejections from V8 and log to console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #include "bindings/core/v8/V8GCController.h" 39 #include "bindings/core/v8/V8GCController.h"
40 #include "bindings/core/v8/V8Initializer.h" 40 #include "bindings/core/v8/V8Initializer.h"
41 #include "bindings/core/v8/V8ObjectConstructor.h" 41 #include "bindings/core/v8/V8ObjectConstructor.h"
42 #include "bindings/core/v8/V8ScriptRunner.h" 42 #include "bindings/core/v8/V8ScriptRunner.h"
43 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" 43 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h"
44 #include "bindings/core/v8/V8WorkerGlobalScope.h" 44 #include "bindings/core/v8/V8WorkerGlobalScope.h"
45 #include "bindings/core/v8/WrapperTypeInfo.h" 45 #include "bindings/core/v8/WrapperTypeInfo.h"
46 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h" 46 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h"
47 #include "core/events/ErrorEvent.h" 47 #include "core/events/ErrorEvent.h"
48 #include "core/frame/DOMTimer.h" 48 #include "core/frame/DOMTimer.h"
49 #include "core/inspector/ScriptArguments.h"
49 #include "core/inspector/ScriptCallStack.h" 50 #include "core/inspector/ScriptCallStack.h"
50 #include "core/workers/SharedWorkerGlobalScope.h" 51 #include "core/workers/SharedWorkerGlobalScope.h"
51 #include "core/workers/WorkerGlobalScope.h" 52 #include "core/workers/WorkerGlobalScope.h"
52 #include "core/workers/WorkerObjectProxy.h" 53 #include "core/workers/WorkerObjectProxy.h"
53 #include "core/workers/WorkerThread.h" 54 #include "core/workers/WorkerThread.h"
54 #include "platform/heap/ThreadState.h" 55 #include "platform/heap/ThreadState.h"
55 #include "public/platform/Platform.h" 56 #include "public/platform/Platform.h"
56 #include "public/platform/WebWorkerRunLoop.h" 57 #include "public/platform/WebWorkerRunLoop.h"
57 #include <v8.h> 58 #include <v8.h>
58 59
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 else 258 else
258 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get()); 259 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get());
259 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Global(), m_isolate); 260 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Global(), m_isolate);
260 } else { 261 } else {
261 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin)); 262 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin));
262 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; 263 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr;
263 if (state.m_errorEventFromImportedScript) 264 if (state.m_errorEventFromImportedScript)
264 event = state.m_errorEventFromImportedScript.release(); 265 event = state.m_errorEventFromImportedScript.release();
265 else 266 else
266 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); 267 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get());
267 m_workerGlobalScope.reportException(event, 0, nullptr, NotSharableCr ossOrigin); 268 m_workerGlobalScope.reportException(event, 0, nullptr, nullptr, NotS harableCrossOrigin);
268 } 269 }
269 } 270 }
270 } 271 }
271 272
272 void WorkerScriptController::scheduleExecutionTermination() 273 void WorkerScriptController::scheduleExecutionTermination()
273 { 274 {
274 // The mutex provides a memory barrier to ensure that once 275 // The mutex provides a memory barrier to ensure that once
275 // termination is scheduled, isExecutionTerminating will 276 // termination is scheduled, isExecutionTerminating will
276 // accurately reflect that state when called from another thread. 277 // accurately reflect that state when called from another thread.
277 { 278 {
(...skipping 29 matching lines...) Expand all
307 308
308 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) 309 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState)
309 { 310 {
310 const String& errorMessage = errorEvent->message(); 311 const String& errorMessage = errorEvent->message();
311 if (m_globalScopeExecutionState) 312 if (m_globalScopeExecutionState)
312 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent ; 313 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent ;
313 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(error Message, m_isolate)); 314 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(error Message, m_isolate));
314 } 315 }
315 316
316 } // namespace blink 317 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698