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

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

Issue 2890023003: [IndexedDB] Adding async tracing for renderer calls. (Closed)
Patch Set: fixed blink tests Created 3 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
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStop) { 141 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStop) {
142 V8TestingScope scope; 142 V8TestingScope scope;
143 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create(); 143 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create();
144 EXPECT_CALL(*backend, Close()).Times(1); 144 EXPECT_CALL(*backend, Close()).Times(1);
145 BuildTransaction(scope, std::move(backend)); 145 BuildTransaction(scope, std::move(backend));
146 146
147 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 147 ASSERT_TRUE(!scope.GetExceptionState().HadException());
148 ASSERT_TRUE(transaction_); 148 ASSERT_TRUE(transaction_);
149 149
150 IDBRequest* request = IDBRequest::Create( 150 IDBRequest* request =
151 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction_.Get()); 151 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
152 transaction_.Get(), IDBRequest::AsyncTraceState());
153
152 EXPECT_EQ(request->readyState(), "pending"); 154 EXPECT_EQ(request->readyState(), "pending");
153 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 155 ASSERT_TRUE(!scope.GetExceptionState().HadException());
154 ASSERT_TRUE(request->transaction()); 156 ASSERT_TRUE(request->transaction());
155 scope.GetExecutionContext()->NotifyContextDestroyed(); 157 scope.GetExecutionContext()->NotifyContextDestroyed();
156 158
157 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState()); 159 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState());
158 } 160 }
159 161
160 TEST_F(IDBRequestTest, EventsAfterDoneStop) { 162 TEST_F(IDBRequestTest, EventsAfterDoneStop) {
161 V8TestingScope scope; 163 V8TestingScope scope;
162 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create(); 164 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create();
163 EXPECT_CALL(*backend, Close()).Times(1); 165 EXPECT_CALL(*backend, Close()).Times(1);
164 BuildTransaction(scope, std::move(backend)); 166 BuildTransaction(scope, std::move(backend));
165 167
166 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 168 ASSERT_TRUE(!scope.GetExceptionState().HadException());
167 ASSERT_TRUE(transaction_); 169 ASSERT_TRUE(transaction_);
168 170
169 IDBRequest* request = IDBRequest::Create( 171 IDBRequest* request =
170 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction_.Get()); 172 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
173 transaction_.Get(), IDBRequest::AsyncTraceState());
171 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 174 ASSERT_TRUE(!scope.GetExceptionState().HadException());
172 ASSERT_TRUE(request->transaction()); 175 ASSERT_TRUE(request->transaction());
173 request->HandleResponse(CreateIDBValue(scope.GetIsolate(), false)); 176 request->HandleResponse(CreateIDBValue(scope.GetIsolate(), false));
174 scope.GetExecutionContext()->NotifyContextDestroyed(); 177 scope.GetExecutionContext()->NotifyContextDestroyed();
175 178
176 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState()); 179 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState());
177 } 180 }
178 181
179 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStopWithQueuedResult) { 182 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStopWithQueuedResult) {
180 V8TestingScope scope; 183 V8TestingScope scope;
181 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create(); 184 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create();
182 EXPECT_CALL(*backend, Close()).Times(1); 185 EXPECT_CALL(*backend, Close()).Times(1);
183 BuildTransaction(scope, std::move(backend)); 186 BuildTransaction(scope, std::move(backend));
184 187
185 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 188 ASSERT_TRUE(!scope.GetExceptionState().HadException());
186 ASSERT_TRUE(transaction_); 189 ASSERT_TRUE(transaction_);
187 190
188 IDBRequest* request = IDBRequest::Create( 191 IDBRequest* request =
189 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction_.Get()); 192 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
193 transaction_.Get(), IDBRequest::AsyncTraceState());
190 EXPECT_EQ(request->readyState(), "pending"); 194 EXPECT_EQ(request->readyState(), "pending");
191 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 195 ASSERT_TRUE(!scope.GetExceptionState().HadException());
192 ASSERT_TRUE(request->transaction()); 196 ASSERT_TRUE(request->transaction());
193 request->HandleResponse(CreateIDBValue(scope.GetIsolate(), true)); 197 request->HandleResponse(CreateIDBValue(scope.GetIsolate(), true));
194 scope.GetExecutionContext()->NotifyContextDestroyed(); 198 scope.GetExecutionContext()->NotifyContextDestroyed();
195 199
196 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState()); 200 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState());
197 url_loader_mock_factory_->ServeAsynchronousRequests(); 201 url_loader_mock_factory_->ServeAsynchronousRequests();
198 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState()); 202 EnsureIDBCallbacksDontThrow(request, scope.GetExceptionState());
199 } 203 }
200 204
201 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStopWithTwoQueuedResults) { 205 TEST_F(IDBRequestTest, EventsAfterEarlyDeathStopWithTwoQueuedResults) {
202 V8TestingScope scope; 206 V8TestingScope scope;
203 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create(); 207 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::Create();
204 EXPECT_CALL(*backend, Close()).Times(1); 208 EXPECT_CALL(*backend, Close()).Times(1);
205 BuildTransaction(scope, std::move(backend)); 209 BuildTransaction(scope, std::move(backend));
206 210
207 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 211 ASSERT_TRUE(!scope.GetExceptionState().HadException());
208 ASSERT_TRUE(transaction_); 212 ASSERT_TRUE(transaction_);
209 213
210 IDBRequest* request1 = IDBRequest::Create( 214 IDBRequest* request1 =
211 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction_.Get()); 215 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
212 IDBRequest* request2 = IDBRequest::Create( 216 transaction_.Get(), IDBRequest::AsyncTraceState());
213 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction_.Get()); 217 IDBRequest* request2 =
218 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
219 transaction_.Get(), IDBRequest::AsyncTraceState());
214 EXPECT_EQ(request1->readyState(), "pending"); 220 EXPECT_EQ(request1->readyState(), "pending");
215 EXPECT_EQ(request2->readyState(), "pending"); 221 EXPECT_EQ(request2->readyState(), "pending");
216 ASSERT_TRUE(!scope.GetExceptionState().HadException()); 222 ASSERT_TRUE(!scope.GetExceptionState().HadException());
217 ASSERT_TRUE(request1->transaction()); 223 ASSERT_TRUE(request1->transaction());
218 ASSERT_TRUE(request2->transaction()); 224 ASSERT_TRUE(request2->transaction());
219 request1->HandleResponse(CreateIDBValue(scope.GetIsolate(), true)); 225 request1->HandleResponse(CreateIDBValue(scope.GetIsolate(), true));
220 request2->HandleResponse(CreateIDBValue(scope.GetIsolate(), true)); 226 request2->HandleResponse(CreateIDBValue(scope.GetIsolate(), true));
221 scope.GetExecutionContext()->NotifyContextDestroyed(); 227 scope.GetExecutionContext()->NotifyContextDestroyed();
222 228
223 EnsureIDBCallbacksDontThrow(request1, scope.GetExceptionState()); 229 EnsureIDBCallbacksDontThrow(request1, scope.GetExceptionState());
224 EnsureIDBCallbacksDontThrow(request2, scope.GetExceptionState()); 230 EnsureIDBCallbacksDontThrow(request2, scope.GetExceptionState());
225 url_loader_mock_factory_->ServeAsynchronousRequests(); 231 url_loader_mock_factory_->ServeAsynchronousRequests();
226 EnsureIDBCallbacksDontThrow(request1, scope.GetExceptionState()); 232 EnsureIDBCallbacksDontThrow(request1, scope.GetExceptionState());
227 EnsureIDBCallbacksDontThrow(request2, scope.GetExceptionState()); 233 EnsureIDBCallbacksDontThrow(request2, scope.GetExceptionState());
228 } 234 }
229 235
230 TEST_F(IDBRequestTest, AbortErrorAfterAbort) { 236 TEST_F(IDBRequestTest, AbortErrorAfterAbort) {
231 V8TestingScope scope; 237 V8TestingScope scope;
232 IDBTransaction* transaction = nullptr; 238 IDBTransaction* transaction = nullptr;
233 IDBRequest* request = IDBRequest::Create( 239 IDBRequest* request =
234 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); 240 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
241 transaction, IDBRequest::AsyncTraceState());
235 EXPECT_EQ(request->readyState(), "pending"); 242 EXPECT_EQ(request->readyState(), "pending");
236 243
237 // Simulate the IDBTransaction having received OnAbort from back end and 244 // Simulate the IDBTransaction having received OnAbort from back end and
238 // aborting the request: 245 // aborting the request:
239 request->Abort(); 246 request->Abort();
240 247
241 // Now simulate the back end having fired an abort error at the request to 248 // Now simulate the back end having fired an abort error at the request to
242 // clear up any intermediaries. Ensure an assertion is not raised. 249 // clear up any intermediaries. Ensure an assertion is not raised.
243 request->HandleResponse( 250 request->HandleResponse(
244 DOMException::Create(kAbortError, "Description goes here.")); 251 DOMException::Create(kAbortError, "Description goes here."));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_EQ(request->readyState(), "pending"); 284 EXPECT_EQ(request->readyState(), "pending");
278 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks(); 285 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks();
279 286
280 scope.GetExecutionContext()->NotifyContextDestroyed(); 287 scope.GetExecutionContext()->NotifyContextDestroyed();
281 callbacks->OnSuccess(backend.release(), metadata); 288 callbacks->OnSuccess(backend.release(), metadata);
282 } 289 }
283 } 290 }
284 291
285 } // namespace 292 } // namespace
286 } // namespace blink 293 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698