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

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

Issue 1362953003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 3 years, 11 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
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;
}
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBRequest.h ('k') | third_party/WebKit/Source/modules/quota/DOMError.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698