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

Side by Side Diff: test/codegen/lib/html/native_gc_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
(Empty)
1 library NativeGCTest;
2 import 'package:unittest/unittest.dart';
3 import 'package:unittest/html_config.dart';
4 import 'dart:html';
5
6 var testEvent = new EventStreamProvider<Event>('test');
7
8 main() {
9 useHtmlConfiguration();
10
11 test('EventListener', () {
12 final int N = 1000000;
13 final int M = 1000;
14
15 var div;
16 for (int i = 0; i < M; ++i) {
17 // This memory should be freed when the listener below is
18 // collected.
19 List l = new List(N);
20
21 // Record the iteration number.
22 l[N - 1] = i;
23
24 div = new Element.tag('div');
25 testEvent.forTarget(div).listen((_) {
26 // Only the final iteration's listener should be invoked.
27 // Note: the reference to l keeps the entire list alive.
28 expect(l[N - 1], M - 1);
29 });
30 }
31
32 final event = new Event('test');
33 div.dispatchEvent(event);
34 });
35
36 test('WindowEventListener', () {
37 String message = 'WindowEventListenerTestPingMessage';
38
39 Element testDiv = new DivElement();
40 testDiv.id = '#TestDiv';
41 document.body.append(testDiv);
42 window.onMessage.listen((e) {
43 if (e.data == message) testDiv.click();
44 });
45
46 for (int i = 0; i < 100; ++i) {
47 triggerMajorGC();
48 }
49
50 testDiv.onClick.listen(expectAsync((e) {}));
51 window.postMessage(message, '*');
52 });
53 }
54
55 void triggerMajorGC() {
56 List list = new List(1000000);
57 Element div = new DivElement();
58 div.onClick.listen((e) => print(list[0]));
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698