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

Side by Side Diff: third_party/WebKit/Source/web/tests/ResizeObserverTest.cpp

Issue 2811793005: Rename LocalFrame::Script() to GetScriptController() (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/dom/ResizeObserver.h" 5 #include "core/dom/ResizeObserver.h"
6 6
7 #include "bindings/core/v8/ScriptController.h" 7 #include "bindings/core/v8/ScriptController.h"
8 #include "bindings/core/v8/ScriptSourceCode.h" 8 #include "bindings/core/v8/ScriptSourceCode.h"
9 #include "bindings/core/v8/V8GCController.h" 9 #include "bindings/core/v8/V8GCController.h"
10 #include "core/dom/ResizeObservation.h" 10 #include "core/dom/ResizeObservation.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 TEST_F(ResizeObserverUnitTest, TestMemoryLeaks) { 103 TEST_F(ResizeObserverUnitTest, TestMemoryLeaks) {
104 ResizeObserverController& controller = 104 ResizeObserverController& controller =
105 GetDocument().EnsureResizeObserverController(); 105 GetDocument().EnsureResizeObserverController();
106 const HeapHashSet<WeakMember<ResizeObserver>>& observers = 106 const HeapHashSet<WeakMember<ResizeObserver>>& observers =
107 controller.Observers(); 107 controller.Observers();
108 ASSERT_EQ(observers.size(), 0U); 108 ASSERT_EQ(observers.size(), 0U);
109 v8::HandleScope scope(v8::Isolate::GetCurrent()); 109 v8::HandleScope scope(v8::Isolate::GetCurrent());
110 110
111 ScriptController& script = GetDocument().ExecutingFrame()->Script(); 111 ScriptController& script_controller =
112 GetDocument().ExecutingFrame()->GetScriptController();
112 113
113 // 114 //
114 // Test whether ResizeObserver is kept alive by direct JS reference 115 // Test whether ResizeObserver is kept alive by direct JS reference
115 // 116 //
116 script.ExecuteScriptInMainWorldAndReturnValue( 117 script_controller.ExecuteScriptInMainWorldAndReturnValue(
117 ScriptSourceCode("var ro = new ResizeObserver( entries => {});"), 118 ScriptSourceCode("var ro = new ResizeObserver( entries => {});"),
118 ScriptController::kExecuteScriptWhenScriptsDisabled); 119 ScriptController::kExecuteScriptWhenScriptsDisabled);
119 ASSERT_EQ(observers.size(), 1U); 120 ASSERT_EQ(observers.size(), 1U);
120 script.ExecuteScriptInMainWorldAndReturnValue( 121 script_controller.ExecuteScriptInMainWorldAndReturnValue(
121 ScriptSourceCode("ro = undefined;"), 122 ScriptSourceCode("ro = undefined;"),
122 ScriptController::kExecuteScriptWhenScriptsDisabled); 123 ScriptController::kExecuteScriptWhenScriptsDisabled);
123 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); 124 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent());
124 WebHeap::CollectAllGarbageForTesting(); 125 WebHeap::CollectAllGarbageForTesting();
125 ASSERT_EQ(observers.IsEmpty(), true); 126 ASSERT_EQ(observers.IsEmpty(), true);
126 127
127 // 128 //
128 // Test whether ResizeObserver is kept alive by an Element 129 // Test whether ResizeObserver is kept alive by an Element
129 // 130 //
130 script.ExecuteScriptInMainWorldAndReturnValue( 131 script_controller.ExecuteScriptInMainWorldAndReturnValue(
131 ScriptSourceCode("var ro = new ResizeObserver( () => {});" 132 ScriptSourceCode("var ro = new ResizeObserver( () => {});"
132 "var el = document.createElement('div');" 133 "var el = document.createElement('div');"
133 "ro.observe(el);" 134 "ro.observe(el);"
134 "ro = undefined;"), 135 "ro = undefined;"),
135 ScriptController::kExecuteScriptWhenScriptsDisabled); 136 ScriptController::kExecuteScriptWhenScriptsDisabled);
136 ASSERT_EQ(observers.size(), 1U); 137 ASSERT_EQ(observers.size(), 1U);
137 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); 138 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent());
138 WebHeap::CollectAllGarbageForTesting(); 139 WebHeap::CollectAllGarbageForTesting();
139 ASSERT_EQ(observers.size(), 1U); 140 ASSERT_EQ(observers.size(), 1U);
140 script.ExecuteScriptInMainWorldAndReturnValue( 141 script_controller.ExecuteScriptInMainWorldAndReturnValue(
141 ScriptSourceCode("el = undefined;"), 142 ScriptSourceCode("el = undefined;"),
142 ScriptController::kExecuteScriptWhenScriptsDisabled); 143 ScriptController::kExecuteScriptWhenScriptsDisabled);
143 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); 144 V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent());
144 WebHeap::CollectAllGarbageForTesting(); 145 WebHeap::CollectAllGarbageForTesting();
145 ASSERT_EQ(observers.IsEmpty(), true); 146 ASSERT_EQ(observers.IsEmpty(), true);
146 } 147 }
147 148
148 } // namespace blink 149 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698