| 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/ScriptPromiseResolver.h" | 6 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 TEST_F(ScriptPromiseResolverTest, keepAliveUntilResolved) | 235 TEST_F(ScriptPromiseResolverTest, keepAliveUntilResolved) |
| 236 { | 236 { |
| 237 ScriptPromiseResolverKeepAlive::reset(); | 237 ScriptPromiseResolverKeepAlive::reset(); |
| 238 ScriptPromiseResolver* resolver = nullptr; | 238 ScriptPromiseResolver* resolver = nullptr; |
| 239 { | 239 { |
| 240 ScriptState::Scope scope(scriptState()); | 240 ScriptState::Scope scope(scriptState()); |
| 241 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); | 241 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); |
| 242 } | 242 } |
| 243 resolver->keepAliveWhilePending(); | 243 resolver->keepAliveWhilePending(); |
| 244 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 244 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 245 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); | 245 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 246 | 246 |
| 247 resolver->resolve("hello"); | 247 resolver->resolve("hello"); |
| 248 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 248 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 249 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); | 249 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 TEST_F(ScriptPromiseResolverTest, keepAliveUntilRejected) | 252 TEST_F(ScriptPromiseResolverTest, keepAliveUntilRejected) |
| 253 { | 253 { |
| 254 ScriptPromiseResolverKeepAlive::reset(); | 254 ScriptPromiseResolverKeepAlive::reset(); |
| 255 ScriptPromiseResolver* resolver = nullptr; | 255 ScriptPromiseResolver* resolver = nullptr; |
| 256 { | 256 { |
| 257 ScriptState::Scope scope(scriptState()); | 257 ScriptState::Scope scope(scriptState()); |
| 258 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); | 258 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); |
| 259 } | 259 } |
| 260 resolver->keepAliveWhilePending(); | 260 resolver->keepAliveWhilePending(); |
| 261 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 261 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 262 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); | 262 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 263 | 263 |
| 264 resolver->reject("hello"); | 264 resolver->reject("hello"); |
| 265 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 265 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 266 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); | 266 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 TEST_F(ScriptPromiseResolverTest, keepAliveUntilStopped) | 269 TEST_F(ScriptPromiseResolverTest, keepAliveUntilStopped) |
| 270 { | 270 { |
| 271 ScriptPromiseResolverKeepAlive::reset(); | 271 ScriptPromiseResolverKeepAlive::reset(); |
| 272 ScriptPromiseResolver* resolver = nullptr; | 272 ScriptPromiseResolver* resolver = nullptr; |
| 273 { | 273 { |
| 274 ScriptState::Scope scope(scriptState()); | 274 ScriptState::Scope scope(scriptState()); |
| 275 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); | 275 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); |
| 276 } | 276 } |
| 277 resolver->keepAliveWhilePending(); | 277 resolver->keepAliveWhilePending(); |
| 278 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 278 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 279 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); | 279 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 280 | 280 |
| 281 executionContext()->stopActiveDOMObjects(); | 281 executionContext()->stopActiveDOMObjects(); |
| 282 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 282 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 283 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); | 283 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST_F(ScriptPromiseResolverTest, suspend) | 286 TEST_F(ScriptPromiseResolverTest, suspend) |
| 287 { | 287 { |
| 288 ScriptPromiseResolverKeepAlive::reset(); | 288 ScriptPromiseResolverKeepAlive::reset(); |
| 289 ScriptPromiseResolver* resolver = nullptr; | 289 ScriptPromiseResolver* resolver = nullptr; |
| 290 { | 290 { |
| 291 ScriptState::Scope scope(scriptState()); | 291 ScriptState::Scope scope(scriptState()); |
| 292 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); | 292 resolver = ScriptPromiseResolverKeepAlive::create(scriptState()); |
| 293 } | 293 } |
| 294 resolver->keepAliveWhilePending(); | 294 resolver->keepAliveWhilePending(); |
| 295 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 295 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 296 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); | 296 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 297 | 297 |
| 298 executionContext()->suspendActiveDOMObjects(); | 298 executionContext()->suspendActiveDOMObjects(); |
| 299 resolver->resolve("hello"); | 299 resolver->resolve("hello"); |
| 300 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 300 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 301 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); | 301 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 302 | 302 |
| 303 executionContext()->stopActiveDOMObjects(); | 303 executionContext()->stopActiveDOMObjects(); |
| 304 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 304 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 305 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); | 305 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TEST_F(ScriptPromiseResolverTest, resolveVoid) | 308 TEST_F(ScriptPromiseResolverTest, resolveVoid) |
| 309 { | 309 { |
| 310 ScriptPromiseResolver* resolver = nullptr; | 310 ScriptPromiseResolver* resolver = nullptr; |
| 311 ScriptPromise promise; | 311 ScriptPromise promise; |
| 312 { | 312 { |
| 313 ScriptState::Scope scope(scriptState()); | 313 ScriptState::Scope scope(scriptState()); |
| 314 resolver = ScriptPromiseResolver::create(scriptState()); | 314 resolver = ScriptPromiseResolver::create(scriptState()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 resolver->reject(); | 349 resolver->reject(); |
| 350 isolate()->RunMicrotasks(); | 350 isolate()->RunMicrotasks(); |
| 351 | 351 |
| 352 EXPECT_EQ(String(), onFulfilled); | 352 EXPECT_EQ(String(), onFulfilled); |
| 353 EXPECT_EQ("undefined", onRejected); | 353 EXPECT_EQ("undefined", onRejected); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace | 356 } // namespace |
| 357 | 357 |
| 358 } // namespace blink | 358 } // namespace blink |
| OLD | NEW |