OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #!/usr/bin/env python | 5 #!/usr/bin/env python |
6 # | 6 # |
7 | 7 |
8 """A test for htmlconverter.py | 8 """A test for htmlconverter.py |
9 """ | 9 """ |
10 | 10 |
11 from os.path import abspath, basename, dirname, exists, join, split | 11 from os.path import abspath, basename, dirname, exists, join, split |
12 import optparse | 12 import optparse |
13 import os | 13 import os |
14 import sys | 14 import sys |
15 import subprocess | 15 import subprocess |
16 | 16 |
17 # The inputs to our test | 17 # The inputs to our test |
18 TEST1_HTML = """ | 18 TEST1_HTML = """ |
19 <html> | 19 <html> |
20 <head></head> | 20 <head></head> |
21 <body> | 21 <body> |
22 <script type="application/javascript"> | 22 <script type="application/javascript"> |
23 if (window.layoutTestController) { | 23 if (window.layoutTestController) { |
24 window.layoutTestController.dumpAsText(); | 24 window.layoutTestController.dumpAsText(); |
25 } | 25 } |
26 </script> | 26 </script> |
27 | 27 |
28 <!-- embed source code --> | 28 <!-- embed source code --> |
29 <script type="application/dart"> | 29 <script type="application/dart"> |
30 #import('dart:dom'); | 30 #import('dart:dom_deprecated'); |
31 main() { | 31 main() { |
32 window.alert('hi'); | 32 window.alert('hi'); |
33 } | 33 } |
34 </script> | 34 </script> |
35 </body> | 35 </body> |
36 </html> | 36 </html> |
37 """ | 37 """ |
38 | 38 |
39 TEST1_OUTPUT = """ | 39 TEST1_OUTPUT = """ |
40 ALERT: hi | 40 ALERT: hi |
(...skipping 13 matching lines...) Expand all Loading... |
54 </script> | 54 </script> |
55 | 55 |
56 <!-- embed source code --> | 56 <!-- embed source code --> |
57 <script type="application/dart" src="test_2.dart"></script> | 57 <script type="application/dart" src="test_2.dart"></script> |
58 </body> | 58 </body> |
59 </html> | 59 </html> |
60 """ | 60 """ |
61 | 61 |
62 TEST2_DART = """ | 62 TEST2_DART = """ |
63 #library('test2'); | 63 #library('test2'); |
64 #import('dart:dom'); | 64 #import('dart:dom_deprecated'); |
65 main() { | 65 main() { |
66 window.alert('test2!'); | 66 window.alert('test2!'); |
67 } | 67 } |
68 """ | 68 """ |
69 | 69 |
70 TEST2_OUTPUT = """ | 70 TEST2_OUTPUT = """ |
71 ALERT: test2! | 71 ALERT: test2! |
72 Content-Type: text/plain | 72 Content-Type: text/plain |
73 | 73 |
74 #EOF | 74 #EOF |
75 """ | 75 """ |
76 | 76 |
77 TEST3_HTML = """ | 77 TEST3_HTML = """ |
78 <html> | 78 <html> |
79 <head></head> | 79 <head></head> |
80 <body> | 80 <body> |
81 <script type="application/javascript"> | 81 <script type="application/javascript"> |
82 if (window.layoutTestController) { | 82 if (window.layoutTestController) { |
83 window.layoutTestController.dumpAsText(); | 83 window.layoutTestController.dumpAsText(); |
84 } | 84 } |
85 </script> | 85 </script> |
86 | 86 |
87 <!-- embed source code --> | 87 <!-- embed source code --> |
88 <script type="application/dart" src="test_3.dart"></script> | 88 <script type="application/dart" src="test_3.dart"></script> |
89 </body> | 89 </body> |
90 </html> | 90 </html> |
91 """ | 91 """ |
92 | 92 |
93 TEST3_DART = """ | 93 TEST3_DART = """ |
94 #import('dart:dom'); | 94 #import('dart:dom_deprecated'); |
95 #source('test_3a.dart'); | 95 #source('test_3a.dart'); |
96 #source('test_3b.dart'); | 96 #source('test_3b.dart'); |
97 """ | 97 """ |
98 | 98 |
99 TEST3_DART_A = """ | 99 TEST3_DART_A = """ |
100 class MyClass { | 100 class MyClass { |
101 static myprint() { | 101 static myprint() { |
102 window.alert('test3!'); | 102 window.alert('test3!'); |
103 } | 103 } |
104 } | 104 } |
(...skipping 21 matching lines...) Expand all Loading... |
126 window.layoutTestController.dumpAsText(); | 126 window.layoutTestController.dumpAsText(); |
127 } | 127 } |
128 </script> | 128 </script> |
129 | 129 |
130 <script type="application/dart" src="test_4.dart"></script> | 130 <script type="application/dart" src="test_4.dart"></script> |
131 </body> | 131 </body> |
132 </html> | 132 </html> |
133 """ | 133 """ |
134 | 134 |
135 TEST4_DART = """ | 135 TEST4_DART = """ |
136 #import('dart:dom'); | 136 #import('dart:dom_deprecated'); |
137 #import('../samples/ui_lib/observable/observable.dart'); | 137 #import('../samples/ui_lib/observable/observable.dart'); |
138 | 138 |
139 main() { | 139 main() { |
140 // use imported code | 140 // use imported code |
141 var arr = new ObservableList(); | 141 var arr = new ObservableList(); |
142 arr.addChangeListener((EventSummary events) { | 142 arr.addChangeListener((EventSummary events) { |
143 var t = ['update', 'add ', | 143 var t = ['update', 'add ', |
144 'remove', 'global'][events.events[0].type]; | 144 'remove', 'global'][events.events[0].type]; |
145 var o = events.events[0].oldValue; | 145 var o = events.events[0].oldValue; |
146 o = (o != null ? o : '_'); | 146 o = (o != null ? o : '_'); |
(...skipping 30 matching lines...) Expand all Loading... |
177 <head></head> | 177 <head></head> |
178 <body> | 178 <body> |
179 <script type="application/javascript"> | 179 <script type="application/javascript"> |
180 if (window.layoutTestController) { | 180 if (window.layoutTestController) { |
181 window.layoutTestController.dumpAsText(); | 181 window.layoutTestController.dumpAsText(); |
182 } | 182 } |
183 </script> | 183 </script> |
184 | 184 |
185 <!-- embed source code --> | 185 <!-- embed source code --> |
186 <script type="application/dart"> | 186 <script type="application/dart"> |
187 #import('dart:dom'); | 187 #import('dart:dom_deprecated'); |
188 main() { | 188 main() { |
189 var element = document.getElementById("test5div"); | 189 var element = document.getElementById("test5div"); |
190 if (element == null) { | 190 if (element == null) { |
191 window.alert("this script shoulnd't be run synchronously"); | 191 window.alert("this script shoulnd't be run synchronously"); |
192 } else { | 192 } else { |
193 window.alert(element.innerHTML); | 193 window.alert(element.innerHTML); |
194 } | 194 } |
195 } | 195 } |
196 </script> | 196 </script> |
197 <div id="test5div">this is visible on DOMContentLoaded</div> | 197 <div id="test5div">this is visible on DOMContentLoaded</div> |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 deleteInputFiles() | 405 deleteInputFiles() |
406 return 1 | 406 return 1 |
407 | 407 |
408 if not keep_temporary_files: | 408 if not keep_temporary_files: |
409 deleteInputFiles() | 409 deleteInputFiles() |
410 return 0 | 410 return 0 |
411 | 411 |
412 | 412 |
413 if __name__ == '__main__': | 413 if __name__ == '__main__': |
414 sys.exit(main()) | 414 sys.exit(main()) |
OLD | NEW |