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

Unified Diff: Source/modules/indexeddb/IDBRequest.cpp

Issue 243523003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/indexeddb/IDBRequest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/indexeddb/IDBRequest.cpp
diff --git a/Source/modules/indexeddb/IDBRequest.cpp b/Source/modules/indexeddb/IDBRequest.cpp
index 16992b32ade0174816e1f35db0e4ff8a6bd849fd..7f99e1d97a4222dcbb03bcbee6dae83a0fb6c6a1 100644
--- a/Source/modules/indexeddb/IDBRequest.cpp
+++ b/Source/modules/indexeddb/IDBRequest.cpp
@@ -31,9 +31,13 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ExceptionStatePlaceholder.h"
+#include "bindings/core/v8/ScriptCallStackFactory.h"
#include "bindings/modules/v8/IDBBindingUtilities.h"
#include "core/dom/ExecutionContext.h"
+#include "core/events/ErrorEvent.h"
#include "core/events/EventQueue.h"
+#include "core/inspector/ScriptCallFrame.h"
+#include "core/inspector/ScriptCallStack.h"
#include "modules/indexeddb/IDBCursorWithValue.h"
#include "modules/indexeddb/IDBDatabase.h"
#include "modules/indexeddb/IDBEventDispatcher.h"
@@ -72,6 +76,9 @@ IDBRequest::IDBRequest(ScriptState* scriptState, IDBAny* source, IDBTransaction*
, m_resultDirty(true)
{
ScriptWrappable::init(this);
+
+ m_creationStackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, false);
aandrey 2014/07/08 18:40:16 Probably we should collect the stacks only when De
+ ASSERT(m_creationStackTrace && m_creationStackTrace->size());
}
IDBRequest::~IDBRequest()
@@ -92,6 +99,7 @@ void IDBRequest::trace(Visitor* visitor)
visitor->trace(m_pendingCursor);
visitor->trace(m_cursorKey);
visitor->trace(m_cursorPrimaryKey);
+ visitor->trace(m_creationStackTrace);
EventTargetWithInlineData::trace(visitor);
}
@@ -493,6 +501,20 @@ bool IDBRequest::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded)
m_hasPendingActivity = false;
+ // Fire window.onerror (or the equivalent for workers) for errors that were not prevented.
+ if (!m_preventPropagation && dontPreventDefault && event->type() == EventTypeNames::error) {
+ const ScriptCallFrame& frame = m_creationStackTrace->at(0);
+ const AccessControlStatus corsStatus = NotSharableCrossOrigin;
+ RefPtrWillBeRawPtr<ErrorEvent> errorEvent;
+ if (executionContext()->shouldSanitizeScriptError(frame.sourceURL(), corsStatus)) {
+ errorEvent = ErrorEvent::createSanitizedError(&m_scriptState->world());
+ } else {
+ String message = m_error->name() + ": " + m_error->message();
+ errorEvent = ErrorEvent::create(message, frame.sourceURL(), frame.lineNumber(), frame.columnNumber(), &m_scriptState->world());
+ }
+ executionContext()->reportException(errorEvent, m_creationStackTrace, corsStatus);
+ }
+
return dontPreventDefault;
}
« no previous file with comments | « Source/modules/indexeddb/IDBRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698