Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/input/text-input-controller-leak-document.html |
| diff --git a/third_party/WebKit/LayoutTests/editing/input/text-input-controller-leak-document.html b/third_party/WebKit/LayoutTests/editing/input/text-input-controller-leak-document.html |
| index cc74c3d30184c09eba48f2dfcb50b61a9ce1ce82..059030ea580fb0f8d3e58ef64c2eca27672be68e 100644 |
| --- a/third_party/WebKit/LayoutTests/editing/input/text-input-controller-leak-document.html |
| +++ b/third_party/WebKit/LayoutTests/editing/input/text-input-controller-leak-document.html |
| @@ -6,20 +6,21 @@ |
| <script> |
| var input = document.getElementById('text'); |
| input.focus(); |
| - textInputController.setMarkedText("hello", 0, 5); |
| - // Do not pass the object directly to observeGC function. This may |
| - // remain live on this function's stack preventing GC from collecting |
| - // it. Accessing the object inside an inner function will prevent any |
| - // unneeded references on this function's stack. |
| - var markedRangeResultGC = internals.observeGC((() => { |
| - return textInputController.markedRange(); |
| - })()); |
| - var selectedRangeResultGC = internals.observeGC((() => { |
| - return textInputController.selectedRange(); |
| - })()); |
| - var firstRectForCharacterRangeGC = internals.observeGC((() => { |
| - return textInputController.firstRectForCharacterRange(0, 0); |
| - })()); |
| + // Do initialization work in an inner function to avoid references to |
| + // objects remaining live on this function's stack frame. |
| + // (http://crbug.com/595672/). |
| + var markedRangeResultGC, selectedRangeResultGC, |
| + firstRectForCharacterRangeGC; |
| + (function() { |
| + textInputController.setMarkedText("hello", 0, 5); |
|
rmcilroy
2016/05/23 12:31:17
I was meaning all the initialization code (e.g., g
mythria
2016/05/23 13:38:10
Done.
|
| + markedRangeResultGC = internals.observeGC( |
| + textInputController.markedRange()); |
| + selectedRangeResultGC = internals.observeGC( |
| + textInputController.selectedRange()); |
| + firstRectForCharacterRangeGC = internals.observeGC( |
| + textInputController.firstRectForCharacterRange(0, 0)); |
| + })(); |
| + |
| gc(); |
| shouldBeTrue('markedRangeResultGC.wasCollected'); |
| shouldBeTrue('selectedRangeResultGC.wasCollected'); |