OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <input id='text' type='text'></input> | 3 <input id='text' type='text'></input> |
4 | 4 |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/js-test.js"></script> |
6 <script> | 6 <script> |
7 var input = document.getElementById('text'); | 7 var input = document.getElementById('text'); |
8 input.focus(); | 8 input.focus(); |
9 textInputController.setMarkedText("hello", 0, 5); | 9 textInputController.setMarkedText("hello", 0, 5); |
10 var markedRangeResultGC = internals.observeGC(textInputController.marked
Range()); | 10 // Do not pass the object directly to observeGC function. This may |
11 var selectedRangeResultGC = internals.observeGC(textInputController.sele
ctedRange()); | 11 // remain live on this function's stack preventing GC from collecting |
12 var firstRectForCharacterRangeGC = internals.observeGC(textInputControll
er.firstRectForCharacterRange(0, 0)); | 12 // it. Accessing the object inside an inner function will prevent any |
| 13 // unneeded references on this function's stack. |
| 14 var markedRangeResultGC = internals.observeGC((() => { |
| 15 return textInputController.markedRange(); |
| 16 })()); |
| 17 var selectedRangeResultGC = internals.observeGC((() => { |
| 18 return textInputController.selectedRange(); |
| 19 })()); |
| 20 var firstRectForCharacterRangeGC = internals.observeGC((() => { |
| 21 return textInputController.firstRectForCharacterRange(0, 0); |
| 22 })()); |
13 gc(); | 23 gc(); |
14 shouldBeTrue('markedRangeResultGC.wasCollected'); | 24 shouldBeTrue('markedRangeResultGC.wasCollected'); |
15 shouldBeTrue('selectedRangeResultGC.wasCollected'); | 25 shouldBeTrue('selectedRangeResultGC.wasCollected'); |
16 shouldBeTrue('firstRectForCharacterRangeGC.wasCollected'); | 26 shouldBeTrue('firstRectForCharacterRangeGC.wasCollected'); |
17 </script> | 27 </script> |
18 </body> | 28 </body> |
19 </html> | 29 </html> |
OLD | NEW |