Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp

Issue 2307003002: Move collectGarbage* methods to ThreadState (Closed)
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bindings/core/v8/ScriptPromiseResolver.h" 5 #include "bindings/core/v8/ScriptPromiseResolver.h"
6 6
7 #include "bindings/core/v8/ScriptFunction.h" 7 #include "bindings/core/v8/ScriptFunction.h"
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 TEST_F(ScriptPromiseResolverTest, keepAliveUntilResolved) 226 TEST_F(ScriptPromiseResolverTest, keepAliveUntilResolved)
227 { 227 {
228 ScriptPromiseResolverKeepAlive::reset(); 228 ScriptPromiseResolverKeepAlive::reset();
229 ScriptPromiseResolver* resolver = nullptr; 229 ScriptPromiseResolver* resolver = nullptr;
230 { 230 {
231 ScriptState::Scope scope(getScriptState()); 231 ScriptState::Scope scope(getScriptState());
232 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState()); 232 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState());
233 } 233 }
234 resolver->keepAliveWhilePending(); 234 resolver->keepAliveWhilePending();
235 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 235 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
236 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); 236 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive());
237 237
238 resolver->resolve("hello"); 238 resolver->resolve("hello");
239 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 239 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
240 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); 240 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive());
241 } 241 }
242 242
243 TEST_F(ScriptPromiseResolverTest, keepAliveUntilRejected) 243 TEST_F(ScriptPromiseResolverTest, keepAliveUntilRejected)
244 { 244 {
245 ScriptPromiseResolverKeepAlive::reset(); 245 ScriptPromiseResolverKeepAlive::reset();
246 ScriptPromiseResolver* resolver = nullptr; 246 ScriptPromiseResolver* resolver = nullptr;
247 { 247 {
248 ScriptState::Scope scope(getScriptState()); 248 ScriptState::Scope scope(getScriptState());
249 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState()); 249 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState());
250 } 250 }
251 resolver->keepAliveWhilePending(); 251 resolver->keepAliveWhilePending();
252 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 252 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
253 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); 253 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive());
254 254
255 resolver->reject("hello"); 255 resolver->reject("hello");
256 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 256 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
257 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); 257 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive());
258 } 258 }
259 259
260 TEST_F(ScriptPromiseResolverTest, keepAliveUntilStopped) 260 TEST_F(ScriptPromiseResolverTest, keepAliveUntilStopped)
261 { 261 {
262 ScriptPromiseResolverKeepAlive::reset(); 262 ScriptPromiseResolverKeepAlive::reset();
263 ScriptPromiseResolver* resolver = nullptr; 263 ScriptPromiseResolver* resolver = nullptr;
264 { 264 {
265 ScriptState::Scope scope(getScriptState()); 265 ScriptState::Scope scope(getScriptState());
266 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState()); 266 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState());
267 } 267 }
268 resolver->keepAliveWhilePending(); 268 resolver->keepAliveWhilePending();
269 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 269 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
270 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); 270 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive());
271 271
272 getExecutionContext()->stopActiveDOMObjects(); 272 getExecutionContext()->stopActiveDOMObjects();
273 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 273 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
274 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); 274 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive());
275 } 275 }
276 276
277 TEST_F(ScriptPromiseResolverTest, suspend) 277 TEST_F(ScriptPromiseResolverTest, suspend)
278 { 278 {
279 ScriptPromiseResolverKeepAlive::reset(); 279 ScriptPromiseResolverKeepAlive::reset();
280 ScriptPromiseResolver* resolver = nullptr; 280 ScriptPromiseResolver* resolver = nullptr;
281 { 281 {
282 ScriptState::Scope scope(getScriptState()); 282 ScriptState::Scope scope(getScriptState());
283 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState()); 283 resolver = ScriptPromiseResolverKeepAlive::create(getScriptState());
284 } 284 }
285 resolver->keepAliveWhilePending(); 285 resolver->keepAliveWhilePending();
286 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 286 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
287 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); 287 ASSERT_TRUE(ScriptPromiseResolverKeepAlive::isAlive());
288 288
289 getExecutionContext()->suspendActiveDOMObjects(); 289 getExecutionContext()->suspendActiveDOMObjects();
290 resolver->resolve("hello"); 290 resolver->resolve("hello");
291 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 291 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
292 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive()); 292 EXPECT_TRUE(ScriptPromiseResolverKeepAlive::isAlive());
293 293
294 getExecutionContext()->stopActiveDOMObjects(); 294 getExecutionContext()->stopActiveDOMObjects();
295 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC); 295 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC);
296 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive()); 296 EXPECT_FALSE(ScriptPromiseResolverKeepAlive::isAlive());
297 } 297 }
298 298
299 TEST_F(ScriptPromiseResolverTest, resolveVoid) 299 TEST_F(ScriptPromiseResolverTest, resolveVoid)
300 { 300 {
301 ScriptPromiseResolver* resolver = nullptr; 301 ScriptPromiseResolver* resolver = nullptr;
302 ScriptPromise promise; 302 ScriptPromise promise;
303 { 303 {
304 ScriptState::Scope scope(getScriptState()); 304 ScriptState::Scope scope(getScriptState());
305 resolver = ScriptPromiseResolver::create(getScriptState()); 305 resolver = ScriptPromiseResolver::create(getScriptState());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 resolver->reject(); 340 resolver->reject();
341 v8::MicrotasksScope::PerformCheckpoint(isolate()); 341 v8::MicrotasksScope::PerformCheckpoint(isolate());
342 342
343 EXPECT_EQ(String(), onFulfilled); 343 EXPECT_EQ(String(), onFulfilled);
344 EXPECT_EQ("undefined", onRejected); 344 EXPECT_EQ("undefined", onRejected);
345 } 345 }
346 346
347 } // namespace 347 } // namespace
348 348
349 } // namespace blink 349 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698