OLD | NEW |
1 library dom_query_html; | 1 library dom_query_html; |
2 import 'dart:html'; | 2 import 'dart:html'; |
3 import '../common/common.dart'; | 3 import '../common/common.dart'; |
4 import 'dart:math' as Math; | 4 import 'dart:math' as Math; |
5 part 'Common.dart'; | 5 part 'Common.dart'; |
6 part 'RunnerSuite.dart'; | 6 part 'RunnerSuite.dart'; |
7 | 7 |
8 void main() { | 8 void main() { |
9 final int num = 40; | 9 final int num = 40; |
10 | 10 |
11 // Try to force real results. | 11 // Try to force real results. |
12 var ret; | 12 var ret; |
13 | 13 |
14 String html = document.body.innerHTML; | 14 String html = document.body.innerHtml; |
15 | 15 |
16 new Suite(window, 'dom-query') | 16 new Suite(window, 'dom-query') |
17 .prep(() { | 17 .prep(() { |
18 html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { | 18 html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { |
19 final group = match.group(1); | 19 final group = match.group(1); |
20 return 'id="test${group}${num}"'; | 20 return 'id="test${group}${num}"'; |
21 }); | 21 }); |
22 html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { | 22 html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { |
23 return 'name="test${num}"'; | 23 return 'name="test${num}"'; |
24 }); | 24 }); |
25 html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { | 25 html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { |
26 return 'class="foo test${num} bar"'; | 26 return 'class="foo test${num} bar"'; |
27 }); | 27 }); |
28 final div = new Element.tag('div'); | 28 final div = new Element.tag('div'); |
29 div.innerHTML = html; | 29 div.innerHtml = html; |
30 document.body.nodes.add(div); | 30 document.body.nodes.add(div); |
31 }) | 31 }) |
32 .test('getElementById', () { | 32 .test('getElementById', () { |
33 for (int i = 0; i < num * 30; i++) { | 33 for (int i = 0; i < num * 30; i++) { |
34 ret = document.query('#testA$num').nodeType; | 34 ret = document.query('#testA$num').nodeType; |
35 ret = document.query('#testB$num').nodeType; | 35 ret = document.query('#testB$num').nodeType; |
36 ret = document.query('#testC$num').nodeType; | 36 ret = document.query('#testC$num').nodeType; |
37 ret = document.query('#testD$num').nodeType; | 37 ret = document.query('#testD$num').nodeType; |
38 ret = document.query('#testE$num').nodeType; | 38 ret = document.query('#testE$num').nodeType; |
39 ret = document.query('#testF$num').nodeType; | 39 ret = document.query('#testF$num').nodeType; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 for (int i = 0; i < num * 20; i++) { | 95 for (int i = 0; i < num * 20; i++) { |
96 ret = document.queryAll('[name="test"]').length == 0; | 96 ret = document.queryAll('[name="test"]').length == 0; |
97 ret = document.queryAll('[name="test"]').length == 0; | 97 ret = document.queryAll('[name="test"]').length == 0; |
98 ret = document.queryAll('[name="test"]').length == 0; | 98 ret = document.queryAll('[name="test"]').length == 0; |
99 ret = document.queryAll('[name="test"]').length == 0; | 99 ret = document.queryAll('[name="test"]').length == 0; |
100 ret = document.queryAll('[name="test"]').length == 0; | 100 ret = document.queryAll('[name="test"]').length == 0; |
101 } | 101 } |
102 }) | 102 }) |
103 .end(); | 103 .end(); |
104 } | 104 } |
OLD | NEW |