Index: content/browser/indexed_db/indexed_db_transaction_unittest.cc |
diff --git a/content/browser/indexed_db/indexed_db_transaction_unittest.cc b/content/browser/indexed_db/indexed_db_transaction_unittest.cc |
index d0228bcd9a14f2e3737e57543270058f8084baae..f9f4add8e2878ff6c746cf58b38a5a51438d6b55 100644 |
--- a/content/browser/indexed_db/indexed_db_transaction_unittest.cc |
+++ b/content/browser/indexed_db/indexed_db_transaction_unittest.cc |
@@ -48,7 +48,7 @@ TEST_F(IndexedDBTransactionTest, Timeout) { |
id, |
new MockIndexedDBDatabaseCallbacks(), |
scope, |
- indexed_db::TRANSACTION_READ_ONLY, |
+ indexed_db::TRANSACTION_READ_WRITE, |
db_, |
new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); |
db_->TransactionCreated(transaction); |
@@ -77,6 +77,38 @@ TEST_F(IndexedDBTransactionTest, Timeout) { |
EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
} |
+TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) { |
+ const int64 id = 0; |
+ const std::set<int64> scope; |
+ const bool commit_success = true; |
+ scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction( |
+ id, |
+ new MockIndexedDBDatabaseCallbacks(), |
+ scope, |
+ indexed_db::TRANSACTION_READ_ONLY, |
+ db_, |
+ new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); |
+ db_->TransactionCreated(transaction); |
+ |
+ // No conflicting transactions, so coordinator will start it immediately: |
+ EXPECT_EQ(IndexedDBTransaction::STARTED, transaction->state()); |
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
+ |
+ // Schedule a task - timer won't be started until it's processed. |
+ transaction->ScheduleTask(base::Bind( |
+ &IndexedDBTransactionTest::DummyOperation, base::Unretained(this))); |
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
+ |
+ // Transaction is read-only, so no need to time it out. |
+ RunPostedTasks(); |
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
+ |
+ // Clean up to avoid leaks. |
+ transaction->Abort(); |
+ EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state()); |
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
+} |
+ |
class AbortObserver { |
public: |
AbortObserver() : abort_task_called_(false) {} |