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