Index: third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
index 173142687331861db12e562b069578cf5fe4eb33..07df3b5b31c30f7a43cbf5fd0b8ba38e0a75cb17 100644 |
--- a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
@@ -29,11 +29,13 @@ |
#include "modules/indexeddb/IDBRequest.h" |
#include "bindings/core/v8/ExceptionState.h" |
+#include "bindings/core/v8/SourceLocation.h" |
#include "bindings/modules/v8/ToV8ForModules.h" |
#include "bindings/modules/v8/V8BindingForModules.h" |
#include "core/dom/DOMException.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/ExecutionContext.h" |
+#include "core/events/ErrorEvent.h" |
#include "core/events/EventQueue.h" |
#include "modules/IndexedDBNames.h" |
#include "modules/indexeddb/IDBCursorWithValue.h" |
@@ -67,7 +69,8 @@ IDBRequest::IDBRequest(ScriptState* scriptState, |
IDBTransaction* transaction) |
: SuspendableObject(scriptState->getExecutionContext()), |
m_transaction(transaction), |
- m_source(source) {} |
+ m_source(source), |
+ m_creationSource(SourceLocation::capture()) {} |
IDBRequest::~IDBRequest() { |
DCHECK(m_readyState == DONE || m_readyState == EarlyDeath || |
@@ -503,6 +506,19 @@ DispatchEventResult IDBRequest::dispatchEventInternal(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 && event->type() == EventTypeNames::error && |
+ dispatchResult == DispatchEventResult::NotCanceled && m_creationSource) { |
+ // TODO: This nulls out m_creationSource; when IDBCursor::continue() or |
+ // IDBCursor::advance() is called we should re-capture. |
+ // TODO: Check Firefox behavior here and add test for continue()! |
+ getExecutionContext()->dispatchErrorEvent( |
+ ErrorEvent::create(m_error->toStringForConsole(), |
+ std::move(m_creationSource), nullptr), |
+ NotSharableCrossOrigin); |
+ } |
+ |
return dispatchResult; |
} |