Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Side by Side Diff: Source/modules/indexeddb/IDBTransactionTest.cpp

Issue 307933011: Fix test failures of IDBTransactionTest.EnsureLifetime with ENABLE(OILPAN) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/indexeddb/IDBRequestTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 using namespace WebCore; 44 using namespace WebCore;
45 45
46 using blink::WebIDBDatabase; 46 using blink::WebIDBDatabase;
47 47
48 namespace { 48 namespace {
49 49
50 class IDBTransactionTest : public testing::Test { 50 class IDBTransactionTest : public testing::Test {
51 public: 51 public:
52 IDBTransactionTest() 52 IDBTransactionTest()
53 : m_scope(v8::Isolate::GetCurrent()) 53 : m_scope(v8::Isolate::GetCurrent())
54 , m_executionContext(Document::create())
54 { 55 {
55 m_scope.scriptState()->setExecutionContext(Document::create()); 56 m_scope.scriptState()->setExecutionContext(m_executionContext.get());
57 }
58
59 ~IDBTransactionTest()
60 {
61 m_scope.scriptState()->setExecutionContext(0);
56 } 62 }
57 63
58 v8::Isolate* isolate() const { return m_scope.isolate(); } 64 v8::Isolate* isolate() const { return m_scope.isolate(); }
59 ScriptState* scriptState() const { return m_scope.scriptState(); } 65 ScriptState* scriptState() const { return m_scope.scriptState(); }
60 ExecutionContext* executionContext() { return m_scope.scriptState()->executi onContext(); } 66 ExecutionContext* executionContext() { return m_scope.scriptState()->executi onContext(); }
61 67
62 private: 68 private:
63 V8TestingScope m_scope; 69 V8TestingScope m_scope;
70 RefPtr<ExecutionContext> m_executionContext;
64 }; 71 };
65 72
66 class FakeWebIDBDatabase FINAL : public blink::WebIDBDatabase { 73 class FakeWebIDBDatabase FINAL : public blink::WebIDBDatabase {
67 public: 74 public:
68 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb IDBDatabase()); } 75 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb IDBDatabase()); }
69 76
70 virtual void commit(long long transactionId) OVERRIDE { } 77 virtual void commit(long long transactionId) OVERRIDE { }
71 virtual void abort(long long transactionId) OVERRIDE { } 78 virtual void abort(long long transactionId) OVERRIDE { }
72 virtual void close() OVERRIDE { } 79 virtual void close() OVERRIDE { }
73 80
74 private: 81 private:
75 FakeWebIDBDatabase() { } 82 FakeWebIDBDatabase() { }
76 }; 83 };
77 84
78 class FakeIDBDatabaseCallbacks FINAL : public IDBDatabaseCallbacks { 85 class FakeIDBDatabaseCallbacks FINAL : public IDBDatabaseCallbacks {
79 public: 86 public:
80 static FakeIDBDatabaseCallbacks* create() { return new FakeIDBDatabaseCallba cks(); } 87 static FakeIDBDatabaseCallbacks* create() { return new FakeIDBDatabaseCallba cks(); }
81 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) OVERRID E { } 88 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) OVERRID E { }
82 virtual void onForcedClose() OVERRIDE { } 89 virtual void onForcedClose() OVERRIDE { }
83 virtual void onAbort(int64_t transactionId, PassRefPtrWillBeRawPtr<DOMError> error) OVERRIDE { } 90 virtual void onAbort(int64_t transactionId, PassRefPtrWillBeRawPtr<DOMError> error) OVERRIDE { }
84 virtual void onComplete(int64_t transactionId) OVERRIDE { } 91 virtual void onComplete(int64_t transactionId) OVERRIDE { }
85 private: 92 private:
86 FakeIDBDatabaseCallbacks() { } 93 FakeIDBDatabaseCallbacks() { }
87 }; 94 };
88 95
89 // crbug.com/379616 96 TEST_F(IDBTransactionTest, EnsureLifetime)
90 #if ENABLE(OILPAN)
91 #define MAYBE_EnsureLifetime DISABLED_EnsureLifetime
92 #else
93 #define MAYBE_EnsureLifetime EnsureLifetime
94 #endif
95 TEST_F(IDBTransactionTest, MAYBE_EnsureLifetime)
96 { 97 {
97 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create(); 98 OwnPtr<FakeWebIDBDatabase> backend = FakeWebIDBDatabase::create();
98 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create()); 99 Persistent<IDBDatabase> db = IDBDatabase::create(executionContext(), backend .release(), FakeIDBDatabaseCallbacks::create());
99 100
100 const int64_t transactionId = 1234; 101 const int64_t transactionId = 1234;
101 const Vector<String> transactionScope; 102 const Vector<String> transactionScope;
102 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon text(), transactionId, transactionScope, blink::WebIDBDatabase::TransactionReadO nly, db.get()); 103 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon text(), transactionId, transactionScope, blink::WebIDBDatabase::TransactionReadO nly, db.get());
103 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; 104 PersistentHeapHashSet<WeakMember<IDBTransaction> > set;
104 set.add(transaction); 105 set.add(transaction);
105 106
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Fire an abort to make sure this doesn't free the transaction during use. The test 153 // Fire an abort to make sure this doesn't free the transaction during use. The test
153 // will not fail if it is, but ASAN would notice the error. 154 // will not fail if it is, but ASAN would notice the error.
154 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); 155 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted"));
155 156
156 // onAbort() should have cleared the transaction's reference to the database . 157 // onAbort() should have cleared the transaction's reference to the database .
157 Heap::collectAllGarbage(); 158 Heap::collectAllGarbage();
158 EXPECT_EQ(0u, set.size()); 159 EXPECT_EQ(0u, set.size());
159 } 160 }
160 161
161 } // namespace 162 } // namespace
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBRequestTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698