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

Side by Side 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, 5 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
« no previous file with comments | « Source/modules/indexeddb/IDBRequest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
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 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "modules/indexeddb/IDBRequest.h" 30 #include "modules/indexeddb/IDBRequest.h"
31 31
32 #include "bindings/core/v8/ExceptionState.h" 32 #include "bindings/core/v8/ExceptionState.h"
33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
34 #include "bindings/core/v8/ScriptCallStackFactory.h"
34 #include "bindings/modules/v8/IDBBindingUtilities.h" 35 #include "bindings/modules/v8/IDBBindingUtilities.h"
35 #include "core/dom/ExecutionContext.h" 36 #include "core/dom/ExecutionContext.h"
37 #include "core/events/ErrorEvent.h"
36 #include "core/events/EventQueue.h" 38 #include "core/events/EventQueue.h"
39 #include "core/inspector/ScriptCallFrame.h"
40 #include "core/inspector/ScriptCallStack.h"
37 #include "modules/indexeddb/IDBCursorWithValue.h" 41 #include "modules/indexeddb/IDBCursorWithValue.h"
38 #include "modules/indexeddb/IDBDatabase.h" 42 #include "modules/indexeddb/IDBDatabase.h"
39 #include "modules/indexeddb/IDBEventDispatcher.h" 43 #include "modules/indexeddb/IDBEventDispatcher.h"
40 #include "modules/indexeddb/IDBTracing.h" 44 #include "modules/indexeddb/IDBTracing.h"
41 #include "platform/SharedBuffer.h" 45 #include "platform/SharedBuffer.h"
42 #include "public/platform/WebBlobInfo.h" 46 #include "public/platform/WebBlobInfo.h"
43 47
44 using blink::WebIDBCursor; 48 using blink::WebIDBCursor;
45 49
46 namespace WebCore { 50 namespace WebCore {
(...skipping 18 matching lines...) Expand all
65 , m_source(source) 69 , m_source(source)
66 , m_hasPendingActivity(true) 70 , m_hasPendingActivity(true)
67 , m_cursorType(IndexedDB::CursorKeyAndValue) 71 , m_cursorType(IndexedDB::CursorKeyAndValue)
68 , m_cursorDirection(blink::WebIDBCursorDirectionNext) 72 , m_cursorDirection(blink::WebIDBCursorDirectionNext)
69 , m_pendingCursor(nullptr) 73 , m_pendingCursor(nullptr)
70 , m_didFireUpgradeNeededEvent(false) 74 , m_didFireUpgradeNeededEvent(false)
71 , m_preventPropagation(false) 75 , m_preventPropagation(false)
72 , m_resultDirty(true) 76 , m_resultDirty(true)
73 { 77 {
74 ScriptWrappable::init(this); 78 ScriptWrappable::init(this);
79
80 m_creationStackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSi zeToCapture, false);
aandrey 2014/07/08 18:40:16 Probably we should collect the stacks only when De
81 ASSERT(m_creationStackTrace && m_creationStackTrace->size());
75 } 82 }
76 83
77 IDBRequest::~IDBRequest() 84 IDBRequest::~IDBRequest()
78 { 85 {
79 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); 86 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt());
80 handleBlobAcks(); 87 handleBlobAcks();
81 } 88 }
82 89
83 void IDBRequest::trace(Visitor* visitor) 90 void IDBRequest::trace(Visitor* visitor)
84 { 91 {
85 visitor->trace(m_transaction); 92 visitor->trace(m_transaction);
86 visitor->trace(m_source); 93 visitor->trace(m_source);
87 visitor->trace(m_result); 94 visitor->trace(m_result);
88 visitor->trace(m_error); 95 visitor->trace(m_error);
89 #if ENABLE(OILPAN) 96 #if ENABLE(OILPAN)
90 visitor->trace(m_enqueuedEvents); 97 visitor->trace(m_enqueuedEvents);
91 #endif 98 #endif
92 visitor->trace(m_pendingCursor); 99 visitor->trace(m_pendingCursor);
93 visitor->trace(m_cursorKey); 100 visitor->trace(m_cursorKey);
94 visitor->trace(m_cursorPrimaryKey); 101 visitor->trace(m_cursorPrimaryKey);
102 visitor->trace(m_creationStackTrace);
95 EventTargetWithInlineData::trace(visitor); 103 EventTargetWithInlineData::trace(visitor);
96 } 104 }
97 105
98 ScriptValue IDBRequest::result(ExceptionState& exceptionState) 106 ScriptValue IDBRequest::result(ExceptionState& exceptionState)
99 { 107 {
100 if (m_readyState != DONE) { 108 if (m_readyState != DONE) {
101 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); 109 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage);
102 return ScriptValue(); 110 return ScriptValue();
103 } 111 }
104 if (m_contextStopped || !executionContext()) 112 if (m_contextStopped || !executionContext())
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 494 }
487 495
488 if (cursorToNotify) 496 if (cursorToNotify)
489 cursorToNotify->postSuccessHandlerCallback(); 497 cursorToNotify->postSuccessHandlerCallback();
490 498
491 // An upgradeneeded event will always be followed by a success or error even t, so must 499 // An upgradeneeded event will always be followed by a success or error even t, so must
492 // be kept alive. 500 // be kept alive.
493 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) 501 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded)
494 m_hasPendingActivity = false; 502 m_hasPendingActivity = false;
495 503
504 // Fire window.onerror (or the equivalent for workers) for errors that were not prevented.
505 if (!m_preventPropagation && dontPreventDefault && event->type() == EventTyp eNames::error) {
506 const ScriptCallFrame& frame = m_creationStackTrace->at(0);
507 const AccessControlStatus corsStatus = NotSharableCrossOrigin;
508 RefPtrWillBeRawPtr<ErrorEvent> errorEvent;
509 if (executionContext()->shouldSanitizeScriptError(frame.sourceURL(), cor sStatus)) {
510 errorEvent = ErrorEvent::createSanitizedError(&m_scriptState->world( ));
511 } else {
512 String message = m_error->name() + ": " + m_error->message();
513 errorEvent = ErrorEvent::create(message, frame.sourceURL(), frame.li neNumber(), frame.columnNumber(), &m_scriptState->world());
514 }
515 executionContext()->reportException(errorEvent, m_creationStackTrace, co rsStatus);
516 }
517
496 return dontPreventDefault; 518 return dontPreventDefault;
497 } 519 }
498 520
499 void IDBRequest::uncaughtExceptionInEventHandler() 521 void IDBRequest::uncaughtExceptionInEventHandler()
500 { 522 {
501 if (m_transaction && !m_requestAborted) { 523 if (m_transaction && !m_requestAborted) {
502 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); 524 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler."));
503 m_transaction->abort(IGNORE_EXCEPTION); 525 m_transaction->abort(IGNORE_EXCEPTION);
504 } 526 }
505 } 527 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 562
541 void IDBRequest::dequeueEvent(Event* event) 563 void IDBRequest::dequeueEvent(Event* event)
542 { 564 {
543 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 565 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
544 if (m_enqueuedEvents[i].get() == event) 566 if (m_enqueuedEvents[i].get() == event)
545 m_enqueuedEvents.remove(i); 567 m_enqueuedEvents.remove(i);
546 } 568 }
547 } 569 }
548 570
549 } // namespace WebCore 571 } // namespace WebCore
OLDNEW
« 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