OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
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 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/dom/MainThreadTaskRunner.h" | 29 #include "core/dom/MainThreadTaskRunner.h" |
30 | 30 |
31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
32 #include "core/dom/ExecutionContextTask.h" | 32 #include "core/dom/ExecutionContextTask.h" |
| 33 #include "core/dom/SecurityContext.h" |
33 #include "core/events/EventQueue.h" | 34 #include "core/events/EventQueue.h" |
34 #include "core/testing/UnitTestHelpers.h" | 35 #include "core/testing/UnitTestHelpers.h" |
| 36 #include "wtf/Forward.h" |
35 #include <gtest/gtest.h> | 37 #include <gtest/gtest.h> |
36 | 38 |
37 using namespace WebCore; | 39 using namespace WebCore; |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 class NullEventQueue : public EventQueue { | 43 class NullEventQueue : public EventQueue { |
42 public: | 44 public: |
43 NullEventQueue() { } | 45 NullEventQueue() { } |
44 virtual ~NullEventQueue() { } | 46 virtual ~NullEventQueue() { } |
45 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } | 47 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t
rue; } |
46 virtual bool cancelEvent(Event*) OVERRIDE { return true; } | 48 virtual bool cancelEvent(Event*) OVERRIDE { return true; } |
47 virtual void close() OVERRIDE { } | 49 virtual void close() OVERRIDE { } |
48 }; | 50 }; |
49 | 51 |
50 class NullExecutionContext : public RefCountedWillBeGarbageCollectedFinalized<Nu
llExecutionContext>, public ExecutionContext { | 52 class NullExecutionContext : public RefCountedWillBeGarbageCollectedFinalized<Nu
llExecutionContext>, public SecurityContext, public ExecutionContext { |
51 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); | 53 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); |
52 public: | 54 public: |
53 NullExecutionContext(); | 55 NullExecutionContext(); |
54 | 56 |
55 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } | 57 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } |
56 virtual bool tasksNeedSuspension() { return m_tasksNeedSuspension; } | 58 virtual bool tasksNeedSuspension() { return m_tasksNeedSuspension; } |
57 | 59 |
58 void setTasksNeedSuspention(bool flag) { m_tasksNeedSuspension = flag; } | 60 void setTasksNeedSuspention(bool flag) { m_tasksNeedSuspension = flag; } |
59 | 61 |
60 void trace(Visitor* visitor) | 62 void trace(Visitor* visitor) |
61 { | 63 { |
62 visitor->trace(m_queue); | 64 visitor->trace(m_queue); |
63 ExecutionContext::trace(visitor); | 65 ExecutionContext::trace(visitor); |
64 } | 66 } |
65 | 67 |
66 #if !ENABLE(OILPAN) | 68 #if !ENABLE(OILPAN) |
67 using RefCounted<NullExecutionContext>::ref; | 69 using RefCounted<NullExecutionContext>::ref; |
68 using RefCounted<NullExecutionContext>::deref; | 70 using RefCounted<NullExecutionContext>::deref; |
69 | 71 |
| 72 virtual void reportBlockedScriptExecutionToInspector(const String& directive
Text) OVERRIDE { } |
| 73 |
| 74 virtual SecurityContext& securityContext() { return *this; } |
| 75 |
70 virtual void refExecutionContext() OVERRIDE { ref(); } | 76 virtual void refExecutionContext() OVERRIDE { ref(); } |
71 virtual void derefExecutionContext() OVERRIDE { deref(); } | 77 virtual void derefExecutionContext() OVERRIDE { deref(); } |
72 #endif | 78 #endif |
73 | 79 |
| 80 protected: |
| 81 virtual const KURL& virtualURL() const OVERRIDE { return m_dummyURL; } |
| 82 virtual KURL virtualCompleteURL(const String&) const OVERRIDE { return m_dum
myURL; } |
| 83 |
74 private: | 84 private: |
75 bool m_tasksNeedSuspension; | 85 bool m_tasksNeedSuspension; |
76 OwnPtrWillBeMember<EventQueue> m_queue; | 86 OwnPtrWillBeMember<EventQueue> m_queue; |
| 87 |
| 88 KURL m_dummyURL; |
77 }; | 89 }; |
78 | 90 |
79 NullExecutionContext::NullExecutionContext() | 91 NullExecutionContext::NullExecutionContext() |
80 : m_tasksNeedSuspension(false) | 92 : m_tasksNeedSuspension(false) |
81 , m_queue(adoptPtrWillBeNoop(new NullEventQueue())) | 93 , m_queue(adoptPtrWillBeNoop(new NullEventQueue())) |
82 { | 94 { |
83 } | 95 } |
84 | 96 |
85 class MarkingBooleanTask FINAL : public ExecutionContextTask { | 97 class MarkingBooleanTask FINAL : public ExecutionContextTask { |
86 public: | 98 public: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 bool isMarked = false; | 152 bool isMarked = false; |
141 | 153 |
142 context->setTasksNeedSuspention(true); | 154 context->setTasksNeedSuspention(true); |
143 runner->postTask(MarkingBooleanTask::create(&isMarked)); | 155 runner->postTask(MarkingBooleanTask::create(&isMarked)); |
144 runner.clear(); | 156 runner.clear(); |
145 WebCore::testing::runPendingTasks(); | 157 WebCore::testing::runPendingTasks(); |
146 EXPECT_FALSE(isMarked); | 158 EXPECT_FALSE(isMarked); |
147 } | 159 } |
148 | 160 |
149 } | 161 } |
OLD | NEW |