| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 99 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 100 EXPECT_TRUE(result()->IsUndefined()); | 100 EXPECT_TRUE(result()->IsUndefined()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(ScriptPromiseResolverTest, fulfill) | 103 TEST_F(ScriptPromiseResolverTest, fulfill) |
| 104 { | 104 { |
| 105 EXPECT_TRUE(m_resolver->isPending()); | 105 EXPECT_TRUE(m_resolver->isPending()); |
| 106 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 106 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 107 EXPECT_TRUE(result()->IsUndefined()); | 107 EXPECT_TRUE(result()->IsUndefined()); |
| 108 | 108 |
| 109 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate))); | 109 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate), m_isolate)); |
| 110 | 110 |
| 111 EXPECT_FALSE(m_resolver->isPending()); | 111 EXPECT_FALSE(m_resolver->isPending()); |
| 112 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 112 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 113 ASSERT_TRUE(result()->IsNumber()); | 113 ASSERT_TRUE(result()->IsNumber()); |
| 114 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 114 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST_F(ScriptPromiseResolverTest, resolve) | 117 TEST_F(ScriptPromiseResolverTest, resolve) |
| 118 { | 118 { |
| 119 EXPECT_TRUE(m_resolver->isPending()); | 119 EXPECT_TRUE(m_resolver->isPending()); |
| 120 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 120 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 121 EXPECT_TRUE(result()->IsUndefined()); | 121 EXPECT_TRUE(result()->IsUndefined()); |
| 122 | 122 |
| 123 m_resolver->resolve(ScriptValue(v8::Integer::New(3, m_isolate))); | 123 m_resolver->resolve(ScriptValue(v8::Integer::New(3, m_isolate), m_isolate)); |
| 124 | 124 |
| 125 EXPECT_FALSE(m_resolver->isPending()); | 125 EXPECT_FALSE(m_resolver->isPending()); |
| 126 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 126 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 127 ASSERT_TRUE(result()->IsNumber()); | 127 ASSERT_TRUE(result()->IsNumber()); |
| 128 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 128 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 TEST_F(ScriptPromiseResolverTest, reject) | 131 TEST_F(ScriptPromiseResolverTest, reject) |
| 132 { | 132 { |
| 133 EXPECT_TRUE(m_resolver->isPending()); | 133 EXPECT_TRUE(m_resolver->isPending()); |
| 134 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 134 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 135 EXPECT_TRUE(result()->IsUndefined()); | 135 EXPECT_TRUE(result()->IsUndefined()); |
| 136 | 136 |
| 137 m_resolver->reject(ScriptValue(v8::Integer::New(3, m_isolate))); | 137 m_resolver->reject(ScriptValue(v8::Integer::New(3, m_isolate), m_isolate)); |
| 138 | 138 |
| 139 EXPECT_FALSE(m_resolver->isPending()); | 139 EXPECT_FALSE(m_resolver->isPending()); |
| 140 EXPECT_EQ(V8PromiseCustom::Rejected, state()); | 140 EXPECT_EQ(V8PromiseCustom::Rejected, state()); |
| 141 ASSERT_TRUE(result()->IsNumber()); | 141 ASSERT_TRUE(result()->IsNumber()); |
| 142 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 142 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(ScriptPromiseResolverTest, fulfillOverFulfill) | 145 TEST_F(ScriptPromiseResolverTest, fulfillOverFulfill) |
| 146 { | 146 { |
| 147 EXPECT_TRUE(m_resolver->isPending()); | 147 EXPECT_TRUE(m_resolver->isPending()); |
| 148 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 148 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 149 EXPECT_TRUE(result()->IsUndefined()); | 149 EXPECT_TRUE(result()->IsUndefined()); |
| 150 | 150 |
| 151 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate))); | 151 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate), m_isolate)); |
| 152 | 152 |
| 153 EXPECT_FALSE(m_resolver->isPending()); | 153 EXPECT_FALSE(m_resolver->isPending()); |
| 154 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 154 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 155 ASSERT_TRUE(result()->IsNumber()); | 155 ASSERT_TRUE(result()->IsNumber()); |
| 156 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 156 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 157 | 157 |
| 158 m_resolver->fulfill(ScriptValue(v8::Integer::New(4, m_isolate))); | 158 m_resolver->fulfill(ScriptValue(v8::Integer::New(4, m_isolate), m_isolate)); |
| 159 EXPECT_FALSE(m_resolver->isPending()); | 159 EXPECT_FALSE(m_resolver->isPending()); |
| 160 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 160 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 161 ASSERT_TRUE(result()->IsNumber()); | 161 ASSERT_TRUE(result()->IsNumber()); |
| 162 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 162 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 163 } | 163 } |
| 164 | 164 |
| 165 TEST_F(ScriptPromiseResolverTest, rejectOverFulfill) | 165 TEST_F(ScriptPromiseResolverTest, rejectOverFulfill) |
| 166 { | 166 { |
| 167 EXPECT_TRUE(m_resolver->isPending()); | 167 EXPECT_TRUE(m_resolver->isPending()); |
| 168 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 168 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 169 EXPECT_TRUE(result()->IsUndefined()); | 169 EXPECT_TRUE(result()->IsUndefined()); |
| 170 | 170 |
| 171 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate))); | 171 m_resolver->fulfill(ScriptValue(v8::Integer::New(3, m_isolate), m_isolate)); |
| 172 | 172 |
| 173 EXPECT_FALSE(m_resolver->isPending()); | 173 EXPECT_FALSE(m_resolver->isPending()); |
| 174 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 174 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 175 ASSERT_TRUE(result()->IsNumber()); | 175 ASSERT_TRUE(result()->IsNumber()); |
| 176 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 176 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 177 | 177 |
| 178 m_resolver->reject(ScriptValue(v8::Integer::New(4, m_isolate))); | 178 m_resolver->reject(ScriptValue(v8::Integer::New(4, m_isolate), m_isolate)); |
| 179 EXPECT_FALSE(m_resolver->isPending()); | 179 EXPECT_FALSE(m_resolver->isPending()); |
| 180 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); | 180 EXPECT_EQ(V8PromiseCustom::Fulfilled, state()); |
| 181 ASSERT_TRUE(result()->IsNumber()); | 181 ASSERT_TRUE(result()->IsNumber()); |
| 182 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); | 182 EXPECT_EQ(3, result().As<v8::Integer>()->Value()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST_F(ScriptPromiseResolverTest, detach) | 185 TEST_F(ScriptPromiseResolverTest, detach) |
| 186 { | 186 { |
| 187 EXPECT_TRUE(m_resolver->isPending()); | 187 EXPECT_TRUE(m_resolver->isPending()); |
| 188 EXPECT_EQ(V8PromiseCustom::Pending, state()); | 188 EXPECT_EQ(V8PromiseCustom::Pending, state()); |
| 189 EXPECT_TRUE(result()->IsUndefined()); | 189 EXPECT_TRUE(result()->IsUndefined()); |
| 190 | 190 |
| 191 m_resolver->detach(); | 191 m_resolver->detach(); |
| 192 | 192 |
| 193 EXPECT_FALSE(m_resolver->isPending()); | 193 EXPECT_FALSE(m_resolver->isPending()); |
| 194 EXPECT_EQ(V8PromiseCustom::Rejected, state()); | 194 EXPECT_EQ(V8PromiseCustom::Rejected, state()); |
| 195 EXPECT_TRUE(result()->IsUndefined()); | 195 EXPECT_TRUE(result()->IsUndefined()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace | 198 } // namespace |
| 199 | 199 |
| 200 } // namespace WebCore | 200 } // namespace WebCore |
| OLD | NEW |