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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBTransactionTest.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/indexeddb/IDBTransaction.h" 32 #include "modules/indexeddb/IDBTransaction.h"
33 33
34 #include "bindings/core/v8/V8BindingForTesting.h" 34 #include "bindings/core/v8/V8BindingForTesting.h"
35 #include "core/dom/DOMError.h" 35 #include "core/dom/DOMException.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/ExceptionCode.h"
37 #include "modules/indexeddb/IDBDatabase.h" 38 #include "modules/indexeddb/IDBDatabase.h"
38 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 39 #include "modules/indexeddb/IDBDatabaseCallbacks.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 <gtest/gtest.h> 42 #include <gtest/gtest.h>
42 #include <v8.h> 43 #include <v8.h>
43 44
44 namespace blink { 45 namespace blink {
45 namespace { 46 namespace {
46 47
(...skipping 28 matching lines...) Expand all
75 private: 76 private:
76 V8TestingScope m_scope; 77 V8TestingScope m_scope;
77 RefPtrWillBePersistent<ExecutionContext> m_executionContext; 78 RefPtrWillBePersistent<ExecutionContext> m_executionContext;
78 }; 79 };
79 80
80 class FakeIDBDatabaseCallbacks final : public IDBDatabaseCallbacks { 81 class FakeIDBDatabaseCallbacks final : public IDBDatabaseCallbacks {
81 public: 82 public:
82 static FakeIDBDatabaseCallbacks* create() { return new FakeIDBDatabaseCallba cks(); } 83 static FakeIDBDatabaseCallbacks* create() { return new FakeIDBDatabaseCallba cks(); }
83 void onVersionChange(int64_t oldVersion, int64_t newVersion) override { } 84 void onVersionChange(int64_t oldVersion, int64_t newVersion) override { }
84 void onForcedClose() override { } 85 void onForcedClose() override { }
85 void onAbort(int64_t transactionId, DOMError* error) override { } 86 void onAbort(int64_t transactionId, DOMException* error) override { }
86 void onComplete(int64_t transactionId) override { } 87 void onComplete(int64_t transactionId) override { }
87 private: 88 private:
88 FakeIDBDatabaseCallbacks() { } 89 FakeIDBDatabaseCallbacks() { }
89 }; 90 };
90 91
91 TEST_F(IDBTransactionTest, EnsureLifetime) 92 TEST_F(IDBTransactionTest, EnsureLifetime)
92 { 93 {
93 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 94 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
94 EXPECT_CALL(*backend, close()) 95 EXPECT_CALL(*backend, close())
95 .Times(1); 96 .Times(1);
(...skipping 10 matching lines...) Expand all
106 107
107 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c reateUndefined(), transaction.get()); 108 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c reateUndefined(), transaction.get());
108 deactivateNewTransactions(); 109 deactivateNewTransactions();
109 110
110 Heap::collectAllGarbage(); 111 Heap::collectAllGarbage();
111 EXPECT_EQ(1u, set.size()); 112 EXPECT_EQ(1u, set.size());
112 113
113 // This will generate an abort() call to the back end which is dropped by th e fake proxy, 114 // This will generate an abort() call to the back end which is dropped by th e fake proxy,
114 // so an explicit onAbort call is made. 115 // so an explicit onAbort call is made.
115 executionContext()->stopActiveDOMObjects(); 116 executionContext()->stopActiveDOMObjects();
116 transaction->onAbort(DOMError::create(AbortError, "Aborted")); 117 transaction->onAbort(DOMException::create(AbortError, "Aborted"));
117 transaction.clear(); 118 transaction.clear();
118 119
119 Heap::collectAllGarbage(); 120 Heap::collectAllGarbage();
120 EXPECT_EQ(0u, set.size()); 121 EXPECT_EQ(0u, set.size());
121 } 122 }
122 123
123 TEST_F(IDBTransactionTest, TransactionFinish) 124 TEST_F(IDBTransactionTest, TransactionFinish)
124 { 125 {
125 const int64_t transactionId = 1234; 126 const int64_t transactionId = 1234;
126 127
(...skipping 20 matching lines...) Expand all
147 transaction.clear(); 148 transaction.clear();
148 149
149 Heap::collectAllGarbage(); 150 Heap::collectAllGarbage();
150 EXPECT_EQ(1u, set.size()); 151 EXPECT_EQ(1u, set.size());
151 152
152 // Stop the context, so events don't get queued (which would keep the transa ction alive). 153 // Stop the context, so events don't get queued (which would keep the transa ction alive).
153 executionContext()->stopActiveDOMObjects(); 154 executionContext()->stopActiveDOMObjects();
154 155
155 // Fire an abort to make sure this doesn't free the transaction during use. The test 156 // Fire an abort to make sure this doesn't free the transaction during use. The test
156 // will not fail if it is, but ASAN would notice the error. 157 // will not fail if it is, but ASAN would notice the error.
157 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); 158 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted"));
158 159
159 // onAbort() should have cleared the transaction's reference to the database . 160 // onAbort() should have cleared the transaction's reference to the database .
160 Heap::collectAllGarbage(); 161 Heap::collectAllGarbage();
161 EXPECT_EQ(0u, set.size()); 162 EXPECT_EQ(0u, set.size());
162 } 163 }
163 164
164 } // namespace 165 } // namespace
165 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698