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

Side by Side Diff: Source/core/dom/ExecutionContext.cpp

Issue 625943002: Catch uncaught promise rejections from V8 and log to console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Ensure all ActiveDOMObjects are suspended also newly created ones. 125 // Ensure all ActiveDOMObjects are suspended also newly created ones.
126 if (m_activeDOMObjectsAreSuspended) 126 if (m_activeDOMObjectsAreSuspended)
127 object->suspend(); 127 object->suspend();
128 } 128 }
129 129
130 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access ControlStatus corsStatus) 130 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access ControlStatus corsStatus)
131 { 131 {
132 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin); 132 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin);
133 } 133 }
134 134
135 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event, int scriptId, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, AccessControlS tatus corsStatus) 135 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event, int scriptId, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, AccessControlS tatus corsStatus, bool isPromiseReject)
136 { 136 {
137 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; 137 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event;
138 if (m_inDispatchErrorEvent) { 138 if (m_inDispatchErrorEvent) {
139 if (!m_pendingExceptions) 139 if (!m_pendingExceptions)
140 m_pendingExceptions = adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtr WillBeMember<PendingException> >()); 140 m_pendingExceptions = adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtr WillBeMember<PendingException> >());
141 m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(erro rEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId , errorEvent->filename(), callStack))); 141 m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(erro rEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId , errorEvent->filename(), callStack)));
142 return; 142 return;
143 } 143 }
144 144
145 // First report the original exception and only then all the nested ones. 145 // First report the original exception and only then all the nested ones.
146 if (!dispatchErrorEvent(errorEvent, corsStatus)) 146 // FIXME: Do not dispatch uncaught Promise rejects until the window.onerror spec is finalized.
147 if (isPromiseReject || !dispatchErrorEvent(errorEvent, corsStatus))
147 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); 148 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack);
148 149
149 if (!m_pendingExceptions) 150 if (!m_pendingExceptions)
150 return; 151 return;
151 152
152 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { 153 for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
153 PendingException* e = m_pendingExceptions->at(i).get(); 154 PendingException* e = m_pendingExceptions->at(i).get();
154 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack); 155 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack);
155 } 156 }
156 m_pendingExceptions.clear(); 157 m_pendingExceptions.clear();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void ExecutionContext::trace(Visitor* visitor) 268 void ExecutionContext::trace(Visitor* visitor)
268 { 269 {
269 #if ENABLE(OILPAN) 270 #if ENABLE(OILPAN)
270 visitor->trace(m_pendingExceptions); 271 visitor->trace(m_pendingExceptions);
271 HeapSupplementable<ExecutionContext>::trace(visitor); 272 HeapSupplementable<ExecutionContext>::trace(visitor);
272 #endif 273 #endif
273 LifecycleContext<ExecutionContext>::trace(visitor); 274 LifecycleContext<ExecutionContext>::trace(visitor);
274 } 275 }
275 276
276 } // namespace blink 277 } // namespace blink
OLDNEW
« Source/bindings/core/v8/V8Initializer.cpp ('K') | « Source/core/dom/ExecutionContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698