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

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

Issue 295163005: Remove ScriptState::current() from IDBRequest (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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
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(V8ExecutionScope::create(v8::Isolate::GetCurrent())) 53 : m_scope(V8TestingScope::create(v8::Isolate::GetCurrent()))
54 , m_document(Document::create())
55 { 54 {
55 m_scope->scriptState()->setExecutionContext(Document::create());
56 } 56 }
57 57
58 ExecutionContext* executionContext() 58 v8::Isolate* isolate() const { return m_scope->isolate(); }
59 { 59 ScriptState* scriptState() const { return m_scope->scriptState(); }
60 return m_document.get(); 60 ExecutionContext* executionContext() { return m_scope->scriptState()->execut ionContext(); }
61 }
62 61
63 private: 62 private:
64 OwnPtr<V8ExecutionScope> m_scope; 63 OwnPtr<V8TestingScope> m_scope;
65 RefPtr<Document> m_document;
66 }; 64 };
67 65
68 class FakeWebIDBDatabase FINAL : public blink::WebIDBDatabase { 66 class FakeWebIDBDatabase FINAL : public blink::WebIDBDatabase {
69 public: 67 public:
70 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb IDBDatabase()); } 68 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb IDBDatabase()); }
71 69
72 virtual void commit(long long transactionId) OVERRIDE { } 70 virtual void commit(long long transactionId) OVERRIDE { }
73 virtual void abort(long long transactionId) OVERRIDE { } 71 virtual void abort(long long transactionId) OVERRIDE { }
74 virtual void close() OVERRIDE { } 72 virtual void close() OVERRIDE { }
75 73
(...skipping 19 matching lines...) Expand all
95 93
96 const int64_t transactionId = 1234; 94 const int64_t transactionId = 1234;
97 const Vector<String> transactionScope; 95 const Vector<String> transactionScope;
98 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon text(), transactionId, transactionScope, blink::WebIDBDatabase::TransactionReadO nly, db.get()); 96 Persistent<IDBTransaction> transaction = IDBTransaction::create(executionCon text(), transactionId, transactionScope, blink::WebIDBDatabase::TransactionReadO nly, db.get());
99 PersistentHeapHashSet<WeakMember<IDBTransaction> > set; 97 PersistentHeapHashSet<WeakMember<IDBTransaction> > set;
100 set.add(transaction); 98 set.add(transaction);
101 99
102 Heap::collectAllGarbage(); 100 Heap::collectAllGarbage();
103 EXPECT_EQ(1u, set.size()); 101 EXPECT_EQ(1u, set.size());
104 102
105 Persistent<IDBRequest> request = IDBRequest::create(executionContext(), IDBA ny::createUndefined(), transaction); 103 Persistent<IDBRequest> request = IDBRequest::create(scriptState(), IDBAny::c reateUndefined(), transaction.get());
106 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac tions(); 104 IDBPendingTransactionMonitor::from(*executionContext()).deactivateNewTransac tions();
107 105
108 Heap::collectAllGarbage(); 106 Heap::collectAllGarbage();
109 EXPECT_EQ(1u, set.size()); 107 EXPECT_EQ(1u, set.size());
110 108
111 // This will generate an abort() call to the back end which is dropped by th e fake proxy, 109 // This will generate an abort() call to the back end which is dropped by th e fake proxy,
112 // so an explicit onAbort call is made. 110 // so an explicit onAbort call is made.
113 executionContext()->stopActiveDOMObjects(); 111 executionContext()->stopActiveDOMObjects();
114 transaction->onAbort(DOMError::create(AbortError, "Aborted")); 112 transaction->onAbort(DOMError::create(AbortError, "Aborted"));
115 transaction.clear(); 113 transaction.clear();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Fire an abort to make sure this doesn't free the transaction during use. The test 146 // Fire an abort to make sure this doesn't free the transaction during use. The test
149 // will not fail if it is, but ASAN would notice the error. 147 // will not fail if it is, but ASAN would notice the error.
150 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); 148 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted"));
151 149
152 // onAbort() should have cleared the transaction's reference to the database . 150 // onAbort() should have cleared the transaction's reference to the database .
153 Heap::collectAllGarbage(); 151 Heap::collectAllGarbage();
154 EXPECT_EQ(0u, set.size()); 152 EXPECT_EQ(0u, set.size());
155 } 153 }
156 154
157 } // namespace 155 } // namespace
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBRequestTest.cpp ('k') | Source/modules/indexeddb/InspectorIndexedDBAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698