OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/v8/ScriptPromiseResolver.h" | 32 #include "bindings/v8/ScriptPromiseResolver.h" |
33 | 33 |
| 34 #include "bindings/v8/ScriptPromise.h" |
34 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
35 #include "bindings/v8/custom/V8PromiseCustom.h" | 36 #include "bindings/v8/custom/V8PromiseCustom.h" |
36 | 37 |
37 #include <gtest/gtest.h> | 38 #include <gtest/gtest.h> |
38 #include <v8.h> | 39 #include <v8.h> |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
(...skipping 28 matching lines...) Expand all Loading... |
72 } | 73 } |
73 | 74 |
74 v8::Local<v8::Value> result() | 75 v8::Local<v8::Value> result() |
75 { | 76 { |
76 return V8PromiseCustom::getInternal(promise())->GetInternalField(V8Promi
seCustom::InternalResultIndex); | 77 return V8PromiseCustom::getInternal(promise())->GetInternalField(V8Promi
seCustom::InternalResultIndex); |
77 } | 78 } |
78 | 79 |
79 v8::Local<v8::Object> promise() | 80 v8::Local<v8::Object> promise() |
80 { | 81 { |
81 ASSERT(!m_promise.hasNoValue()); | 82 ASSERT(!m_promise.hasNoValue()); |
82 return m_promise.v8Object(); | 83 return m_promise.v8Value().As<v8::Object>(); |
83 } | 84 } |
84 | 85 |
85 protected: | 86 protected: |
86 v8::Isolate* m_isolate; | 87 v8::Isolate* m_isolate; |
87 v8::HandleScope m_handleScope; | 88 v8::HandleScope m_handleScope; |
88 ScopedPersistent<v8::Context> m_context; | 89 ScopedPersistent<v8::Context> m_context; |
89 v8::Context::Scope m_contextScope; | 90 v8::Context::Scope m_contextScope; |
90 RefPtr<ScriptPromiseResolver> m_resolver; | 91 RefPtr<ScriptPromiseResolver> m_resolver; |
91 ScriptObject m_promise; | 92 ScriptPromise m_promise; |
92 OwnPtr<V8PerContextData> m_perContextData; | 93 OwnPtr<V8PerContextData> m_perContextData; |
93 }; | 94 }; |
94 | 95 |
95 TEST_F(ScriptPromiseResolverTest, initialState) | 96 TEST_F(ScriptPromiseResolverTest, initialState) |
96 { | 97 { |
97 EXPECT_TRUE(m_resolver->isPending()); | 98 EXPECT_TRUE(m_resolver->isPending()); |
98 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 99 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
99 EXPECT_TRUE(result()->IsUndefined()); | 100 EXPECT_TRUE(result()->IsUndefined()); |
100 } | 101 } |
101 | 102 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 m_resolver->detach(); | 191 m_resolver->detach(); |
191 | 192 |
192 EXPECT_FALSE(m_resolver->isPending()); | 193 EXPECT_FALSE(m_resolver->isPending()); |
193 EXPECT_EQ(V8PromiseCustom::Rejected, state()); | 194 EXPECT_EQ(V8PromiseCustom::Rejected, state()); |
194 EXPECT_TRUE(result()->IsUndefined()); | 195 EXPECT_TRUE(result()->IsUndefined()); |
195 } | 196 } |
196 | 197 |
197 } // namespace | 198 } // namespace |
198 | 199 |
199 } // namespace WebCore | 200 } // namespace WebCore |
OLD | NEW |