| OLD | NEW |
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: | 115 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: |
| 116 request->abort(); | 116 request->abort(); |
| 117 | 117 |
| 118 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. | 118 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. |
| 119 // Ensure an assertion is not raised. | 119 // Ensure an assertion is not raised. |
| 120 request->onError(IDBDatabaseError::create(IDBDatabaseException::AbortError,
"Description goes here.")); | 120 request->onError(IDBDatabaseError::create(IDBDatabaseException::AbortError,
"Description goes here.")); |
| 121 } | 121 } |
| 122 | 122 |
| 123 class MockIDBDatabaseBackendInterface : public IDBDatabaseBackendInterface { | 123 class MockIDBDatabaseBackendInterface : public IDBDatabaseBackendInterface { |
| 124 public: | 124 public: |
| 125 static PassRefPtr<MockIDBDatabaseBackendInterface> create() | 125 static MockIDBDatabaseBackendInterface* create() |
| 126 { | 126 { |
| 127 return adoptRef(new MockIDBDatabaseBackendInterface()); | 127 return new MockIDBDatabaseBackendInterface(); |
| 128 } | 128 } |
| 129 virtual ~MockIDBDatabaseBackendInterface() | 129 virtual ~MockIDBDatabaseBackendInterface() |
| 130 { | 130 { |
| 131 EXPECT_TRUE(m_closeCalled); | 131 EXPECT_TRUE(m_closeCalled); |
| 132 } | 132 } |
| 133 | 133 |
| 134 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { } | 134 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { } |
| 135 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
OVERRIDE { } | 135 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
OVERRIDE { } |
| 136 virtual void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabase
Callbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode) OVERRIDE
{ } | 136 virtual void createTransaction(int64_t transactionId, IDBDatabaseCallbacks*,
const Vector<int64_t>& objectStoreIds, unsigned short mode) OVERRIDE { } |
| 137 virtual void close(PassRefPtr<IDBDatabaseCallbacks>) OVERRIDE | 137 virtual void close(IDBDatabaseCallbacks*) OVERRIDE |
| 138 { | 138 { |
| 139 m_closeCalled = true; | 139 m_closeCalled = true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual void commit(int64_t transactionId) OVERRIDE { } | 142 virtual void commit(int64_t transactionId) OVERRIDE { } |
| 143 virtual void abort(int64_t transactionId) OVERRIDE { } | 143 virtual void abort(int64_t transactionId) OVERRIDE { } |
| 144 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) OVER
RIDE { } | 144 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) OVER
RIDE { } |
| 145 | 145 |
| 146 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
OVERRIDE { } | 146 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
OVERRIDE { } |
| 147 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId) OVERRIDE { } | 147 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId) OVERRIDE { } |
| 148 | 148 |
| 149 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE {
} | 149 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, IDBCallbacks*) OVERRIDE { } |
| 150 virtual void put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<Sh
aredBuffer> value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const
Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE { } | 150 virtual void put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<Sh
aredBuffer> value, PassRefPtr<IDBKey>, PutMode, IDBCallbacks*, const Vector<int6
4_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE { } |
| 151 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERR
IDE { } | 151 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERR
IDE { } |
| 152 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE { } | 152 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE { } |
| 153 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 153 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, IDBCallbacks*) OVERRIDE { } |
| 154 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 154 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, IDBCallbacks*) OVERRIDE { } |
| 155 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 155 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, IDBCallbacks*) OVERRIDE { } |
| 156 virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<
IDBCallbacks>) OVERRIDE { } | 156 virtual void clear(int64_t transactionId, int64_t objectStoreId, IDBCallback
s*) OVERRIDE { } |
| 157 |
| 158 virtual void trace(Visitor*) OVERRIDE { } |
| 157 | 159 |
| 158 private: | 160 private: |
| 159 MockIDBDatabaseBackendInterface() | 161 MockIDBDatabaseBackendInterface() |
| 160 : m_closeCalled(false) | 162 : m_closeCalled(false) |
| 161 { | 163 { |
| 162 } | 164 } |
| 163 | 165 |
| 164 bool m_closeCalled; | 166 bool m_closeCalled; |
| 165 }; | 167 }; |
| 166 | 168 |
| 167 TEST_F(IDBRequestTest, ConnectionsAfterStopping) | 169 TEST_F(IDBRequestTest, ConnectionsAfterStopping) |
| 168 { | 170 { |
| 169 v8::HandleScope handleScope; | 171 v8::HandleScope handleScope; |
| 170 v8::Context::Scope scope(context()); | 172 v8::Context::Scope scope(context()); |
| 171 | 173 |
| 172 const int64_t transactionId = 1234; | 174 const int64_t transactionId = 1234; |
| 173 const int64_t version = 1; | 175 const int64_t version = 1; |
| 174 const int64_t oldVersion = 0; | 176 const int64_t oldVersion = 0; |
| 175 const IDBDatabaseMetadata metadata; | 177 const IDBDatabaseMetadata metadata; |
| 176 RefPtr<IDBDatabaseCallbacksImpl> callbacks = IDBDatabaseCallbacksImpl::creat
e(); | 178 IDBDatabaseCallbacksImpl* callbacks = IDBDatabaseCallbacksImpl::create(); |
| 177 | 179 |
| 178 { | 180 { |
| 179 RefPtr<MockIDBDatabaseBackendInterface> interface = MockIDBDatabaseBacke
ndInterface::create(); | 181 MockIDBDatabaseBackendInterface* interface = MockIDBDatabaseBackendInter
face::create(); |
| 180 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(scriptExecut
ionContext(), callbacks, transactionId, version); | 182 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(scriptExecut
ionContext(), callbacks, transactionId, version); |
| 181 EXPECT_EQ(request->readyState(), "pending"); | 183 EXPECT_EQ(request->readyState(), "pending"); |
| 182 | 184 |
| 183 scriptExecutionContext()->stopActiveDOMObjects(); | 185 scriptExecutionContext()->stopActiveDOMObjects(); |
| 184 request->onUpgradeNeeded(oldVersion, interface, metadata); | 186 request->onUpgradeNeeded(oldVersion, interface, metadata); |
| 185 } | 187 } |
| 186 | 188 |
| 187 { | 189 { |
| 188 RefPtr<MockIDBDatabaseBackendInterface> interface = MockIDBDatabaseBacke
ndInterface::create(); | 190 MockIDBDatabaseBackendInterface* interface = MockIDBDatabaseBackendInter
face::create(); |
| 189 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(scriptExecut
ionContext(), callbacks, transactionId, version); | 191 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(scriptExecut
ionContext(), callbacks, transactionId, version); |
| 190 EXPECT_EQ(request->readyState(), "pending"); | 192 EXPECT_EQ(request->readyState(), "pending"); |
| 191 | 193 |
| 192 scriptExecutionContext()->stopActiveDOMObjects(); | 194 scriptExecutionContext()->stopActiveDOMObjects(); |
| 193 request->onSuccess(interface, metadata);; | 195 request->onSuccess(interface, metadata);; |
| 194 } | 196 } |
| 195 } | 197 } |
| 196 | 198 |
| 197 } // namespace | 199 } // namespace |
| OLD | NEW |