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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequestTest.cpp

Issue 1364823002: IndexedDB: Replace use of DOMError with DOMException (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop [Measure] where done Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "modules/indexeddb/IDBRequest.h" 27 #include "modules/indexeddb/IDBRequest.h"
28 28
29 #include "bindings/core/v8/ScriptState.h" 29 #include "bindings/core/v8/ScriptState.h"
30 #include "bindings/core/v8/V8Binding.h" 30 #include "bindings/core/v8/V8Binding.h"
31 #include "bindings/core/v8/V8BindingForTesting.h" 31 #include "bindings/core/v8/V8BindingForTesting.h"
32 #include "core/dom/DOMError.h" 32 #include "core/dom/DOMException.h"
33 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
34 #include "core/testing/NullExecutionContext.h" 35 #include "core/testing/NullExecutionContext.h"
35 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 36 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
36 #include "modules/indexeddb/IDBKey.h" 37 #include "modules/indexeddb/IDBKey.h"
37 #include "modules/indexeddb/IDBOpenDBRequest.h" 38 #include "modules/indexeddb/IDBOpenDBRequest.h"
38 #include "modules/indexeddb/IDBValue.h" 39 #include "modules/indexeddb/IDBValue.h"
39 #include "modules/indexeddb/MockWebIDBDatabase.h" 40 #include "modules/indexeddb/MockWebIDBDatabase.h"
40 #include "platform/SharedBuffer.h" 41 #include "platform/SharedBuffer.h"
41 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
42 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 79 };
79 80
80 TEST_F(IDBRequestTest, EventsAfterStopping) 81 TEST_F(IDBRequestTest, EventsAfterStopping)
81 { 82 {
82 IDBTransaction* transaction = nullptr; 83 IDBTransaction* transaction = nullptr;
83 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction); 84 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction);
84 EXPECT_EQ(request->readyState(), "pending"); 85 EXPECT_EQ(request->readyState(), "pending");
85 executionContext()->stopActiveDOMObjects(); 86 executionContext()->stopActiveDOMObjects();
86 87
87 // Ensure none of the following raise assertions in stopped state: 88 // Ensure none of the following raise assertions in stopped state:
88 request->onError(DOMError::create(AbortError, "Description goes here.")); 89 request->onError(DOMException::create(AbortError, "Description goes here.")) ;
89 request->onSuccess(Vector<String>()); 90 request->onSuccess(Vector<String>());
90 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , IDBValue::create()); 91 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , IDBValue::create());
91 request->onSuccess(IDBKey::createInvalid()); 92 request->onSuccess(IDBKey::createInvalid());
92 request->onSuccess(IDBValue::create()); 93 request->onSuccess(IDBValue::create());
93 request->onSuccess(static_cast<int64_t>(0)); 94 request->onSuccess(static_cast<int64_t>(0));
94 request->onSuccess(); 95 request->onSuccess();
95 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu e::create()); 96 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu e::create());
96 } 97 }
97 98
98 TEST_F(IDBRequestTest, AbortErrorAfterAbort) 99 TEST_F(IDBRequestTest, AbortErrorAfterAbort)
99 { 100 {
100 IDBTransaction* transaction = nullptr; 101 IDBTransaction* transaction = nullptr;
101 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction); 102 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction);
102 EXPECT_EQ(request->readyState(), "pending"); 103 EXPECT_EQ(request->readyState(), "pending");
103 104
104 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request: 105 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request:
105 request->abort(); 106 request->abort();
106 107
107 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries. 108 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries.
108 // Ensure an assertion is not raised. 109 // Ensure an assertion is not raised.
109 request->onError(DOMError::create(AbortError, "Description goes here.")); 110 request->onError(DOMException::create(AbortError, "Description goes here.")) ;
110 111
111 // Stop the request lest it be GCed and its destructor 112 // Stop the request lest it be GCed and its destructor
112 // finds the object in a pending state (and asserts.) 113 // finds the object in a pending state (and asserts.)
113 executionContext()->stopActiveDOMObjects(); 114 executionContext()->stopActiveDOMObjects();
114 } 115 }
115 116
116 TEST_F(IDBRequestTest, ConnectionsAfterStopping) 117 TEST_F(IDBRequestTest, ConnectionsAfterStopping)
117 { 118 {
118 const int64_t transactionId = 1234; 119 const int64_t transactionId = 1234;
119 const int64_t version = 1; 120 const int64_t version = 1;
(...skipping 21 matching lines...) Expand all
141 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version); 142 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version);
142 EXPECT_EQ(request->readyState(), "pending"); 143 EXPECT_EQ(request->readyState(), "pending");
143 144
144 executionContext()->stopActiveDOMObjects(); 145 executionContext()->stopActiveDOMObjects();
145 request->onSuccess(backend.release(), metadata); 146 request->onSuccess(backend.release(), metadata);
146 } 147 }
147 } 148 }
148 149
149 } // namespace 150 } // namespace
150 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698