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

Side by Side Diff: Source/modules/indexeddb/IDBTransactionTest.cpp

Issue 864533002: Fix template angle bracket syntax in modules (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 }; 100 };
101 101
102 TEST_F(IDBTransactionTest, EnsureLifetime) 102 TEST_F(IDBTransactionTest, EnsureLifetime)
103 { 103 {
104 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); 104 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create();
105 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create()); 105 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create());
106 106
107 const int64_t transactionId = 1234; 107 const int64_t transactionId = 1234;
108 const Vector<String> transactionScope; 108 const Vector<String> transactionScope;
109 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState( ), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); 109 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState( ), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get());
110 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; 110 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
111 set.add(transaction); 111 set.add(transaction);
112 112
113 Heap::collectAllGarbage(); 113 Heap::collectAllGarbage();
114 EXPECT_EQ(1u, set.size()); 114 EXPECT_EQ(1u, set.size());
115 115
116 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c reateUndefined(), transaction.get()); 116 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c reateUndefined(), transaction.get());
117 deactivateNewTransactions(); 117 deactivateNewTransactions();
118 118
119 Heap::collectAllGarbage(); 119 Heap::collectAllGarbage();
120 EXPECT_EQ(1u, set.size()); 120 EXPECT_EQ(1u, set.size());
121 121
122 // This will generate an abort() call to the back end which is dropped by th e fake proxy, 122 // This will generate an abort() call to the back end which is dropped by th e fake proxy,
123 // so an explicit onAbort call is made. 123 // so an explicit onAbort call is made.
124 executionContext()->stopActiveDOMObjects(); 124 executionContext()->stopActiveDOMObjects();
125 transaction->onAbort(DOMError::create(AbortError, "Aborted")); 125 transaction->onAbort(DOMError::create(AbortError, "Aborted"));
126 transaction.clear(); 126 transaction.clear();
127 127
128 Heap::collectAllGarbage(); 128 Heap::collectAllGarbage();
129 EXPECT_EQ(0u, set.size()); 129 EXPECT_EQ(0u, set.size());
130 } 130 }
131 131
132 TEST_F(IDBTransactionTest, TransactionFinish) 132 TEST_F(IDBTransactionTest, TransactionFinish)
133 { 133 {
134 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); 134 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create();
135 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create()); 135 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create());
136 136
137 const int64_t transactionId = 1234; 137 const int64_t transactionId = 1234;
138 const Vector<String> transactionScope; 138 const Vector<String> transactionScope;
139 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState( ), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); 139 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState( ), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get());
140 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; 140 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
141 set.add(transaction); 141 set.add(transaction);
142 142
143 Heap::collectAllGarbage(); 143 Heap::collectAllGarbage();
144 EXPECT_EQ(1u, set.size()); 144 EXPECT_EQ(1u, set.size());
145 145
146 deactivateNewTransactions(); 146 deactivateNewTransactions();
147 147
148 Heap::collectAllGarbage(); 148 Heap::collectAllGarbage();
149 EXPECT_EQ(1u, set.size()); 149 EXPECT_EQ(1u, set.size());
150 150
151 transaction.clear(); 151 transaction.clear();
152 152
153 Heap::collectAllGarbage(); 153 Heap::collectAllGarbage();
154 EXPECT_EQ(1u, set.size()); 154 EXPECT_EQ(1u, set.size());
155 155
156 // Stop the context, so events don't get queued (which would keep the transa ction alive). 156 // Stop the context, so events don't get queued (which would keep the transa ction alive).
157 executionContext()->stopActiveDOMObjects(); 157 executionContext()->stopActiveDOMObjects();
158 158
159 // Fire an abort to make sure this doesn't free the transaction during use. The test 159 // Fire an abort to make sure this doesn't free the transaction during use. The test
160 // will not fail if it is, but ASAN would notice the error. 160 // will not fail if it is, but ASAN would notice the error.
161 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); 161 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted"));
162 162
163 // onAbort() should have cleared the transaction's reference to the database . 163 // onAbort() should have cleared the transaction's reference to the database .
164 Heap::collectAllGarbage(); 164 Heap::collectAllGarbage();
165 EXPECT_EQ(0u, set.size()); 165 EXPECT_EQ(0u, set.size());
166 } 166 }
167 167
168 } // namespace 168 } // namespace
169 } // namespace blink 169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698