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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 private: | 58 private: |
59 Function(v8::Isolate* isolate, String* value) : ScriptFunction(isolate), m_v
alue(value) { } | 59 Function(v8::Isolate* isolate, String* value) : ScriptFunction(isolate), m_v
alue(value) { } |
60 | 60 |
61 String* m_value; | 61 String* m_value; |
62 }; | 62 }; |
63 | 63 |
64 class ScriptPromiseResolverTest : public testing::Test { | 64 class ScriptPromiseResolverTest : public testing::Test { |
65 public: | 65 public: |
66 ScriptPromiseResolverTest() | 66 ScriptPromiseResolverTest() |
67 : m_scope(V8TestingScope::create(v8::Isolate::GetCurrent())) | 67 : m_scope(v8::Isolate::GetCurrent()) |
68 { | 68 { |
69 m_resolver = ScriptPromiseResolver::create(m_scope->scriptState()); | 69 m_resolver = ScriptPromiseResolver::create(m_scope.scriptState()); |
70 } | 70 } |
71 | 71 |
72 virtual ~ScriptPromiseResolverTest() | 72 virtual ~ScriptPromiseResolverTest() |
73 { | 73 { |
74 // Run all pending microtasks here. | 74 // Run all pending microtasks here. |
75 isolate()->RunMicrotasks(); | 75 isolate()->RunMicrotasks(); |
76 } | 76 } |
77 | 77 |
78 v8::Isolate* isolate() { return m_scope->isolate(); } | 78 v8::Isolate* isolate() { return m_scope.isolate(); } |
79 | 79 |
80 protected: | 80 protected: |
81 RefPtr<ScriptPromiseResolver> m_resolver; | 81 RefPtr<ScriptPromiseResolver> m_resolver; |
82 OwnPtr<V8TestingScope> m_scope; | 82 V8TestingScope m_scope; |
83 }; | 83 }; |
84 | 84 |
85 TEST_F(ScriptPromiseResolverTest, initialState) | 85 TEST_F(ScriptPromiseResolverTest, initialState) |
86 { | 86 { |
87 ScriptPromise promise = m_resolver->promise(); | 87 ScriptPromise promise = m_resolver->promise(); |
88 ASSERT_FALSE(promise.isEmpty()); | 88 ASSERT_FALSE(promise.isEmpty()); |
89 String onFulfilled, onRejected; | 89 String onFulfilled, onRejected; |
90 promise.then(Function::create(isolate(), &onFulfilled), Function::create(iso
late(), &onRejected)); | 90 promise.then(Function::create(isolate(), &onFulfilled), Function::create(iso
late(), &onRejected)); |
91 | 91 |
92 EXPECT_EQ(String(), onFulfilled); | 92 EXPECT_EQ(String(), onFulfilled); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 m_resolver->reject("world"); | 178 m_resolver->reject("world"); |
179 isolate()->RunMicrotasks(); | 179 isolate()->RunMicrotasks(); |
180 | 180 |
181 EXPECT_EQ("hello", onFulfilled); | 181 EXPECT_EQ("hello", onFulfilled); |
182 EXPECT_EQ(String(), onRejected); | 182 EXPECT_EQ(String(), onRejected); |
183 } | 183 } |
184 | 184 |
185 } // namespace | 185 } // namespace |
186 | 186 |
187 } // namespace WebCore | 187 } // namespace WebCore |
OLD | NEW |