| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/csspaint/PaintWorklet.h" | 5 #include "modules/csspaint/PaintWorklet.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/V8GCController.h" | 8 #include "bindings/core/v8/V8GCController.h" |
| 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 PaintWorklet* GetPaintWorklet() { | 24 PaintWorklet* GetPaintWorklet() { |
| 25 return WindowPaintWorklet::From(*page_->GetFrame().DomWindow()) | 25 return WindowPaintWorklet::From(*page_->GetFrame().DomWindow()) |
| 26 .paintWorklet(); | 26 .paintWorklet(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 std::unique_ptr<DummyPageHolder> page_; | 30 std::unique_ptr<DummyPageHolder> page_; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) { | 33 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) { |
| 34 PaintWorkletGlobalScope* global_scope = | 34 PaintWorkletGlobalScopeProxy* proxy = PaintWorkletGlobalScopeProxy::From( |
| 35 GetPaintWorklet()->GetWorkletGlobalScopeProxy(); | 35 GetPaintWorklet()->GetWorkletGlobalScopeProxy()); |
| 36 PaintWorkletGlobalScope* global_scope = proxy->global_scope(); |
| 36 global_scope->ScriptController()->Evaluate( | 37 global_scope->ScriptController()->Evaluate( |
| 37 ScriptSourceCode("registerPaint('foo', class { paint() { } });")); | 38 ScriptSourceCode("registerPaint('foo', class { paint() { } });")); |
| 38 | 39 |
| 39 CSSPaintDefinition* definition = global_scope->FindDefinition("foo"); | 40 CSSPaintDefinition* definition = global_scope->FindDefinition("foo"); |
| 40 ASSERT(definition); | 41 ASSERT(definition); |
| 41 | 42 |
| 42 v8::Isolate* isolate = | 43 v8::Isolate* isolate = |
| 43 global_scope->ScriptController()->GetScriptState()->GetIsolate(); | 44 global_scope->ScriptController()->GetScriptState()->GetIsolate(); |
| 44 ASSERT(isolate); | 45 ASSERT(isolate); |
| 45 | 46 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 // Delete the page & associated objects. | 62 // Delete the page & associated objects. |
| 62 page_.reset(); | 63 page_.reset(); |
| 63 | 64 |
| 64 // Run a GC, the persistent should have been collected. | 65 // Run a GC, the persistent should have been collected. |
| 65 ThreadState::Current()->CollectAllGarbage(); | 66 ThreadState::Current()->CollectAllGarbage(); |
| 66 V8GCController::CollectAllGarbageForTesting(isolate); | 67 V8GCController::CollectAllGarbageForTesting(isolate); |
| 67 ASSERT(handle.IsEmpty()); | 68 ASSERT(handle.IsEmpty()); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |