| OLD | NEW |
| 1 library NativeGCTest; | 1 library NativeGCTest; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 | 5 |
| 6 var testEvent = new EventStreamProvider<Event>('test'); | 6 var testEvent = new EventStreamProvider<Event>('test'); |
| 7 | 7 |
| 8 main() { | 8 main() { |
| 9 useHtmlConfiguration(); | 9 useHtmlConfiguration(); |
| 10 | 10 |
| 11 test('EventListener', () { | 11 test('EventListener', () { |
| 12 final int N = 1000000; | 12 final int N = 1000000; |
| 13 final int M = 1000; | 13 final int M = 1000; |
| 14 | 14 |
| 15 var div; | 15 var div; |
| 16 for (int i = 0; i < M; ++i) { | 16 for (int i = 0; i < M; ++i) { |
| 17 // This memory should be freed when the listener below is | 17 // This memory should be freed when the listener below is |
| 18 // collected. | 18 // collected. |
| 19 List l = new List.fixedLength(N); | 19 List l = new List(N); |
| 20 | 20 |
| 21 // Record the iteration number. | 21 // Record the iteration number. |
| 22 l[N - 1] = i; | 22 l[N - 1] = i; |
| 23 | 23 |
| 24 div = new Element.tag('div'); | 24 div = new Element.tag('div'); |
| 25 testEvent.forTarget(div).listen((_) { | 25 testEvent.forTarget(div).listen((_) { |
| 26 // Only the final iteration's listener should be invoked. | 26 // Only the final iteration's listener should be invoked. |
| 27 // Note: the reference to l keeps the entire list alive. | 27 // Note: the reference to l keeps the entire list alive. |
| 28 expect(l[N - 1], M - 1); | 28 expect(l[N - 1], M - 1); |
| 29 }); | 29 }); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 46 for (int i = 0; i < 100; ++i) { | 46 for (int i = 0; i < 100; ++i) { |
| 47 triggerMajorGC(); | 47 triggerMajorGC(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 testDiv.onClick.listen(expectAsync1((e) {})); | 50 testDiv.onClick.listen(expectAsync1((e) {})); |
| 51 window.postMessage(message, '*'); | 51 window.postMessage(message, '*'); |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void triggerMajorGC() { | 55 void triggerMajorGC() { |
| 56 List list = new List.fixedLength(1000000); | 56 List list = new List(1000000); |
| 57 Element div = new DivElement(); | 57 Element div = new DivElement(); |
| 58 div.onClick.listen((e) => print(list[0])); | 58 div.onClick.listen((e) => print(list[0])); |
| 59 } | 59 } |
| OLD | NEW |