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 <memory> | 16 #include <memory> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class PaintWorkletTest : public testing::Test { | 20 class PaintWorkletTest : public testing::Test { |
21 public: | 21 public: |
22 PaintWorkletTest() | 22 PaintWorkletTest() |
23 : m_page(DummyPageHolder::create()) | 23 : m_page(DummyPageHolder::create()) |
24 { | 24 { |
25 } | 25 } |
26 | 26 |
27 PaintWorklet* paintWorklet() | 27 PaintWorklet* paintWorklet() |
28 { | 28 { |
29 return WindowPaintWorklet::from(*m_page->frame().localDOMWindow()).paint
Worklet(&m_page->document()); | 29 return WindowPaintWorklet::from(*m_page->frame().localDOMWindow()).paint
Worklet(); |
30 } | 30 } |
31 | 31 |
32 protected: | 32 protected: |
33 std::unique_ptr<DummyPageHolder> m_page; | 33 std::unique_ptr<DummyPageHolder> m_page; |
34 }; | 34 }; |
35 | 35 |
36 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) | 36 TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) |
37 { | 37 { |
38 PaintWorkletGlobalScope* globalScope = paintWorklet()->workletGlobalScopePro
xy(); | 38 PaintWorkletGlobalScope* globalScope = paintWorklet()->workletGlobalScopePro
xy(); |
39 globalScope->scriptController()->evaluate(ScriptSourceCode("registerPaint('f
oo', class { paint() { } });")); | 39 globalScope->scriptController()->evaluate(ScriptSourceCode("registerPaint('f
oo', class { paint() { } });")); |
(...skipping 22 matching lines...) Expand all Loading... |
62 // Delete the page & associated objects. | 62 // Delete the page & associated objects. |
63 m_page.reset(); | 63 m_page.reset(); |
64 | 64 |
65 // Run a GC, the persistent should have been collected. | 65 // Run a GC, the persistent should have been collected. |
66 ThreadHeap::collectAllGarbage(); | 66 ThreadHeap::collectAllGarbage(); |
67 V8GCController::collectAllGarbageForTesting(isolate); | 67 V8GCController::collectAllGarbageForTesting(isolate); |
68 ASSERT(handle.isEmpty()); | 68 ASSERT(handle.isEmpty()); |
69 } | 69 } |
70 | 70 |
71 } // naespace blink | 71 } // naespace blink |
OLD | NEW |