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" |
11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
12 #include "modules/csspaint/CSSPaintDefinition.h" | 12 #include "modules/csspaint/CSSPaintDefinition.h" |
13 #include "modules/csspaint/PaintWorkletGlobalScope.h" | 13 #include "modules/csspaint/PaintWorkletGlobalScope.h" |
14 #include "modules/csspaint/WindowPaintWorklet.h" | 14 #include "modules/csspaint/WindowPaintWorklet.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "wtf/OwnPtr.h" | 16 #include <memory> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 static void clearHandle(const v8::WeakCallbackInfo<ScopedPersistent<v8::Function
>>& data) | 22 static void clearHandle(const v8::WeakCallbackInfo<ScopedPersistent<v8::Function
>>& data) |
23 { | 23 { |
24 data.GetParameter()->clear(); | 24 data.GetParameter()->clear(); |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 class PaintWorkletTest : public testing::Test { | 29 class PaintWorkletTest : public testing::Test { |
30 public: | 30 public: |
31 PaintWorkletTest() | 31 PaintWorkletTest() |
32 : m_page(DummyPageHolder::create()) | 32 : m_page(DummyPageHolder::create()) |
33 { | 33 { |
34 } | 34 } |
35 | 35 |
36 PaintWorklet* paintWorklet() | 36 PaintWorklet* paintWorklet() |
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 std::unique_ptr<DummyPageHolder> m_page; |
43 }; | 43 }; |
44 | 44 |
45 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) | 45 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) |
46 { | 46 { |
47 PaintWorkletGlobalScope* globalScope = paintWorklet()->workletGlobalScopePro
xy(); | 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 |
(...skipping 18 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 |