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

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

Issue 295163005: Remove ScriptState::current() from IDBRequest (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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) 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 }; 67 };
68 68
69 NullExecutionContext::NullExecutionContext() 69 NullExecutionContext::NullExecutionContext()
70 : m_queue(adoptPtr(new NullEventQueue())) 70 : m_queue(adoptPtr(new NullEventQueue()))
71 { 71 {
72 } 72 }
73 73
74 class IDBRequestTest : public testing::Test { 74 class IDBRequestTest : public testing::Test {
75 public: 75 public:
76 IDBRequestTest() 76 IDBRequestTest()
77 : m_scope(V8ExecutionScope::create(v8::Isolate::GetCurrent())) 77 : m_scope(V8TestingScope::create(v8::Isolate::GetCurrent()))
78 , m_context(adoptRef(new NullExecutionContext()))
79 { 78 {
79 m_scope->scriptState()->setExecutionContext(adoptRef(new NullExecutionCo ntext()));
80 } 80 }
81 81
82 ExecutionContext* executionContext() 82 v8::Isolate* isolate() const { return m_scope->isolate(); }
83
84 ExecutionContext* executionContext() const
83 { 85 {
84 return m_context.get(); 86 return m_scope->scriptState()->executionContext();
85 } 87 }
86 88
87 private: 89 private:
88 OwnPtr<V8ExecutionScope> m_scope; 90 OwnPtr<V8TestingScope> m_scope;
89 RefPtr<ExecutionContext> m_context;
90 }; 91 };
91 92
92 TEST_F(IDBRequestTest, EventsAfterStopping) 93 TEST_F(IDBRequestTest, EventsAfterStopping)
93 { 94 {
94 IDBTransaction* transaction = 0; 95 IDBTransaction* transaction = 0;
95 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext (), IDBAny::createUndefined(), transaction); 96 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(ScriptState::cur rent(isolate()), IDBAny::createUndefined(), transaction);
jsbell 2014/05/27 18:38:47 Just isolate() here, rather than ScriptState::curr
haraken 2014/05/28 00:35:49 We need to pass ScriptState*, so replaced with scr
jsbell 2014/05/28 01:21:57 Oops, yeah. That. :)
96 EXPECT_EQ(request->readyState(), "pending"); 97 EXPECT_EQ(request->readyState(), "pending");
97 executionContext()->stopActiveDOMObjects(); 98 executionContext()->stopActiveDOMObjects();
98 99
99 // Ensure none of the following raise assertions in stopped state: 100 // Ensure none of the following raise assertions in stopped state:
100 request->onError(DOMError::create(AbortError, "Description goes here.")); 101 request->onError(DOMError::create(AbortError, "Description goes here."));
101 request->onSuccess(Vector<String>()); 102 request->onSuccess(Vector<String>());
102 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , nullptr, adoptPtr(new Vector<WebBlobInfo>())); 103 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , nullptr, adoptPtr(new Vector<WebBlobInfo>()));
103 request->onSuccess(IDBKey::createInvalid()); 104 request->onSuccess(IDBKey::createInvalid());
104 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We bBlobInfo>())); 105 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We bBlobInfo>()));
105 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We bBlobInfo>()), IDBKey::createInvalid(), IDBKeyPath()); 106 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We bBlobInfo>()), IDBKey::createInvalid(), IDBKeyPath());
106 request->onSuccess(0LL); 107 request->onSuccess(0LL);
107 request->onSuccess(); 108 request->onSuccess();
108 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr , adoptPtr(new Vector<WebBlobInfo>())); 109 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr , adoptPtr(new Vector<WebBlobInfo>()));
109 } 110 }
110 111
111 TEST_F(IDBRequestTest, AbortErrorAfterAbort) 112 TEST_F(IDBRequestTest, AbortErrorAfterAbort)
112 { 113 {
113 IDBTransaction* transaction = 0; 114 IDBTransaction* transaction = 0;
114 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext (), IDBAny::createUndefined(), transaction); 115 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(ScriptState::cur rent(isolate()), IDBAny::createUndefined(), transaction);
115 EXPECT_EQ(request->readyState(), "pending"); 116 EXPECT_EQ(request->readyState(), "pending");
116 117
117 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request: 118 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request:
118 request->abort(); 119 request->abort();
119 120
120 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries. 121 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries.
121 // Ensure an assertion is not raised. 122 // Ensure an assertion is not raised.
122 request->onError(DOMError::create(AbortError, "Description goes here.")); 123 request->onError(DOMError::create(AbortError, "Description goes here."));
123 } 124 }
124 125
(...skipping 26 matching lines...) Expand all
151 TEST_F(IDBRequestTest, ConnectionsAfterStopping) 152 TEST_F(IDBRequestTest, ConnectionsAfterStopping)
152 { 153 {
153 const int64_t transactionId = 1234; 154 const int64_t transactionId = 1234;
154 const int64_t version = 1; 155 const int64_t version = 1;
155 const int64_t oldVersion = 0; 156 const int64_t oldVersion = 0;
156 const IDBDatabaseMetadata metadata; 157 const IDBDatabaseMetadata metadata;
157 RefPtrWillBePersistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallback s::create(); 158 RefPtrWillBePersistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallback s::create();
158 159
159 { 160 {
160 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 161 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
161 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create( executionContext(), callbacks, transactionId, version); 162 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create( ScriptState::current(isolate()), callbacks, transactionId, version);
162 EXPECT_EQ(request->readyState(), "pending"); 163 EXPECT_EQ(request->readyState(), "pending");
163 164
164 executionContext()->stopActiveDOMObjects(); 165 executionContext()->stopActiveDOMObjects();
165 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, blink: :WebIDBDataLossNone, String()); 166 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, blink: :WebIDBDataLossNone, String());
166 } 167 }
167 168
168 { 169 {
169 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 170 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
170 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create( executionContext(), callbacks, transactionId, version); 171 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create( ScriptState::current(isolate()), callbacks, transactionId, version);
171 EXPECT_EQ(request->readyState(), "pending"); 172 EXPECT_EQ(request->readyState(), "pending");
172 173
173 executionContext()->stopActiveDOMObjects(); 174 executionContext()->stopActiveDOMObjects();
174 request->onSuccess(backend.release(), metadata); 175 request->onSuccess(backend.release(), metadata);
175 } 176 }
176 } 177 }
177 178
178 } // namespace 179 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698