| 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 "public/platform/WebBlobInfo.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 | 
|  | 41 using blink::WebBlobInfo; | 
| 40 using namespace WebCore; | 42 using namespace WebCore; | 
| 41 | 43 | 
| 42 namespace { | 44 namespace { | 
| 43 | 45 | 
| 44 class NullEventQueue FINAL : public EventQueue { | 46 class NullEventQueue FINAL : public EventQueue { | 
| 45 public: | 47 public: | 
| 46     NullEventQueue() { } | 48     NullEventQueue() { } | 
| 47     virtual ~NullEventQueue() { } | 49     virtual ~NullEventQueue() { } | 
| 48     virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
     rue; } | 50     virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
     rue; } | 
| 49     virtual bool cancelEvent(Event*) OVERRIDE { return true; } | 51     virtual bool cancelEvent(Event*) OVERRIDE { return true; } | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 90 TEST_F(IDBRequestTest, EventsAfterStopping) | 92 TEST_F(IDBRequestTest, EventsAfterStopping) | 
| 91 { | 93 { | 
| 92     IDBTransaction* transaction = 0; | 94     IDBTransaction* transaction = 0; | 
| 93     RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
     (), IDBAny::createUndefined(), transaction); | 95     RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
     (), IDBAny::createUndefined(), transaction); | 
| 94     EXPECT_EQ(request->readyState(), "pending"); | 96     EXPECT_EQ(request->readyState(), "pending"); | 
| 95     executionContext()->stopActiveDOMObjects(); | 97     executionContext()->stopActiveDOMObjects(); | 
| 96 | 98 | 
| 97     // Ensure none of the following raise assertions in stopped state: | 99     // Ensure none of the following raise assertions in stopped state: | 
| 98     request->onError(DOMError::create(AbortError, "Description goes here.")); | 100     request->onError(DOMError::create(AbortError, "Description goes here.")); | 
| 99     request->onSuccess(Vector<String>()); | 101     request->onSuccess(Vector<String>()); | 
| 100     request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
     , nullptr); | 102     request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
     , nullptr, adoptPtr(new Vector<WebBlobInfo>())); | 
| 101     request->onSuccess(IDBKey::createInvalid()); | 103     request->onSuccess(IDBKey::createInvalid()); | 
| 102     request->onSuccess(PassRefPtr<SharedBuffer>(nullptr)); | 104     request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
     bBlobInfo>())); | 
| 103     request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), IDBKey::createInvalid(
     ), IDBKeyPath()); | 105     request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
     bBlobInfo>()), IDBKey::createInvalid(), IDBKeyPath()); | 
| 104     request->onSuccess(0LL); | 106     request->onSuccess(0LL); | 
| 105     request->onSuccess(); | 107     request->onSuccess(); | 
| 106     request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr
     ); | 108     request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr
     , adoptPtr(new Vector<WebBlobInfo>())); | 
| 107 } | 109 } | 
| 108 | 110 | 
| 109 TEST_F(IDBRequestTest, AbortErrorAfterAbort) | 111 TEST_F(IDBRequestTest, AbortErrorAfterAbort) | 
| 110 { | 112 { | 
| 111     IDBTransaction* transaction = 0; | 113     IDBTransaction* transaction = 0; | 
| 112     RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
     (), IDBAny::createUndefined(), transaction); | 114     RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
     (), IDBAny::createUndefined(), transaction); | 
| 113     EXPECT_EQ(request->readyState(), "pending"); | 115     EXPECT_EQ(request->readyState(), "pending"); | 
| 114 | 116 | 
| 115     // Simulate the IDBTransaction having received onAbort from back end and abo
     rting the request: | 117     // Simulate the IDBTransaction having received onAbort from back end and abo
     rting the request: | 
| 116     request->abort(); | 118     request->abort(); | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 167         OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 169         OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 
| 168         RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
     executionContext(), callbacks, transactionId, version); | 170         RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
     executionContext(), callbacks, transactionId, version); | 
| 169         EXPECT_EQ(request->readyState(), "pending"); | 171         EXPECT_EQ(request->readyState(), "pending"); | 
| 170 | 172 | 
| 171         executionContext()->stopActiveDOMObjects(); | 173         executionContext()->stopActiveDOMObjects(); | 
| 172         request->onSuccess(backend.release(), metadata); | 174         request->onSuccess(backend.release(), metadata); | 
| 173     } | 175     } | 
| 174 } | 176 } | 
| 175 | 177 | 
| 176 } // namespace | 178 } // namespace | 
| OLD | NEW | 
|---|