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

Unified Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix wrong dcheck Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp
index 7a9be6568820c1a897bc0e710a19a65cd1f8eeb1..7b973715e9c64d2d8e9b225d25dbad246d494292 100644
--- a/third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletTest.cpp
@@ -4,6 +4,7 @@
#include "modules/csspaint/PaintWorklet.h"
+#include <memory>
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/V8GCController.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
@@ -11,9 +12,9 @@
#include "core/testing/DummyPageHolder.h"
#include "modules/csspaint/CSSPaintDefinition.h"
#include "modules/csspaint/PaintWorkletGlobalScope.h"
+#include "modules/csspaint/PaintWorkletGlobalScopeProxy.h"
#include "modules/csspaint/WindowPaintWorklet.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <memory>
namespace blink {
@@ -21,19 +22,30 @@ class PaintWorkletTest : public testing::Test {
public:
PaintWorkletTest() : page_(DummyPageHolder::Create()) {}
+ void SetUp() override { proxy_ = GetPaintWorklet()->CreateGlobalScope(); }
+
PaintWorklet* GetPaintWorklet() {
return WindowPaintWorklet::From(*page_->GetFrame().DomWindow())
.paintWorklet();
}
- protected:
+ PaintWorkletGlobalScopeProxy* GetProxy() {
+ return PaintWorkletGlobalScopeProxy::From(proxy_.get());
+ }
+
+ void Terminate() {
+ page_.reset();
+ proxy_->TerminateWorkletGlobalScope();
+ proxy_.reset();
+ }
+
+ private:
std::unique_ptr<DummyPageHolder> page_;
+ std::unique_ptr<WorkletGlobalScopeProxy> proxy_;
};
TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) {
- PaintWorkletGlobalScopeProxy* proxy = PaintWorkletGlobalScopeProxy::From(
- GetPaintWorklet()->GetWorkletGlobalScopeProxy());
- PaintWorkletGlobalScope* global_scope = proxy->global_scope();
+ PaintWorkletGlobalScope* global_scope = GetProxy()->global_scope();
global_scope->ScriptController()->Evaluate(
ScriptSourceCode("registerPaint('foo', class { paint() { } });"));
@@ -60,7 +72,7 @@ TEST_F(PaintWorkletTest, GarbageCollectionOfCSSPaintDefinition) {
DCHECK(!handle.IsEmpty());
// Delete the page & associated objects.
- page_.reset();
+ Terminate();
// Run a GC, the persistent should have been collected.
ThreadState::Current()->CollectAllGarbage();
« no previous file with comments | « third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698