| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 { | 77 { |
| 78 return static_cast<WebFrameImpl*>(m_webView->mainFrame())->frame()->docu
ment(); | 78 return static_cast<WebFrameImpl*>(m_webView->mainFrame())->frame()->docu
ment(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 WebView* m_webView; | 82 WebView* m_webView; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class FakeIDBDatabaseBackendProxy : public IDBDatabaseBackendInterface { | 85 class FakeIDBDatabaseBackendProxy : public IDBDatabaseBackendInterface { |
| 86 public: | 86 public: |
| 87 static PassRefPtr<FakeIDBDatabaseBackendProxy> create() { return adoptRef(ne
w FakeIDBDatabaseBackendProxy()); } | 87 static FakeIDBDatabaseBackendProxy* create() { return new FakeIDBDatabaseBac
kendProxy(); } |
| 88 | 88 |
| 89 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { } | 89 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { } |
| 90 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
OVERRIDE { } | 90 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
OVERRIDE { } |
| 91 virtual void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabase
Callbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode) OVERRIDE
{ } | 91 virtual void createTransaction(int64_t transactionId, IDBDatabaseCallbacks*,
const Vector<int64_t>& objectStoreIds, unsigned short mode) OVERRIDE { } |
| 92 virtual void close(PassRefPtr<IDBDatabaseCallbacks>) OVERRIDE { } | 92 virtual void close(IDBDatabaseCallbacks*) OVERRIDE { } |
| 93 | 93 |
| 94 virtual void commit(int64_t transactionId) OVERRIDE { } | 94 virtual void commit(int64_t transactionId) OVERRIDE { } |
| 95 virtual void abort(int64_t transactionId) OVERRIDE { } | 95 virtual void abort(int64_t transactionId) OVERRIDE { } |
| 96 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) OVER
RIDE { } | 96 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) OVER
RIDE { } |
| 97 | 97 |
| 98 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
OVERRIDE { } | 98 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
OVERRIDE { } |
| 99 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId) OVERRIDE { } | 99 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId) OVERRIDE { } |
| 100 | 100 |
| 101 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE {
} | 101 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE {
} |
| 102 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 { } | 102 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 { } |
| 103 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERR
IDE { } | 103 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERR
IDE { } |
| 104 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE { } | 104 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE { } |
| 105 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 105 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, PassRefPtr<IDBCallbacks>) OVERRIDE { } |
| 106 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 106 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } |
| 107 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } | 107 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { } |
| 108 virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<
IDBCallbacks>) OVERRIDE { } | 108 virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<
IDBCallbacks>) OVERRIDE { } |
| 109 | 109 |
| 110 virtual void trace(Visitor*) const OVERRIDE { } |
| 111 |
| 110 private: | 112 private: |
| 111 FakeIDBDatabaseBackendProxy() { } | 113 FakeIDBDatabaseBackendProxy() { } |
| 112 }; | 114 }; |
| 113 | 115 |
| 114 class FakeIDBDatabaseCallbacks : public IDBDatabaseCallbacks { | 116 class FakeIDBDatabaseCallbacks : public IDBDatabaseCallbacks { |
| 115 public: | 117 public: |
| 116 static PassRefPtr<FakeIDBDatabaseCallbacks> create() { return adoptRef(new F
akeIDBDatabaseCallbacks()); } | 118 static FakeIDBDatabaseCallbacks* create() { return new FakeIDBDatabaseCallba
cks(); } |
| 117 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) OVERRID
E { } | 119 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) OVERRID
E { } |
| 118 virtual void onForcedClose() OVERRIDE { } | 120 virtual void onForcedClose() OVERRIDE { } |
| 119 virtual void onAbort(int64_t transactionId, PassRefPtr<IDBDatabaseError> err
or) OVERRIDE { } | 121 virtual void onAbort(int64_t transactionId, PassRefPtr<IDBDatabaseError> err
or) OVERRIDE { } |
| 120 virtual void onComplete(int64_t transactionId) OVERRIDE { } | 122 virtual void onComplete(int64_t transactionId) OVERRIDE { } |
| 123 virtual void trace(Visitor*) const OVERRIDE { } |
| 121 private: | 124 private: |
| 122 FakeIDBDatabaseCallbacks() { } | 125 FakeIDBDatabaseCallbacks() { } |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 TEST_F(IDBTransactionTest, EnsureLifetime) | 128 TEST_F(IDBTransactionTest, EnsureLifetime) |
| 126 { | 129 { |
| 127 v8::HandleScope handleScope; | 130 v8::HandleScope handleScope; |
| 128 v8::Context::Scope scope(context()); | 131 v8::Context::Scope scope(context()); |
| 129 | 132 |
| 130 RefPtr<FakeIDBDatabaseBackendProxy> proxy = FakeIDBDatabaseBackendProxy::cre
ate(); | 133 FakeIDBDatabaseBackendProxy* proxy = FakeIDBDatabaseBackendProxy::create(); |
| 131 RefPtr<FakeIDBDatabaseCallbacks> connection = FakeIDBDatabaseCallbacks::crea
te(); | 134 FakeIDBDatabaseCallbacks* connection = FakeIDBDatabaseCallbacks::create(); |
| 132 RefPtr<IDBDatabase> db = IDBDatabase::create(scriptExecutionContext(), proxy
, connection); | 135 RefPtr<IDBDatabase> db = IDBDatabase::create(scriptExecutionContext(), proxy
, connection); |
| 133 | 136 |
| 134 const int64_t transactionId = 1234; | 137 const int64_t transactionId = 1234; |
| 135 const Vector<String> transactionScope; | 138 const Vector<String> transactionScope; |
| 136 RefPtr<IDBTransaction> transaction = IDBTransaction::create(scriptExecutionC
ontext(), transactionId, transactionScope, IndexedDB::TransactionReadOnly, db.ge
t()); | 139 RefPtr<IDBTransaction> transaction = IDBTransaction::create(scriptExecutionC
ontext(), transactionId, transactionScope, IndexedDB::TransactionReadOnly, db.ge
t()); |
| 137 | 140 |
| 138 // Local reference, IDBDatabase's reference and IDBPendingTransactionMonitor
's reference: | 141 // Local reference, IDBDatabase's reference and IDBPendingTransactionMonitor
's reference: |
| 139 EXPECT_EQ(3, transaction->refCount()); | 142 EXPECT_EQ(3, transaction->refCount()); |
| 140 | 143 |
| 141 RefPtr<IDBRequest> request = IDBRequest::create(scriptExecutionContext(), ID
BAny::createInvalid(), transaction.get()); | 144 RefPtr<IDBRequest> request = IDBRequest::create(scriptExecutionContext(), ID
BAny::createInvalid(), transaction.get()); |
| 142 IDBPendingTransactionMonitor::deactivateNewTransactions(); | 145 IDBPendingTransactionMonitor::deactivateNewTransactions(); |
| 143 | 146 |
| 144 // Local reference, IDBDatabase's reference, and the IDBRequest's reference | 147 // Local reference, IDBDatabase's reference, and the IDBRequest's reference |
| 145 EXPECT_EQ(3, transaction->refCount()); | 148 EXPECT_EQ(3, transaction->refCount()); |
| 146 | 149 |
| 147 // This will generate an abort() call to the back end which is dropped by th
e fake proxy, | 150 // This will generate an abort() call to the back end which is dropped by th
e fake proxy, |
| 148 // so an explicit onAbort call is made. | 151 // so an explicit onAbort call is made. |
| 149 scriptExecutionContext()->stopActiveDOMObjects(); | 152 scriptExecutionContext()->stopActiveDOMObjects(); |
| 150 transaction->onAbort(IDBDatabaseError::create(IDBDatabaseException::AbortErr
or, "Aborted")); | 153 transaction->onAbort(IDBDatabaseError::create(IDBDatabaseException::AbortErr
or, "Aborted")); |
| 151 | 154 |
| 152 EXPECT_EQ(1, transaction->refCount()); | 155 EXPECT_EQ(1, transaction->refCount()); |
| 153 } | 156 } |
| 154 | 157 |
| 155 } // namespace | 158 } // namespace |
| OLD | NEW |