| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 class NullEventQueue FINAL : public EventQueue { | 47 class NullEventQueue FINAL : public EventQueue { |
| 48 public: | 48 public: |
| 49 NullEventQueue() { } | 49 NullEventQueue() { } |
| 50 virtual ~NullEventQueue() { } | 50 virtual ~NullEventQueue() { } |
| 51 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } | 51 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } |
| 52 virtual bool cancelEvent(Event*) OVERRIDE { return true; } | 52 virtual bool cancelEvent(Event*) OVERRIDE { return true; } |
| 53 virtual void close() OVERRIDE { } | 53 virtual void close() OVERRIDE { } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class NullExecutionContext FINAL : public RefCountedWillBeGarbageCollectedFinali
zed<NullExecutionContext>, public ExecutionContext { | 56 class NullExecutionContext FINAL : public ExecutionContext, public RefCounted<Nu
llExecutionContext> { |
| 57 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); | |
| 58 public: | 57 public: |
| 59 void trace(Visitor* visitor) { ExecutionContext::trace(visitor); } | |
| 60 #if !ENABLE(OILPAN) | |
| 61 using RefCounted<NullExecutionContext>::ref; | 58 using RefCounted<NullExecutionContext>::ref; |
| 62 using RefCounted<NullExecutionContext>::deref; | 59 using RefCounted<NullExecutionContext>::deref; |
| 63 | 60 |
| 64 virtual void refExecutionContext() OVERRIDE { ref(); } | 61 virtual void refExecutionContext() OVERRIDE { ref(); } |
| 65 virtual void derefExecutionContext() OVERRIDE { deref(); } | 62 virtual void derefExecutionContext() OVERRIDE { deref(); } |
| 66 #endif | |
| 67 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } | 63 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } |
| 68 | 64 |
| 69 NullExecutionContext(); | 65 NullExecutionContext(); |
| 70 private: | 66 private: |
| 71 OwnPtr<EventQueue> m_queue; | 67 OwnPtr<EventQueue> m_queue; |
| 72 }; | 68 }; |
| 73 | 69 |
| 74 NullExecutionContext::NullExecutionContext() | 70 NullExecutionContext::NullExecutionContext() |
| 75 : m_queue(adoptPtr(new NullEventQueue())) | 71 : m_queue(adoptPtr(new NullEventQueue())) |
| 76 { | 72 { |
| 77 } | 73 } |
| 78 | 74 |
| 79 class IDBRequestTest : public testing::Test { | 75 class IDBRequestTest : public testing::Test { |
| 80 public: | 76 public: |
| 81 IDBRequestTest() | 77 IDBRequestTest() |
| 82 : m_scope(v8::Isolate::GetCurrent()) | 78 : m_scope(v8::Isolate::GetCurrent()) |
| 83 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext())) | 79 , m_executionContext(adoptRef(new NullExecutionContext())) |
| 84 { | 80 { |
| 85 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); | 81 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); |
| 86 } | 82 } |
| 87 | 83 |
| 88 ~IDBRequestTest() | 84 ~IDBRequestTest() |
| 89 { | 85 { |
| 90 m_scope.scriptState()->setExecutionContext(0); | 86 m_scope.scriptState()->setExecutionContext(0); |
| 91 } | 87 } |
| 92 | 88 |
| 93 v8::Isolate* isolate() const { return m_scope.isolate(); } | 89 v8::Isolate* isolate() const { return m_scope.isolate(); } |
| 94 ScriptState* scriptState() const { return m_scope.scriptState(); } | 90 ScriptState* scriptState() const { return m_scope.scriptState(); } |
| 95 ExecutionContext* executionContext() const { return m_scope.scriptState()->e
xecutionContext(); } | 91 ExecutionContext* executionContext() const { return m_scope.scriptState()->e
xecutionContext(); } |
| 96 | 92 |
| 97 private: | 93 private: |
| 98 V8TestingScope m_scope; | 94 V8TestingScope m_scope; |
| 99 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 95 RefPtr<ExecutionContext> m_executionContext; |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 TEST_F(IDBRequestTest, EventsAfterStopping) | 98 TEST_F(IDBRequestTest, EventsAfterStopping) |
| 103 { | 99 { |
| 104 IDBTransaction* transaction = 0; | 100 IDBTransaction* transaction = 0; |
| 105 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); | 101 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); |
| 106 EXPECT_EQ(request->readyState(), "pending"); | 102 EXPECT_EQ(request->readyState(), "pending"); |
| 107 executionContext()->stopActiveDOMObjects(); | 103 executionContext()->stopActiveDOMObjects(); |
| 108 | 104 |
| 109 // Ensure none of the following raise assertions in stopped state: | 105 // Ensure none of the following raise assertions in stopped state: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 175 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 180 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 176 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
| 181 EXPECT_EQ(request->readyState(), "pending"); | 177 EXPECT_EQ(request->readyState(), "pending"); |
| 182 | 178 |
| 183 executionContext()->stopActiveDOMObjects(); | 179 executionContext()->stopActiveDOMObjects(); |
| 184 request->onSuccess(backend.release(), metadata); | 180 request->onSuccess(backend.release(), metadata); |
| 185 } | 181 } |
| 186 } | 182 } |
| 187 | 183 |
| 188 } // namespace | 184 } // namespace |
| OLD | NEW |