| 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 15 matching lines...) Expand all Loading... |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/indexeddb/IDBRequest.h" | 27 #include "modules/indexeddb/IDBRequest.h" |
| 28 | 28 |
| 29 #include "core/dom/DOMError.h" | 29 #include "core/dom/DOMError.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/events/EventQueue.h" | 31 #include "core/events/EventQueue.h" |
| 32 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 32 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 33 #include "modules/indexeddb/IDBKeyRange.h" | 33 #include "modules/indexeddb/IDBKeyRange.h" |
| 34 #include "modules/indexeddb/IDBOpenDBRequest.h" | 34 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 35 #include "platform/SharedBuffer.h" | 35 #include "platform/SharedBuffer.h" |
| 36 #include "platform/blob/BlobInfo.h" |
| 36 #include "public/platform/WebIDBDatabase.h" | 37 #include "public/platform/WebIDBDatabase.h" |
| 37 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 38 #include <gtest/gtest.h> | 39 #include <gtest/gtest.h> |
| 39 | 40 |
| 40 using namespace WebCore; | 41 using namespace WebCore; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 class NullEventQueue : public EventQueue { | 45 class NullEventQueue : public EventQueue { |
| 45 public: | 46 public: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TEST_F(IDBRequestTest, EventsAfterStopping) | 93 TEST_F(IDBRequestTest, EventsAfterStopping) |
| 93 { | 94 { |
| 94 IDBTransaction* transaction = 0; | 95 IDBTransaction* transaction = 0; |
| 95 RefPtr<IDBRequest> request = IDBRequest::create(executionContext(), IDBAny::
createUndefined(), transaction); | 96 RefPtr<IDBRequest> request = IDBRequest::create(executionContext(), IDBAny::
createUndefined(), transaction); |
| 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()
, 0); | 103 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
, 0, adoptPtr(new Vector<BlobInfo>())); |
| 103 request->onSuccess(IDBKey::createInvalid()); | 104 request->onSuccess(IDBKey::createInvalid()); |
| 104 request->onSuccess(PassRefPtr<SharedBuffer>(0)); | 105 request->onSuccess(PassRefPtr<SharedBuffer>(0), adoptPtr(new Vector<BlobInfo
>())); |
| 105 request->onSuccess(PassRefPtr<SharedBuffer>(0), IDBKey::createInvalid(), IDB
KeyPath()); | 106 request->onSuccess(PassRefPtr<SharedBuffer>(0), adoptPtr(new Vector<BlobInfo
>()), IDBKey::createInvalid(), IDBKeyPath()); |
| 106 request->onSuccess(0LL); | 107 request->onSuccess(0LL); |
| 107 request->onSuccess(); | 108 request->onSuccess(); |
| 108 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), 0); | 109 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), 0, adop
tPtr(new Vector<BlobInfo>())); |
| 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 RefPtr<IDBRequest> request = IDBRequest::create(executionContext(), IDBAny::
createUndefined(), transaction); | 115 RefPtr<IDBRequest> request = IDBRequest::create(executionContext(), 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(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 170 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 170 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(executionCon
text(), callbacks, transactionId, version); | 171 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(executionCon
text(), 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 |
| OLD | NEW |