| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 TEST(IDBTransactionTest, EnsureLifetime) | 64 TEST(IDBTransactionTest, EnsureLifetime) |
| 65 { | 65 { |
| 66 V8TestingScope scope; | 66 V8TestingScope scope; |
| 67 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 67 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 68 EXPECT_CALL(*backend, close()) | 68 EXPECT_CALL(*backend, close()) |
| 69 .Times(1); | 69 .Times(1); |
| 70 Persistent<IDBDatabase> db = IDBDatabase::create(scope.getExecutionContext()
, std::move(backend), FakeIDBDatabaseCallbacks::create()); | 70 Persistent<IDBDatabase> db = IDBDatabase::create(scope.getExecutionContext()
, std::move(backend), FakeIDBDatabaseCallbacks::create()); |
| 71 | 71 |
| 72 const int64_t transactionId = 1234; | 72 const int64_t transactionId = 1234; |
| 73 const HashSet<String> transactionScope = HashSet<String>(); | 73 HashSet<String> transactionScope = HashSet<String>(); |
| 74 Persistent<IDBTransaction> transaction = IDBTransaction::create(scope.getScr
iptState(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.g
et()); | 74 transactionScope.add("test-store-name"); |
| 75 Persistent<IDBTransaction> transaction = IDBTransaction::createNonVersionCha
nge(scope.getScriptState(), transactionId, transactionScope, WebIDBTransactionMo
deReadOnly, db.get()); |
| 75 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 76 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; |
| 76 set.add(transaction); | 77 set.add(transaction); |
| 77 | 78 |
| 78 ThreadState::current()-> collectAllGarbage(); | 79 ThreadState::current()-> collectAllGarbage(); |
| 79 EXPECT_EQ(1u, set.size()); | 80 EXPECT_EQ(1u, set.size()); |
| 80 | 81 |
| 81 Persistent<IDBRequest> request = IDBRequest::create(scope.getScriptState(),
IDBAny::createUndefined(), transaction.get()); | 82 Persistent<IDBRequest> request = IDBRequest::create(scope.getScriptState(),
IDBAny::createUndefined(), transaction.get()); |
| 82 deactivateNewTransactions(scope.isolate()); | 83 deactivateNewTransactions(scope.isolate()); |
| 83 | 84 |
| 84 ThreadState::current()-> collectAllGarbage(); | 85 ThreadState::current()-> collectAllGarbage(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 99 V8TestingScope scope; | 100 V8TestingScope scope; |
| 100 const int64_t transactionId = 1234; | 101 const int64_t transactionId = 1234; |
| 101 | 102 |
| 102 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 103 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 103 EXPECT_CALL(*backend, commit(transactionId)) | 104 EXPECT_CALL(*backend, commit(transactionId)) |
| 104 .Times(1); | 105 .Times(1); |
| 105 EXPECT_CALL(*backend, close()) | 106 EXPECT_CALL(*backend, close()) |
| 106 .Times(1); | 107 .Times(1); |
| 107 Persistent<IDBDatabase> db = IDBDatabase::create(scope.getExecutionContext()
, std::move(backend), FakeIDBDatabaseCallbacks::create()); | 108 Persistent<IDBDatabase> db = IDBDatabase::create(scope.getExecutionContext()
, std::move(backend), FakeIDBDatabaseCallbacks::create()); |
| 108 | 109 |
| 109 const HashSet<String> transactionScope = HashSet<String>(); | 110 HashSet<String> transactionScope = HashSet<String>(); |
| 110 Persistent<IDBTransaction> transaction = IDBTransaction::create(scope.getScr
iptState(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.g
et()); | 111 transactionScope.add("test-store-name"); |
| 112 Persistent<IDBTransaction> transaction = IDBTransaction::createNonVersionCha
nge(scope.getScriptState(), transactionId, transactionScope, WebIDBTransactionMo
deReadOnly, db.get()); |
| 111 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 113 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; |
| 112 set.add(transaction); | 114 set.add(transaction); |
| 113 | 115 |
| 114 ThreadState::current()-> collectAllGarbage(); | 116 ThreadState::current()-> collectAllGarbage(); |
| 115 EXPECT_EQ(1u, set.size()); | 117 EXPECT_EQ(1u, set.size()); |
| 116 | 118 |
| 117 deactivateNewTransactions(scope.isolate()); | 119 deactivateNewTransactions(scope.isolate()); |
| 118 | 120 |
| 119 ThreadState::current()-> collectAllGarbage(); | 121 ThreadState::current()-> collectAllGarbage(); |
| 120 EXPECT_EQ(1u, set.size()); | 122 EXPECT_EQ(1u, set.size()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 // will not fail if it is, but ASAN would notice the error. | 133 // will not fail if it is, but ASAN would notice the error. |
| 132 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); | 134 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); |
| 133 | 135 |
| 134 // onAbort() should have cleared the transaction's reference to the database
. | 136 // onAbort() should have cleared the transaction's reference to the database
. |
| 135 ThreadState::current()-> collectAllGarbage(); | 137 ThreadState::current()-> collectAllGarbage(); |
| 136 EXPECT_EQ(0u, set.size()); | 138 EXPECT_EQ(0u, set.size()); |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace | 141 } // namespace |
| 140 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |