| 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 26 matching lines...) Expand all Loading... |
| 37 { | 37 { |
| 38 return WindowPaintWorklet::from(*m_page->frame().localDOMWindow()).paint
Worklet(&m_page->document()); | 38 return WindowPaintWorklet::from(*m_page->frame().localDOMWindow()).paint
Worklet(&m_page->document()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 OwnPtr<DummyPageHolder> m_page; | 42 OwnPtr<DummyPageHolder> m_page; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) | 45 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) |
| 46 { | 46 { |
| 47 PaintWorkletGlobalScope* globalScope = toPaintWorkletGlobalScope(paintWorkle
t()->workletGlobalScope()); | 47 PaintWorkletGlobalScope* globalScope = paintWorklet()->workletGlobalScopePro
xy(); |
| 48 globalScope->scriptController()->evaluate(ScriptSourceCode("registerPaint('f
oo', class { paint() { } });")); | 48 globalScope->scriptController()->evaluate(ScriptSourceCode("registerPaint('f
oo', class { paint() { } });")); |
| 49 | 49 |
| 50 CSSPaintDefinition* definition = globalScope->findDefinition("foo"); | 50 CSSPaintDefinition* definition = globalScope->findDefinition("foo"); |
| 51 ASSERT(definition); | 51 ASSERT(definition); |
| 52 | 52 |
| 53 v8::Isolate* isolate = globalScope->scriptController()->getScriptState()->is
olate(); | 53 v8::Isolate* isolate = globalScope->scriptController()->getScriptState()->is
olate(); |
| 54 ASSERT(isolate); | 54 ASSERT(isolate); |
| 55 | 55 |
| 56 // Set our ScopedPersistent to the paint function, and make weak. | 56 // Set our ScopedPersistent to the paint function, and make weak. |
| 57 ScopedPersistent<v8::Function> handle; | 57 ScopedPersistent<v8::Function> handle; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 // Delete the page & associated objects. | 71 // Delete the page & associated objects. |
| 72 m_page.reset(); | 72 m_page.reset(); |
| 73 | 73 |
| 74 // Run a GC, the persistent should have been collected. | 74 // Run a GC, the persistent should have been collected. |
| 75 ThreadHeap::collectAllGarbage(); | 75 ThreadHeap::collectAllGarbage(); |
| 76 V8GCController::collectAllGarbageForTesting(isolate); | 76 V8GCController::collectAllGarbageForTesting(isolate); |
| 77 ASSERT(handle.isEmpty()); | 77 ASSERT(handle.isEmpty()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // naespace blink | 80 } // naespace blink |
| OLD | NEW |