Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #library('NativeGCTest'); | 1 #library('NativeGCTest'); |
| 2 #import('../../lib/unittest/unittest.dart'); | 2 #import('../../lib/unittest/unittest.dart'); |
| 3 #import('../../lib/unittest/html_config.dart'); | 3 #import('../../lib/unittest/html_config.dart'); |
| 4 #import('dart:html'); | 4 #import('dart:html'); |
| 5 | 5 |
| 6 main() { | 6 main() { |
| 7 useHtmlConfiguration(); | 7 useHtmlConfiguration(); |
| 8 | 8 |
| 9 test('EventListener', () { | 9 test('EventListener', () { |
| 10 final int N = 1000000; | 10 final int N = 1000000; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 div.on['test'].add((_) { | 23 div.on['test'].add((_) { |
| 24 // Only the final iteration's listener should be invoked. | 24 // Only the final iteration's listener should be invoked. |
| 25 // Note: the reference to l keeps the entire list alive. | 25 // Note: the reference to l keeps the entire list alive. |
| 26 Expect.equals(M - 1, l[N - 1]); | 26 Expect.equals(M - 1, l[N - 1]); |
| 27 }, false); | 27 }, false); |
| 28 } | 28 } |
| 29 | 29 |
| 30 final event = new Event('test'); | 30 final event = new Event('test'); |
| 31 div.on['test'].dispatch(event); | 31 div.on['test'].dispatch(event); |
| 32 }); | 32 }); |
| 33 | |
| 34 test('WindowEventListener', () { | |
| 35 Element testDiv = new DivElement(); | |
| 36 testDiv.id = '#TestDiv'; | |
| 37 document.body.nodes.add(testDiv); | |
| 38 window.on.message.add((e) => testDiv.click()); | |
| 39 | |
| 40 for (int i = 0; i < 100; ++i) { | |
| 41 triggerMajorGC(); | |
| 42 } | |
| 43 | |
| 44 testDiv.on.click.add(expectAsync1((e) {})); | |
| 45 window.postMessage('test', '*'); | |
| 46 }); | |
| 33 } | 47 } |
| 48 | |
| 49 void triggerMajorGC() { | |
| 50 List list = new List(1000000); | |
|
Anton Muhin
2012/07/06 16:17:01
somewhat fragile, but, I don't know better approac
| |
| 51 Element div = new DivElement(); | |
| 52 div.on.click.add((e) => print(list[0])); | |
|
Anton Muhin
2012/07/06 16:17:01
why?
podivilov
2012/07/10 08:33:52
why not? :)
Anton Muhin
2012/07/10 08:41:38
It's not obvious why code which promises to trigge
podivilov
2012/07/10 11:03:47
Is it possible that void foo() { List list = new L
Anton Muhin
2012/07/10 11:36:16
That's a good point, but in this case you'd better
| |
| 53 } | |
| OLD | NEW |