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

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

Issue 2890023003: [IndexedDB] Adding async tracing for renderer calls. (Closed)
Patch Set: test fix Created 3 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "public/platform/modules/indexeddb/WebIDBCallbacks.h" 46 #include "public/platform/modules/indexeddb/WebIDBCallbacks.h"
47 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
48 #include "v8/include/v8.h" 48 #include "v8/include/v8.h"
49 49
50 namespace blink { 50 namespace blink {
51 namespace { 51 namespace {
52 52
53 TEST(IDBRequestTest, EventsAfterStopping) { 53 TEST(IDBRequestTest, EventsAfterStopping) {
54 V8TestingScope scope; 54 V8TestingScope scope;
55 IDBTransaction* transaction = nullptr; 55 IDBTransaction* transaction = nullptr;
56 IDBRequest* request = IDBRequest::Create( 56 IDBRequest* request =
57 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); 57 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
58 transaction, IDBRequest::AsyncTraceState());
58 EXPECT_EQ(request->readyState(), "pending"); 59 EXPECT_EQ(request->readyState(), "pending");
59 scope.GetExecutionContext()->NotifyContextDestroyed(); 60 scope.GetExecutionContext()->NotifyContextDestroyed();
60 61
61 // Ensure none of the following raise assertions in stopped state: 62 // Ensure none of the following raise assertions in stopped state:
62 request->EnqueueResponse( 63 request->EnqueueResponse(
63 DOMException::Create(kAbortError, "Description goes here.")); 64 DOMException::Create(kAbortError, "Description goes here."));
64 request->EnqueueResponse(Vector<String>()); 65 request->EnqueueResponse(Vector<String>());
65 request->EnqueueResponse(nullptr, IDBKey::CreateInvalid(), 66 request->EnqueueResponse(nullptr, IDBKey::CreateInvalid(),
66 IDBKey::CreateInvalid(), IDBValue::Create()); 67 IDBKey::CreateInvalid(), IDBValue::Create());
67 request->EnqueueResponse(IDBKey::CreateInvalid()); 68 request->EnqueueResponse(IDBKey::CreateInvalid());
68 request->EnqueueResponse(IDBValue::Create()); 69 request->EnqueueResponse(IDBValue::Create());
69 request->EnqueueResponse(static_cast<int64_t>(0)); 70 request->EnqueueResponse(static_cast<int64_t>(0));
70 request->EnqueueResponse(); 71 request->EnqueueResponse();
71 request->EnqueueResponse(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(), 72 request->EnqueueResponse(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(),
72 IDBValue::Create()); 73 IDBValue::Create());
73 } 74 }
74 75
75 TEST(IDBRequestTest, AbortErrorAfterAbort) { 76 TEST(IDBRequestTest, AbortErrorAfterAbort) {
76 V8TestingScope scope; 77 V8TestingScope scope;
77 IDBTransaction* transaction = nullptr; 78 IDBTransaction* transaction = nullptr;
78 IDBRequest* request = IDBRequest::Create( 79 IDBRequest* request =
79 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); 80 IDBRequest::Create(scope.GetScriptState(), IDBAny::CreateUndefined(),
81 transaction, IDBRequest::AsyncTraceState());
80 EXPECT_EQ(request->readyState(), "pending"); 82 EXPECT_EQ(request->readyState(), "pending");
81 83
82 // Simulate the IDBTransaction having received OnAbort from back end and 84 // Simulate the IDBTransaction having received OnAbort from back end and
83 // aborting the request: 85 // aborting the request:
84 request->Abort(); 86 request->Abort();
85 87
86 // Now simulate the back end having fired an abort error at the request to 88 // Now simulate the back end having fired an abort error at the request to
87 // clear up any intermediaries. Ensure an assertion is not raised. 89 // clear up any intermediaries. Ensure an assertion is not raised.
88 request->EnqueueResponse( 90 request->EnqueueResponse(
89 DOMException::Create(kAbortError, "Description goes here.")); 91 DOMException::Create(kAbortError, "Description goes here."));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_EQ(request->readyState(), "pending"); 124 EXPECT_EQ(request->readyState(), "pending");
123 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks(); 125 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks();
124 126
125 scope.GetExecutionContext()->NotifyContextDestroyed(); 127 scope.GetExecutionContext()->NotifyContextDestroyed();
126 callbacks->OnSuccess(backend.release(), metadata); 128 callbacks->OnSuccess(backend.release(), metadata);
127 } 129 }
128 } 130 }
129 131
130 } // namespace 132 } // namespace
131 } // namespace blink 133 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698