| OLD | NEW |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 FakeIDBDatabaseCallbacks() { } | 90 FakeIDBDatabaseCallbacks() { } |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 TEST_F(IDBTransactionTest, EnsureLifetime) | 93 TEST_F(IDBTransactionTest, EnsureLifetime) |
| 94 { | 94 { |
| 95 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); | 95 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); |
| 96 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend
.release(), FakeIDBDatabaseCallbacks::create()); | 96 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend
.release(), FakeIDBDatabaseCallbacks::create()); |
| 97 | 97 |
| 98 const int64_t transactionId = 1234; | 98 const int64_t transactionId = 1234; |
| 99 const Vector<String> transactionScope; | 99 const Vector<String> transactionScope; |
| 100 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon
text(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()
); | 100 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState(
), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); |
| 101 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; | 101 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; |
| 102 set.add(transaction); | 102 set.add(transaction); |
| 103 | 103 |
| 104 Heap::collectAllGarbage(); | 104 Heap::collectAllGarbage(); |
| 105 EXPECT_EQ(1u, set.size()); | 105 EXPECT_EQ(1u, set.size()); |
| 106 | 106 |
| 107 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c
reateUndefined(), transaction.get()); | 107 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c
reateUndefined(), transaction.get()); |
| 108 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac
tions(); | 108 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac
tions(); |
| 109 | 109 |
| 110 Heap::collectAllGarbage(); | 110 Heap::collectAllGarbage(); |
| 111 EXPECT_EQ(1u, set.size()); | 111 EXPECT_EQ(1u, set.size()); |
| 112 | 112 |
| 113 // This will generate an abort() call to the back end which is dropped by th
e fake proxy, | 113 // 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. | 114 // so an explicit onAbort call is made. |
| 115 executionContext()->stopActiveDOMObjects(); | 115 executionContext()->stopActiveDOMObjects(); |
| 116 transaction->onAbort(DOMError::create(AbortError, "Aborted")); | 116 transaction->onAbort(DOMError::create(AbortError, "Aborted")); |
| 117 transaction.clear(); | 117 transaction.clear(); |
| 118 | 118 |
| 119 Heap::collectAllGarbage(); | 119 Heap::collectAllGarbage(); |
| 120 EXPECT_EQ(0u, set.size()); | 120 EXPECT_EQ(0u, set.size()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 TEST_F(IDBTransactionTest, TransactionFinish) | 123 TEST_F(IDBTransactionTest, TransactionFinish) |
| 124 { | 124 { |
| 125 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); | 125 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); |
| 126 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend
.release(), FakeIDBDatabaseCallbacks::create()); | 126 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend
.release(), FakeIDBDatabaseCallbacks::create()); |
| 127 | 127 |
| 128 const int64_t transactionId = 1234; | 128 const int64_t transactionId = 1234; |
| 129 const Vector<String> transactionScope; | 129 const Vector<String> transactionScope; |
| 130 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon
text(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()
); | 130 Persistent<IDBTransaction> transaction = IDBTransaction::create(scriptState(
), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); |
| 131 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; | 131 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; |
| 132 set.add(transaction); | 132 set.add(transaction); |
| 133 | 133 |
| 134 Heap::collectAllGarbage(); | 134 Heap::collectAllGarbage(); |
| 135 EXPECT_EQ(1u, set.size()); | 135 EXPECT_EQ(1u, set.size()); |
| 136 | 136 |
| 137 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac
tions(); | 137 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac
tions(); |
| 138 | 138 |
| 139 Heap::collectAllGarbage(); | 139 Heap::collectAllGarbage(); |
| 140 EXPECT_EQ(1u, set.size()); | 140 EXPECT_EQ(1u, set.size()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 151 // will not fail if it is, but ASAN would notice the error. | 151 // will not fail if it is, but ASAN would notice the error. |
| 152 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); | 152 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); |
| 153 | 153 |
| 154 // onAbort() should have cleared the transaction's reference to the database
. | 154 // onAbort() should have cleared the transaction's reference to the database
. |
| 155 Heap::collectAllGarbage(); | 155 Heap::collectAllGarbage(); |
| 156 EXPECT_EQ(0u, set.size()); | 156 EXPECT_EQ(0u, set.size()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace | 159 } // namespace |
| 160 } // namespace blink | 160 } // namespace blink |
| OLD | NEW |