| OLD | NEW |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = IDBRequest::Create( |
| 57 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); | 57 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); |
| 58 EXPECT_EQ(request->readyState(), "pending"); | 58 EXPECT_EQ(request->readyState(), "pending"); |
| 59 scope.GetExecutionContext()->NotifyContextDestroyed(); | 59 scope.GetExecutionContext()->NotifyContextDestroyed(); |
| 60 | 60 |
| 61 // Ensure none of the following raise assertions in stopped state: | 61 // Ensure none of the following raise assertions in stopped state: |
| 62 request->OnError(DOMException::Create(kAbortError, "Description goes here.")); | 62 request->EnqueueResponse( |
| 63 request->OnSuccess(Vector<String>()); | 63 DOMException::Create(kAbortError, "Description goes here.")); |
| 64 request->OnSuccess(nullptr, IDBKey::CreateInvalid(), IDBKey::CreateInvalid(), | 64 request->EnqueueResponse(Vector<String>()); |
| 65 IDBValue::Create()); | 65 request->EnqueueResponse(nullptr, IDBKey::CreateInvalid(), |
| 66 request->OnSuccess(IDBKey::CreateInvalid()); | 66 IDBKey::CreateInvalid(), IDBValue::Create()); |
| 67 request->OnSuccess(IDBValue::Create()); | 67 request->EnqueueResponse(IDBKey::CreateInvalid()); |
| 68 request->OnSuccess(static_cast<int64_t>(0)); | 68 request->EnqueueResponse(IDBValue::Create()); |
| 69 request->OnSuccess(); | 69 request->EnqueueResponse(static_cast<int64_t>(0)); |
| 70 request->OnSuccess(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(), | 70 request->EnqueueResponse(); |
| 71 IDBValue::Create()); | 71 request->EnqueueResponse(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(), |
| 72 IDBValue::Create()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 TEST(IDBRequestTest, AbortErrorAfterAbort) { | 75 TEST(IDBRequestTest, AbortErrorAfterAbort) { |
| 75 V8TestingScope scope; | 76 V8TestingScope scope; |
| 76 IDBTransaction* transaction = nullptr; | 77 IDBTransaction* transaction = nullptr; |
| 77 IDBRequest* request = IDBRequest::Create( | 78 IDBRequest* request = IDBRequest::Create( |
| 78 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); | 79 scope.GetScriptState(), IDBAny::CreateUndefined(), transaction); |
| 79 EXPECT_EQ(request->readyState(), "pending"); | 80 EXPECT_EQ(request->readyState(), "pending"); |
| 80 | 81 |
| 81 // Simulate the IDBTransaction having received OnAbort from back end and | 82 // Simulate the IDBTransaction having received OnAbort from back end and |
| 82 // aborting the request: | 83 // aborting the request: |
| 83 request->Abort(); | 84 request->Abort(); |
| 84 | 85 |
| 85 // Now simulate the back end having fired an abort error at the request to | 86 // Now simulate the back end having fired an abort error at the request to |
| 86 // clear up any intermediaries. Ensure an assertion is not raised. | 87 // clear up any intermediaries. Ensure an assertion is not raised. |
| 87 request->OnError(DOMException::Create(kAbortError, "Description goes here.")); | 88 request->EnqueueResponse( |
| 89 DOMException::Create(kAbortError, "Description goes here.")); |
| 88 | 90 |
| 89 // Stop the request lest it be GCed and its destructor | 91 // Stop the request lest it be GCed and its destructor |
| 90 // finds the object in a pending state (and asserts.) | 92 // finds the object in a pending state (and asserts.) |
| 91 scope.GetExecutionContext()->NotifyContextDestroyed(); | 93 scope.GetExecutionContext()->NotifyContextDestroyed(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 TEST(IDBRequestTest, ConnectionsAfterStopping) { | 96 TEST(IDBRequestTest, ConnectionsAfterStopping) { |
| 95 V8TestingScope scope; | 97 V8TestingScope scope; |
| 96 const int64_t kTransactionId = 1234; | 98 const int64_t kTransactionId = 1234; |
| 97 const int64_t kVersion = 1; | 99 const int64_t kVersion = 1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 120 EXPECT_EQ(request->readyState(), "pending"); | 122 EXPECT_EQ(request->readyState(), "pending"); |
| 121 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks(); | 123 std::unique_ptr<WebIDBCallbacks> callbacks = request->CreateWebCallbacks(); |
| 122 | 124 |
| 123 scope.GetExecutionContext()->NotifyContextDestroyed(); | 125 scope.GetExecutionContext()->NotifyContextDestroyed(); |
| 124 callbacks->OnSuccess(backend.release(), metadata); | 126 callbacks->OnSuccess(backend.release(), metadata); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 } // namespace | 130 } // namespace |
| 129 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |