| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/indexeddb/IDBRequest.h" | 27 #include "modules/indexeddb/IDBRequest.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ScriptState.h" | 29 #include "bindings/core/v8/ScriptState.h" |
| 30 #include "bindings/core/v8/V8Binding.h" | 30 #include "bindings/core/v8/V8Binding.h" |
| 31 #include "bindings/core/v8/V8BindingForTesting.h" | 31 #include "bindings/core/v8/V8BindingForTesting.h" |
| 32 #include "core/dom/DOMError.h" | 32 #include "core/dom/DOMException.h" |
| 33 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
| 34 #include "core/testing/NullExecutionContext.h" | 35 #include "core/testing/NullExecutionContext.h" |
| 35 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 36 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 36 #include "modules/indexeddb/IDBKey.h" | 37 #include "modules/indexeddb/IDBKey.h" |
| 37 #include "modules/indexeddb/IDBKeyRange.h" | 38 #include "modules/indexeddb/IDBKeyRange.h" |
| 38 #include "modules/indexeddb/IDBOpenDBRequest.h" | 39 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 39 #include "modules/indexeddb/IDBValue.h" | 40 #include "modules/indexeddb/IDBValue.h" |
| 40 #include "platform/SharedBuffer.h" | 41 #include "platform/SharedBuffer.h" |
| 41 #include "public/platform/WebBlobInfo.h" | 42 #include "public/platform/WebBlobInfo.h" |
| 42 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" | 43 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 TEST_F(IDBRequestTest, EventsAfterStopping) | 83 TEST_F(IDBRequestTest, EventsAfterStopping) |
| 83 { | 84 { |
| 84 IDBTransaction* transaction = nullptr; | 85 IDBTransaction* transaction = nullptr; |
| 85 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); | 86 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); |
| 86 EXPECT_EQ(request->readyState(), "pending"); | 87 EXPECT_EQ(request->readyState(), "pending"); |
| 87 executionContext()->stopActiveDOMObjects(); | 88 executionContext()->stopActiveDOMObjects(); |
| 88 | 89 |
| 89 // Ensure none of the following raise assertions in stopped state: | 90 // Ensure none of the following raise assertions in stopped state: |
| 90 request->onError(DOMError::create(AbortError, "Description goes here.")); | 91 request->onError(DOMException::create(AbortError, "Description goes here."))
; |
| 91 request->onSuccess(Vector<String>()); | 92 request->onSuccess(Vector<String>()); |
| 92 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
, IDBValue::create()); | 93 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
, IDBValue::create()); |
| 93 request->onSuccess(IDBKey::createInvalid()); | 94 request->onSuccess(IDBKey::createInvalid()); |
| 94 request->onSuccess(IDBValue::create()); | 95 request->onSuccess(IDBValue::create()); |
| 95 request->onSuccess(static_cast<int64_t>(0)); | 96 request->onSuccess(static_cast<int64_t>(0)); |
| 96 request->onSuccess(); | 97 request->onSuccess(); |
| 97 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu
e::create()); | 98 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu
e::create()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 TEST_F(IDBRequestTest, AbortErrorAfterAbort) | 101 TEST_F(IDBRequestTest, AbortErrorAfterAbort) |
| 101 { | 102 { |
| 102 IDBTransaction* transaction = nullptr; | 103 IDBTransaction* transaction = nullptr; |
| 103 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); | 104 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); |
| 104 EXPECT_EQ(request->readyState(), "pending"); | 105 EXPECT_EQ(request->readyState(), "pending"); |
| 105 | 106 |
| 106 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: | 107 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: |
| 107 request->abort(); | 108 request->abort(); |
| 108 | 109 |
| 109 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. | 110 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. |
| 110 // Ensure an assertion is not raised. | 111 // Ensure an assertion is not raised. |
| 111 request->onError(DOMError::create(AbortError, "Description goes here.")); | 112 request->onError(DOMException::create(AbortError, "Description goes here."))
; |
| 112 | 113 |
| 113 // Stop the request lest it be GCed and its destructor | 114 // Stop the request lest it be GCed and its destructor |
| 114 // finds the object in a pending state (and asserts.) | 115 // finds the object in a pending state (and asserts.) |
| 115 executionContext()->stopActiveDOMObjects(); | 116 executionContext()->stopActiveDOMObjects(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 class MockWebIDBDatabase : public WebIDBDatabase { | 119 class MockWebIDBDatabase : public WebIDBDatabase { |
| 119 public: | 120 public: |
| 120 static PassOwnPtr<MockWebIDBDatabase> create() | 121 static PassOwnPtr<MockWebIDBDatabase> create() |
| 121 { | 122 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 164 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
| 164 EXPECT_EQ(request->readyState(), "pending"); | 165 EXPECT_EQ(request->readyState(), "pending"); |
| 165 | 166 |
| 166 executionContext()->stopActiveDOMObjects(); | 167 executionContext()->stopActiveDOMObjects(); |
| 167 request->onSuccess(backend.release(), metadata); | 168 request->onSuccess(backend.release(), metadata); |
| 168 } | 169 } |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace | 172 } // namespace |
| 172 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |