OLD | NEW |
| (Empty) |
1 library dromaeo; | |
2 import 'dart:async'; | |
3 import 'dart:html'; | |
4 import "dart:convert"; | |
5 import 'dart:math' as Math; | |
6 part 'Common.dart'; | |
7 part 'RunnerSuite.dart'; | |
8 | |
9 void main() { | |
10 final int num = 400; | |
11 var random = new Math.Random(); | |
12 | |
13 String str = 'null'; | |
14 // Very ugly way to build up the string, but let's mimic JS version as much as | |
15 // possible. | |
16 for (int i = 0; i < 1024; i++) { | |
17 str += new String.fromCharCode(((25 * random.nextDouble()) + 97).toInt()); | |
18 } | |
19 | |
20 List<Node> elems = <Node>[]; | |
21 | |
22 // Try to force real results. | |
23 var ret; | |
24 | |
25 final htmlstr = document.body.innerHtml; | |
26 | |
27 new Suite(window, 'dom-modify') | |
28 .test('createElement', () { | |
29 for (int i = 0; i < num; i++) { | |
30 ret = new Element.tag('div'); | |
31 ret = new Element.tag('span'); | |
32 ret = new Element.tag('table'); | |
33 ret = new Element.tag('tr'); | |
34 ret = new Element.tag('select'); | |
35 } | |
36 }) | |
37 .test('createTextNode', () { | |
38 for (int i = 0; i < num; i++) { | |
39 ret = new Text(str); | |
40 ret = new Text('${str}2'); | |
41 ret = new Text('${str}3'); | |
42 ret = new Text('${str}4'); | |
43 ret = new Text('${str}5'); | |
44 } | |
45 }) | |
46 .test('innerHtml', () { | |
47 document.body.innerHtml = htmlstr; | |
48 }) | |
49 .prep(() { | |
50 elems = new List<Node>(); | |
51 final telems = document.body.nodes; | |
52 for (int i = 0; i < telems.length; i++) { | |
53 elems.add(telems[i]); | |
54 } | |
55 }) | |
56 .test('cloneNode', () { | |
57 for (int i = 0; i < elems.length; i++) { | |
58 ret = elems[i].clone(false); | |
59 ret = elems[i].clone(true); | |
60 ret = elems[i].clone(true); | |
61 } | |
62 }) | |
63 .test('appendChild', () { | |
64 for (int i = 0; i < elems.length; i++) | |
65 document.body.append(elems[i]); | |
66 }) | |
67 .test('insertBefore', () { | |
68 for (int i = 0; i < elems.length; i++) | |
69 document.body.insertBefore(elems[i], document.body.firstChild); | |
70 }) | |
71 .end(); | |
72 } | |
OLD | NEW |