| 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 10 matching lines...) Expand all Loading... |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 "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/dom/SecurityContext.h" |
| 31 #include "core/events/EventQueue.h" | 32 #include "core/events/EventQueue.h" |
| 32 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 33 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 33 #include "modules/indexeddb/IDBKeyRange.h" | 34 #include "modules/indexeddb/IDBKeyRange.h" |
| 34 #include "modules/indexeddb/IDBOpenDBRequest.h" | 35 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 35 #include "platform/SharedBuffer.h" | 36 #include "platform/SharedBuffer.h" |
| 36 #include "public/platform/WebBlobInfo.h" | 37 #include "public/platform/WebBlobInfo.h" |
| 37 #include "public/platform/WebIDBDatabase.h" | 38 #include "public/platform/WebIDBDatabase.h" |
| 38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
| 39 #include <gtest/gtest.h> | 40 #include <gtest/gtest.h> |
| 40 #include <v8.h> | 41 #include <v8.h> |
| 41 | 42 |
| 42 using blink::WebBlobInfo; | 43 using blink::WebBlobInfo; |
| 43 using namespace WebCore; | 44 using namespace WebCore; |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 class NullEventQueue FINAL : public EventQueue { | 48 class NullEventQueue FINAL : public EventQueue { |
| 48 public: | 49 public: |
| 49 NullEventQueue() { } | 50 NullEventQueue() { } |
| 50 virtual ~NullEventQueue() { } | 51 virtual ~NullEventQueue() { } |
| 51 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } | 52 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } |
| 52 virtual bool cancelEvent(Event*) OVERRIDE { return true; } | 53 virtual bool cancelEvent(Event*) OVERRIDE { return true; } |
| 53 virtual void close() OVERRIDE { } | 54 virtual void close() OVERRIDE { } |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 class NullExecutionContext FINAL : public RefCountedWillBeGarbageCollectedFinali
zed<NullExecutionContext>, public ExecutionContext { | 57 class NullExecutionContext FINAL : public RefCountedWillBeGarbageCollectedFinali
zed<NullExecutionContext>, public SecurityContext, public ExecutionContext { |
| 57 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); | 58 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); |
| 58 public: | 59 public: |
| 59 void trace(Visitor* visitor) { ExecutionContext::trace(visitor); } | 60 void trace(Visitor* visitor) { ExecutionContext::trace(visitor); } |
| 60 #if !ENABLE(OILPAN) | 61 #if !ENABLE(OILPAN) |
| 61 using RefCounted<NullExecutionContext>::ref; | 62 using RefCounted<NullExecutionContext>::ref; |
| 62 using RefCounted<NullExecutionContext>::deref; | 63 using RefCounted<NullExecutionContext>::deref; |
| 63 | 64 |
| 65 virtual void reportBlockedScriptExecutionToInspector(const String& directive
Text) OVERRIDE { } |
| 66 |
| 67 virtual SecurityContext& securityContext() { return *this; } |
| 68 |
| 64 virtual void refExecutionContext() OVERRIDE { ref(); } | 69 virtual void refExecutionContext() OVERRIDE { ref(); } |
| 65 virtual void derefExecutionContext() OVERRIDE { deref(); } | 70 virtual void derefExecutionContext() OVERRIDE { deref(); } |
| 66 #endif | 71 #endif |
| 67 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } | 72 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } |
| 68 | 73 |
| 69 NullExecutionContext(); | 74 NullExecutionContext(); |
| 75 |
| 76 protected: |
| 77 virtual const KURL& virtualURL() const OVERRIDE { return m_dummyURL; } |
| 78 virtual KURL virtualCompleteURL(const String&) const OVERRIDE { return m_dum
myURL; } |
| 79 |
| 70 private: | 80 private: |
| 71 OwnPtr<EventQueue> m_queue; | 81 OwnPtr<EventQueue> m_queue; |
| 82 |
| 83 KURL m_dummyURL; |
| 72 }; | 84 }; |
| 73 | 85 |
| 74 NullExecutionContext::NullExecutionContext() | 86 NullExecutionContext::NullExecutionContext() |
| 75 : m_queue(adoptPtr(new NullEventQueue())) | 87 : m_queue(adoptPtr(new NullEventQueue())) |
| 76 { | 88 { |
| 77 } | 89 } |
| 78 | 90 |
| 79 class IDBRequestTest : public testing::Test { | 91 class IDBRequestTest : public testing::Test { |
| 80 public: | 92 public: |
| 81 IDBRequestTest() | 93 IDBRequestTest() |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 191 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 180 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 192 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
| 181 EXPECT_EQ(request->readyState(), "pending"); | 193 EXPECT_EQ(request->readyState(), "pending"); |
| 182 | 194 |
| 183 executionContext()->stopActiveDOMObjects(); | 195 executionContext()->stopActiveDOMObjects(); |
| 184 request->onSuccess(backend.release(), metadata); | 196 request->onSuccess(backend.release(), metadata); |
| 185 } | 197 } |
| 186 } | 198 } |
| 187 | 199 |
| 188 } // namespace | 200 } // namespace |
| OLD | NEW |