OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptPromiseProperty.h" | 6 #include "bindings/core/v8/ScriptPromiseProperty.h" |
7 | 7 |
8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 NotReached* self = new NotReached(scriptState); | 36 NotReached* self = new NotReached(scriptState); |
37 return self->bindToV8Function(); | 37 return self->bindToV8Function(); |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 explicit NotReached(ScriptState* scriptState) | 41 explicit NotReached(ScriptState* scriptState) |
42 : ScriptFunction(scriptState) | 42 : ScriptFunction(scriptState) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 virtual ScriptValue call(ScriptValue) OVERRIDE; | 46 virtual ScriptValue call(ScriptValue) override; |
47 }; | 47 }; |
48 | 48 |
49 ScriptValue NotReached::call(ScriptValue) | 49 ScriptValue NotReached::call(ScriptValue) |
50 { | 50 { |
51 EXPECT_TRUE(false) << "'Unreachable' code was reached"; | 51 EXPECT_TRUE(false) << "'Unreachable' code was reached"; |
52 return ScriptValue(); | 52 return ScriptValue(); |
53 } | 53 } |
54 | 54 |
55 class StubFunction : public ScriptFunction { | 55 class StubFunction : public ScriptFunction { |
56 public: | 56 public: |
57 static v8::Handle<v8::Function> createFunction(ScriptState* scriptState, Scr
iptValue& value, size_t& callCount) | 57 static v8::Handle<v8::Function> createFunction(ScriptState* scriptState, Scr
iptValue& value, size_t& callCount) |
58 { | 58 { |
59 StubFunction* self = new StubFunction(scriptState, value, callCount); | 59 StubFunction* self = new StubFunction(scriptState, value, callCount); |
60 return self->bindToV8Function(); | 60 return self->bindToV8Function(); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 StubFunction(ScriptState* scriptState, ScriptValue& value, size_t& callCount
) | 64 StubFunction(ScriptState* scriptState, ScriptValue& value, size_t& callCount
) |
65 : ScriptFunction(scriptState) | 65 : ScriptFunction(scriptState) |
66 , m_value(value) | 66 , m_value(value) |
67 , m_callCount(callCount) | 67 , m_callCount(callCount) |
68 { | 68 { |
69 } | 69 } |
70 | 70 |
71 virtual ScriptValue call(ScriptValue arg) OVERRIDE | 71 virtual ScriptValue call(ScriptValue arg) override |
72 { | 72 { |
73 m_value = arg; | 73 m_value = arg; |
74 m_callCount++; | 74 m_callCount++; |
75 return ScriptValue(); | 75 return ScriptValue(); |
76 } | 76 } |
77 | 77 |
78 ScriptValue& m_value; | 78 ScriptValue& m_value; |
79 size_t& m_callCount; | 79 size_t& m_callCount; |
80 }; | 80 }; |
81 | 81 |
82 class GarbageCollectedHolder : public GarbageCollectedScriptWrappable { | 82 class GarbageCollectedHolder : public GarbageCollectedScriptWrappable { |
83 public: | 83 public: |
84 typedef ScriptPromiseProperty<Member<GarbageCollectedScriptWrappable>, Membe
r<GarbageCollectedScriptWrappable>, Member<GarbageCollectedScriptWrappable> > Pr
operty; | 84 typedef ScriptPromiseProperty<Member<GarbageCollectedScriptWrappable>, Membe
r<GarbageCollectedScriptWrappable>, Member<GarbageCollectedScriptWrappable> > Pr
operty; |
85 GarbageCollectedHolder(ExecutionContext* executionContext) | 85 GarbageCollectedHolder(ExecutionContext* executionContext) |
86 : GarbageCollectedScriptWrappable("holder") | 86 : GarbageCollectedScriptWrappable("holder") |
87 , m_property(new Property(executionContext, toGarbageCollectedScriptWrap
pable(), Property::Ready)) { } | 87 , m_property(new Property(executionContext, toGarbageCollectedScriptWrap
pable(), Property::Ready)) { } |
88 | 88 |
89 Property* property() { return m_property; } | 89 Property* property() { return m_property; } |
90 GarbageCollectedScriptWrappable* toGarbageCollectedScriptWrappable() { retur
n this; } | 90 GarbageCollectedScriptWrappable* toGarbageCollectedScriptWrappable() { retur
n this; } |
91 | 91 |
92 virtual void trace(Visitor *visitor) OVERRIDE | 92 virtual void trace(Visitor *visitor) override |
93 { | 93 { |
94 GarbageCollectedScriptWrappable::trace(visitor); | 94 GarbageCollectedScriptWrappable::trace(visitor); |
95 visitor->trace(m_property); | 95 visitor->trace(m_property); |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 Member<Property> m_property; | 99 Member<Property> m_property; |
100 }; | 100 }; |
101 | 101 |
102 class RefCountedHolder : public RefCountedScriptWrappable { | 102 class RefCountedHolder : public RefCountedScriptWrappable { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 ScriptPromisePropertyGarbageCollectedTest() | 180 ScriptPromisePropertyGarbageCollectedTest() |
181 : m_holder(new GarbageCollectedHolder(&document())) | 181 : m_holder(new GarbageCollectedHolder(&document())) |
182 { | 182 { |
183 } | 183 } |
184 | 184 |
185 GarbageCollectedHolder* holder() { return m_holder; } | 185 GarbageCollectedHolder* holder() { return m_holder; } |
186 Property* property() { return m_holder->property(); } | 186 Property* property() { return m_holder->property(); } |
187 ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(w
orld); } | 187 ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(w
orld); } |
188 | 188 |
189 virtual void destroyContext() OVERRIDE | 189 virtual void destroyContext() override |
190 { | 190 { |
191 m_holder = nullptr; | 191 m_holder = nullptr; |
192 ScriptPromisePropertyTestBase::destroyContext(); | 192 ScriptPromisePropertyTestBase::destroyContext(); |
193 } | 193 } |
194 | 194 |
195 private: | 195 private: |
196 Persistent<GarbageCollectedHolder> m_holder; | 196 Persistent<GarbageCollectedHolder> m_holder; |
197 }; | 197 }; |
198 | 198 |
199 TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_IsStableObjectInMainWo
rld) | 199 TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_IsStableObjectInMainWo
rld) |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 { | 545 { |
546 test(String("hello"), "hello", __FILE__, __LINE__); | 546 test(String("hello"), "hello", __FILE__, __LINE__); |
547 } | 547 } |
548 | 548 |
549 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) | 549 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) |
550 { | 550 { |
551 test<int>(-1, "-1", __FILE__, __LINE__); | 551 test<int>(-1, "-1", __FILE__, __LINE__); |
552 } | 552 } |
553 | 553 |
554 } // namespace | 554 } // namespace |
OLD | NEW |