| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // TODO(jmesserly): merge into import_inliner_test.dart. | 5 // TODO(jmesserly): merge into import_inliner_test.dart. |
| 6 // Keeping here for now so it's easier to see the diff. | 6 // Keeping here for now so it's easier to see the diff. |
| 7 part of polymer.test.build.import_inliner_test; | 7 part of polymer.test.build.import_inliner_test; |
| 8 | 8 |
| 9 void codeExtractorTests() { | 9 void codeExtractorTests() { |
| 10 testPhases('no changes', phases, { | 10 testPhases('no changes', phases, { |
| 11 'a|web/test.html': '<!DOCTYPE html><html></html>', | 11 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 12 }, { | 12 }, { |
| 13 'a|web/test.html': '<!DOCTYPE html><html></html>', | 13 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 14 }); | 14 }); |
| 15 | 15 |
| 16 testPhases('single script, no library in script', phases, { | 16 testPhases('single script, no library in script', phases, { |
| 17 'a|web/test.html': | 17 'a|web/test.html': |
| 18 '<!DOCTYPE html><html><head>' | 18 '<!DOCTYPE html><html><head>' |
| 19 '<script type="application/dart">main() { }</script>', | 19 '<script type="application/dart">main() { }</script>', |
| 20 }, { | 20 }, { |
| 21 'a|web/test.html': | 21 'a|web/test.html': |
| 22 '<!DOCTYPE html><html><head></head><body>' | 22 '<!DOCTYPE html><html><head></head><body>' |
| 23 '<script type="application/dart" src="test.html.0.dart"></script>' | |
| 24 '</body></html>', | |
| 25 | |
| 26 'a|web/test.html.0.dart': | |
| 27 'library a.web.test_html_0;\nmain() { }', | |
| 28 }); | |
| 29 | |
| 30 testPhases('component script, no library in script', phases, { | |
| 31 'a|web/test.html': | |
| 32 '<!DOCTYPE html><html><head>' | |
| 33 '<script type="application/dart;component=1">main() { }</script>', | |
| 34 }, { | |
| 35 'a|web/test.html': | |
| 36 '<!DOCTYPE html><html><head></head><body>' | |
| 37 '</body></html>', | 23 '</body></html>', |
| 38 | 24 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 39 'a|web/test.html.0.dart': | 25 'a|web/test.html.0.dart': |
| 40 'library a.web.test_html_0;\nmain() { }', | 26 'library a.web.test_html_0;\nmain() { }', |
| 41 }); | 27 }); |
| 42 | 28 |
| 43 testPhases('single script, with library', phases, { | 29 testPhases('single script, with library', phases, { |
| 44 'a|web/test.html': | 30 'a|web/test.html': |
| 45 '<!DOCTYPE html><html><head>' | 31 '<!DOCTYPE html><html><head>' |
| 46 '<script type="application/dart">library f;\nmain() { }</script>', | 32 '<script type="application/dart">library f;\nmain() { }</script>', |
| 47 }, { | 33 }, { |
| 48 'a|web/test.html': | 34 'a|web/test.html': |
| 49 '<!DOCTYPE html><html><head></head><body>' | 35 '<!DOCTYPE html><html><head></head><body>' |
| 50 '<script type="application/dart" src="test.html.0.dart"></script>' | |
| 51 '</body></html>', | 36 '</body></html>', |
| 52 | 37 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 53 'a|web/test.html.0.dart': | 38 'a|web/test.html.0.dart': |
| 54 'library f;\nmain() { }', | 39 'library f;\nmain() { }', |
| 55 }); | 40 }); |
| 56 | 41 |
| 57 testPhases('under lib/ directory not transformed', phases, { | 42 testPhases('under lib/ directory not transformed', phases, { |
| 58 'a|lib/test.html': | 43 'a|lib/test.html': |
| 59 '<!DOCTYPE html><html><head>' | 44 '<!DOCTYPE html><html><head>' |
| 60 '<script type="application/dart">library f;\nmain() { }</script>' | 45 '<script type="application/dart">library f;\nmain() { }</script>', |
| 61 '<script type="application/dart;component=1">' | |
| 62 'library g;\nmain() { }</script>', | |
| 63 }, { | 46 }, { |
| 64 'a|lib/test.html': | 47 'a|lib/test.html': |
| 65 '<!DOCTYPE html><html><head>' | 48 '<!DOCTYPE html><html><head>' |
| 66 '<script type="application/dart">library f;\nmain() { }</script>' | 49 '<script type="application/dart">library f;\nmain() { }</script>' |
| 67 '<script type="application/dart;component=1">' | |
| 68 'library g;\nmain() { }</script>', | |
| 69 }); | 50 }); |
| 70 | 51 |
| 71 testPhases('multiple scripts allowed', phases, { | 52 testPhases('multiple scripts - removed', phases, { |
| 72 'a|web/test.html': | 53 'a|web/test.html': |
| 73 '<!DOCTYPE html><html><head>' | 54 '<!DOCTYPE html><html><head>' |
| 74 '<script type="application/dart">library a1;\nmain1() { }</script>' | 55 '<script type="application/dart">library a1;\nmain1() { }</script>' |
| 75 '<script type="application/dart">library a2;\nmain2() { }</script>', | 56 '<script type="application/dart">library a2;\nmain2() { }</script>', |
| 76 }, { | 57 }, { |
| 77 'a|web/test.html': | 58 'a|web/test.html': |
| 78 '<!DOCTYPE html><html><head></head><body>' | 59 '<!DOCTYPE html><html><head></head><body>' |
| 79 '<script type="application/dart" src="test.html.0.dart"></script>' | |
| 80 '<script type="application/dart" src="test.html.1.dart"></script>' | |
| 81 '</body></html>', | 60 '</body></html>', |
| 82 | 61 'a|web/test.html._data': expectedData( |
| 62 ['web/test.html.0.dart', 'web/test.html.1.dart']), |
| 83 'a|web/test.html.0.dart': | 63 'a|web/test.html.0.dart': |
| 84 'library a1;\nmain1() { }', | 64 'library a1;\nmain1() { }', |
| 85 'a|web/test.html.1.dart': | 65 'a|web/test.html.1.dart': |
| 86 'library a2;\nmain2() { }', | 66 'library a2;\nmain2() { }', |
| 87 }); | 67 }); |
| 88 | 68 |
| 89 testPhases('component scripts removed', phases, { | |
| 90 'a|web/test.html': | |
| 91 '<!DOCTYPE html><html><head>' | |
| 92 '<script type="application/dart;component=1">' | |
| 93 'library a1;\nmain1() { }</script>' | |
| 94 '<script type="application/dart;component=1">' | |
| 95 'library a2;\nmain2() { }</script>', | |
| 96 }, { | |
| 97 'a|web/test.html': | |
| 98 '<!DOCTYPE html><html><head></head><body>' | |
| 99 '</body></html>', | |
| 100 'a|web/test.html.scriptUrls': JSON.encode([ | |
| 101 ["a", "web/test.html.0.dart"], | |
| 102 ["a", "web/test.html.1.dart"]]), | |
| 103 'a|web/test.html.0.dart': | |
| 104 'library a1;\nmain1() { }', | |
| 105 'a|web/test.html.1.dart': | |
| 106 'library a2;\nmain2() { }', | |
| 107 }); | |
| 108 | |
| 109 testPhases('multiple deeper scripts', phases, { | |
| 110 'a|web/test.html': | |
| 111 '<!DOCTYPE html><html><head>' | |
| 112 '<script type="application/dart">main1() { }</script>' | |
| 113 '</head><body><div>' | |
| 114 '<script type="application/dart">main2() { }</script>' | |
| 115 '</div><div><div>' | |
| 116 '<script type="application/dart">main3() { }</script>' | |
| 117 '</div></div>' | |
| 118 }, { | |
| 119 'a|web/test.html': | |
| 120 '<!DOCTYPE html><html><head>' | |
| 121 '</head><body>' | |
| 122 '<script type="application/dart" src="test.html.0.dart"></script>' | |
| 123 '<div>' | |
| 124 '<script type="application/dart" src="test.html.1.dart"></script>' | |
| 125 '</div><div><div>' | |
| 126 '<script type="application/dart" src="test.html.2.dart"></script>' | |
| 127 '</div></div></body></html>', | |
| 128 | |
| 129 'a|web/test.html.0.dart': | |
| 130 'library a.web.test_html_0;\nmain1() { }', | |
| 131 'a|web/test.html.1.dart': | |
| 132 'library a.web.test_html_1;\nmain2() { }', | |
| 133 'a|web/test.html.2.dart': | |
| 134 'library a.web.test_html_2;\nmain3() { }', | |
| 135 }); | |
| 136 | |
| 137 testPhases('multiple imported scripts', phases, { | 69 testPhases('multiple imported scripts', phases, { |
| 138 'a|web/test.html': | 70 'a|web/test.html': |
| 139 '<link rel="import" href="test2.html">' | 71 '<link rel="import" href="test2.html">' |
| 140 '<link rel="import" href="bar/test.html">' | 72 '<link rel="import" href="bar/test.html">' |
| 141 '<link rel="import" href="packages/a/foo/test.html">' | 73 '<link rel="import" href="packages/a/foo/test.html">' |
| 142 '<link rel="import" href="packages/b/test.html">', | 74 '<link rel="import" href="packages/b/test.html">', |
| 143 'a|web/test2.html': | 75 'a|web/test2.html': |
| 144 '<script type="application/dart;component=1">main1() { }', | 76 '<script type="application/dart">main1() { }', |
| 145 'a|web/bar/test.html': | 77 'a|web/bar/test.html': |
| 146 '<script type="application/dart;component=1">main2() { }', | 78 '<script type="application/dart">main2() { }', |
| 147 'a|lib/foo/test.html': | 79 'a|lib/foo/test.html': |
| 148 '<script type="application/dart;component=1">main3() { }', | 80 '<script type="application/dart">main3() { }', |
| 149 'b|lib/test.html': | 81 'b|lib/test.html': |
| 150 '<script type="application/dart;component=1">main4() { }' | 82 '<script type="application/dart">main4() { }' |
| 151 }, { | 83 }, { |
| 152 'a|web/test.html': | 84 'a|web/test.html': |
| 153 '<html><head></head><body></body></html>', | 85 '<html><head></head><body></body></html>', |
| 154 'a|web/test.html.scriptUrls': JSON.encode([ | 86 'a|web/test.html._data': expectedData(["web/test.html.0.dart", |
| 155 ["a", "web/test.html.0.dart"], | 87 "web/test.html.1.dart", "web/test.html.2.dart", |
| 156 ["a", "web/test.html.1.dart"], | 88 "web/test.html.3.dart"]), |
| 157 ["a", "web/test.html.2.dart"], | |
| 158 ["a", "web/test.html.3.dart"], | |
| 159 ]), | |
| 160 'a|web/test.html.0.dart': 'library a.web.test2_html_0;\nmain1() { }', | 89 'a|web/test.html.0.dart': 'library a.web.test2_html_0;\nmain1() { }', |
| 161 'a|web/test.html.1.dart': 'library a.web.bar.test_html_1;\nmain2() { }', | 90 'a|web/test.html.1.dart': 'library a.web.bar.test_html_1;\nmain2() { }', |
| 162 'a|web/test.html.2.dart': 'library a.foo.test_html_2;\nmain3() { }', | 91 'a|web/test.html.2.dart': 'library a.foo.test_html_2;\nmain3() { }', |
| 163 'a|web/test.html.3.dart': 'library b.test_html_3;\nmain4() { }' | 92 'a|web/test.html.3.dart': 'library b.test_html_3;\nmain4() { }' |
| 164 }); | 93 }); |
| 165 | 94 |
| 95 testPhases('experimental bootstrap', phases, { |
| 96 'a|web/test.html': |
| 97 '<link rel="import" ' |
| 98 'href="packages/polymer/polymer_experimental.html">' |
| 99 '<link rel="import" href="test2.html">', |
| 100 'a|web/test2.html': |
| 101 '<script type="application/dart">main1() { }', |
| 102 }, { |
| 103 'a|web/test.html': |
| 104 '<html><head></head><body></body></html>', |
| 105 'a|web/test.html._data': expectedData(["web/test.html.0.dart"], |
| 106 experimental: true), |
| 107 'a|web/test.html.0.dart': 'library a.web.test2_html_0;\nmain1() { }', |
| 108 }); |
| 109 |
| 166 group('fixes import/export/part URIs', dartUriTests); | 110 group('fixes import/export/part URIs', dartUriTests); |
| 167 group('validates script-tag URIs', validateUriTests); | 111 group('validates script-tag URIs', validateUriTests); |
| 168 } | 112 } |
| 169 | 113 |
| 170 dartUriTests() { | 114 dartUriTests() { |
| 171 | 115 |
| 172 testPhases('from web folder', phases, { | 116 testPhases('from web folder', phases, { |
| 173 'a|web/test.html': | 117 'a|web/test.html': |
| 174 '<!DOCTYPE html><html><head>' | 118 '<!DOCTYPE html><html><head>' |
| 175 '<link rel="import" href="test2/foo.html">' | 119 '<link rel="import" href="test2/foo.html">' |
| 176 '</head><body></body></html>', | 120 '</head><body></body></html>', |
| 177 'a|web/test2/foo.html': | 121 'a|web/test2/foo.html': |
| 178 '<!DOCTYPE html><html><head></head><body>' | 122 '<!DOCTYPE html><html><head></head><body>' |
| 179 '<script type="application/dart">' | 123 '<script type="application/dart">' |
| 180 "import 'package:qux/qux.dart';" | 124 "import 'package:qux/qux.dart';" |
| 181 "import 'foo.dart';" | 125 "import 'foo.dart';" |
| 182 "export 'bar.dart';" | 126 "export 'bar.dart';" |
| 183 "part 'baz.dart';" | 127 "part 'baz.dart';" |
| 184 '</script>' | 128 '</script>' |
| 185 '</body></html>', | 129 '</body></html>', |
| 186 }, { | 130 }, { |
| 187 'a|web/test.html': | 131 'a|web/test.html': |
| 188 '<!DOCTYPE html><html><head></head><body>' | 132 '<!DOCTYPE html><html><head></head><body></body></html>', |
| 189 '<script type="application/dart" src="test.html.0.dart"></script>' | 133 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 190 '</body></html>', | |
| 191 'a|web/test.html.scriptUrls': '[]', | |
| 192 'a|web/test.html.0.dart': | 134 'a|web/test.html.0.dart': |
| 193 "library a.web.test2.foo_html_0;\n" | 135 "library a.web.test2.foo_html_0;\n" |
| 194 "import 'package:qux/qux.dart';" | 136 "import 'package:qux/qux.dart';" |
| 195 "import 'test2/foo.dart';" | 137 "import 'test2/foo.dart';" |
| 196 "export 'test2/bar.dart';" | 138 "export 'test2/bar.dart';" |
| 197 "part 'test2/baz.dart';", | 139 "part 'test2/baz.dart';", |
| 198 'a|web/test2/foo.html': | 140 'a|web/test2/foo.html': |
| 199 '<!DOCTYPE html><html><head></head><body>' | 141 '<!DOCTYPE html><html><head></head><body>' |
| 200 '<script type="application/dart" src="foo.html.0.dart"></script>' | |
| 201 '</body></html>', | 142 '</body></html>', |
| 202 'a|web/test2/foo.html.scriptUrls': '[]', | 143 'a|web/test2/foo.html._data': expectedData(['web/test2/foo.html.0.dart']), |
| 203 'a|web/test2/foo.html.0.dart': | 144 'a|web/test2/foo.html.0.dart': |
| 204 "library a.web.test2.foo_html_0;\n" | 145 "library a.web.test2.foo_html_0;\n" |
| 205 "import 'package:qux/qux.dart';" | 146 "import 'package:qux/qux.dart';" |
| 206 "import 'foo.dart';" | |
| 207 "export 'bar.dart';" | |
| 208 "part 'baz.dart';", | |
| 209 }); | |
| 210 | |
| 211 testPhases('from web folder, component', phases, { | |
| 212 'a|web/test.html': | |
| 213 '<!DOCTYPE html><html><head>' | |
| 214 '<link rel="import" href="test2/foo.html">' | |
| 215 '</head><body></body></html>', | |
| 216 'a|web/test2/foo.html': | |
| 217 '<!DOCTYPE html><html><head></head><body>' | |
| 218 '<script type="application/dart;component=1">' | |
| 219 "import 'package:qux/qux.dart';" | |
| 220 "import 'foo.dart';" | |
| 221 "export 'bar.dart';" | |
| 222 "part 'baz.dart';" | |
| 223 '</script>' | |
| 224 '</body></html>', | |
| 225 }, { | |
| 226 'a|web/test.html': | |
| 227 '<!DOCTYPE html><html><head></head><body></body></html>', | |
| 228 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', | |
| 229 'a|web/test.html.0.dart': | |
| 230 "library a.web.test2.foo_html_0;\n" | |
| 231 "import 'package:qux/qux.dart';" | |
| 232 "import 'test2/foo.dart';" | |
| 233 "export 'test2/bar.dart';" | |
| 234 "part 'test2/baz.dart';", | |
| 235 'a|web/test2/foo.html': | |
| 236 '<!DOCTYPE html><html><head></head><body></body></html>', | |
| 237 'a|web/test2/foo.html.scriptUrls': '[["a","web/test2/foo.html.0.dart"]]', | |
| 238 'a|web/test2/foo.html.0.dart': | |
| 239 "library a.web.test2.foo_html_0;\n" | |
| 240 "import 'package:qux/qux.dart';" | |
| 241 "import 'foo.dart';" | 147 "import 'foo.dart';" |
| 242 "export 'bar.dart';" | 148 "export 'bar.dart';" |
| 243 "part 'baz.dart';", | 149 "part 'baz.dart';", |
| 244 }); | 150 }); |
| 245 | 151 |
| 246 testPhases('from lib folder', phases, { | 152 testPhases('from lib folder', phases, { |
| 247 'a|web/test.html': | 153 'a|web/test.html': |
| 248 '<!DOCTYPE html><html><head>' | 154 '<!DOCTYPE html><html><head>' |
| 249 '<link rel="import" href="packages/a/test2/foo.html">' | 155 '<link rel="import" href="packages/a/test2/foo.html">' |
| 250 '</head><body></body></html>', | 156 '</head><body></body></html>', |
| 251 'a|lib/test2/foo.html': | 157 'a|lib/test2/foo.html': |
| 252 '<!DOCTYPE html><html><head></head><body>' | 158 '<!DOCTYPE html><html><head></head><body>' |
| 253 '<script type="application/dart;component=1">' | 159 '<script type="application/dart">' |
| 254 "import 'package:qux/qux.dart';" | 160 "import 'package:qux/qux.dart';" |
| 255 "import 'foo.dart';" | 161 "import 'foo.dart';" |
| 256 "export 'bar.dart';" | 162 "export 'bar.dart';" |
| 257 "part 'baz.dart';" | 163 "part 'baz.dart';" |
| 258 '</script>' | 164 '</script>' |
| 259 '</body></html>', | 165 '</body></html>', |
| 260 }, { | 166 }, { |
| 261 'a|web/test.html': | 167 'a|web/test.html': |
| 262 '<!DOCTYPE html><html><head></head><body></body></html>', | 168 '<!DOCTYPE html><html><head></head><body></body></html>', |
| 263 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', | 169 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 264 'a|web/test.html.0.dart': | 170 'a|web/test.html.0.dart': |
| 265 "library a.test2.foo_html_0;\n" | 171 "library a.test2.foo_html_0;\n" |
| 266 "import 'package:qux/qux.dart';" | 172 "import 'package:qux/qux.dart';" |
| 267 "import 'package:a/test2/foo.dart';" | 173 "import 'package:a/test2/foo.dart';" |
| 268 "export 'package:a/test2/bar.dart';" | 174 "export 'package:a/test2/bar.dart';" |
| 269 "part 'package:a/test2/baz.dart';", | 175 "part 'package:a/test2/baz.dart';", |
| 270 'a|lib/test2/foo.html': | 176 'a|lib/test2/foo.html': |
| 271 '<!DOCTYPE html><html><head></head><body>' | 177 '<!DOCTYPE html><html><head></head><body>' |
| 272 '<script type="application/dart;component=1">' | 178 '<script type="application/dart">' |
| 273 "import 'package:qux/qux.dart';" | 179 "import 'package:qux/qux.dart';" |
| 274 "import 'foo.dart';" | 180 "import 'foo.dart';" |
| 275 "export 'bar.dart';" | 181 "export 'bar.dart';" |
| 276 "part 'baz.dart';" | 182 "part 'baz.dart';" |
| 277 '</script>' | 183 '</script>' |
| 278 '</body></html>', | 184 '</body></html>', |
| 279 }); | 185 }); |
| 280 | 186 |
| 281 testPhases('from another pkg', phases, { | 187 testPhases('from another pkg', phases, { |
| 282 'a|web/test.html': | 188 'a|web/test.html': |
| 283 '<!DOCTYPE html><html><head>' | 189 '<!DOCTYPE html><html><head>' |
| 284 '<link rel="import" href="packages/b/test2/foo.html">' | 190 '<link rel="import" href="packages/b/test2/foo.html">' |
| 285 '</head><body></body></html>', | 191 '</head><body></body></html>', |
| 286 'b|lib/test2/foo.html': | 192 'b|lib/test2/foo.html': |
| 287 '<!DOCTYPE html><html><head></head><body>' | 193 '<!DOCTYPE html><html><head></head><body>' |
| 288 '<script type="application/dart;component=1">' | 194 '<script type="application/dart">' |
| 289 "import 'package:qux/qux.dart';" | 195 "import 'package:qux/qux.dart';" |
| 290 "import 'foo.dart';" | 196 "import 'foo.dart';" |
| 291 "export 'bar.dart';" | 197 "export 'bar.dart';" |
| 292 "part 'baz.dart';" | 198 "part 'baz.dart';" |
| 293 '</script>' | 199 '</script>' |
| 294 '</body></html>', | 200 '</body></html>', |
| 295 }, { | 201 }, { |
| 296 'a|web/test.html': | 202 'a|web/test.html': |
| 297 '<!DOCTYPE html><html><head></head><body></body></html>', | 203 '<!DOCTYPE html><html><head></head><body></body></html>', |
| 298 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', | 204 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 299 'a|web/test.html.0.dart': | 205 'a|web/test.html.0.dart': |
| 300 "library b.test2.foo_html_0;\n" | 206 "library b.test2.foo_html_0;\n" |
| 301 "import 'package:qux/qux.dart';" | 207 "import 'package:qux/qux.dart';" |
| 302 "import 'package:b/test2/foo.dart';" | 208 "import 'package:b/test2/foo.dart';" |
| 303 "export 'package:b/test2/bar.dart';" | 209 "export 'package:b/test2/bar.dart';" |
| 304 "part 'package:b/test2/baz.dart';", | 210 "part 'package:b/test2/baz.dart';", |
| 305 'b|lib/test2/foo.html': | 211 'b|lib/test2/foo.html': |
| 306 '<!DOCTYPE html><html><head></head><body>' | 212 '<!DOCTYPE html><html><head></head><body>' |
| 307 '<script type="application/dart;component=1">' | 213 '<script type="application/dart">' |
| 308 "import 'package:qux/qux.dart';" | 214 "import 'package:qux/qux.dart';" |
| 309 "import 'foo.dart';" | 215 "import 'foo.dart';" |
| 310 "export 'bar.dart';" | 216 "export 'bar.dart';" |
| 311 "part 'baz.dart';" | 217 "part 'baz.dart';" |
| 312 '</script>' | 218 '</script>' |
| 313 '</body></html>', | 219 '</body></html>', |
| 314 }); | 220 }); |
| 315 } | 221 } |
| 316 | 222 |
| 317 validateUriTests() { | 223 validateUriTests() { |
| 318 | 224 |
| 319 testPhases('script is inline', phases, { | 225 testPhases('script is inline', phases, { |
| 320 'a|web/test.html': | 226 'a|web/test.html': |
| 321 '<!DOCTYPE html><html><body>' | 227 '<!DOCTYPE html><html><body>' |
| 322 '<script type="application/dart;component=1">' | 228 '<script type="application/dart">' |
| 323 'main(){}' | 229 'main(){}' |
| 324 '</script>' | 230 '</script>' |
| 325 '</body></html>', | 231 '</body></html>', |
| 326 }, { | 232 }, { |
| 327 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', | 233 'a|web/test.html._data': expectedData(['web/test.html.0.dart']), |
| 328 }, []); | 234 }, []); |
| 329 | 235 |
| 330 testPhases('script src is valid', phases, { | 236 testPhases('script src is valid', phases, { |
| 331 'a|web/test.html': | 237 'a|web/test.html': |
| 332 '<!DOCTYPE html><html><body>' | 238 '<!DOCTYPE html><html><body>' |
| 333 '<script type="application/dart;component=1" src="a.dart"></script>' | 239 '<script type="application/dart" src="a.dart"></script>' |
| 334 '</body></html>', | 240 '</body></html>', |
| 335 'a|web/a.dart': 'main() {}', | 241 'a|web/a.dart': 'main() {}', |
| 336 }, { | 242 }, { |
| 337 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 243 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 338 }, []); | 244 }, []); |
| 339 | 245 |
| 340 testPhases('script src is invalid', phases, { | 246 testPhases('script src is invalid', phases, { |
| 341 'a|web/test.html': | 247 'a|web/test.html': |
| 342 '<!DOCTYPE html><html><body>\n' | 248 '<!DOCTYPE html><html><body>\n' |
| 343 '<script type="application/dart;component=1" src="a.dart"></script>' | 249 '<script type="application/dart" src="a.dart"></script>' |
| 344 '</body></html>', | 250 '</body></html>', |
| 345 }, { | 251 }, { |
| 346 'a|web/test.html.scriptUrls': '[]', | 252 'a|web/test.html._data': EMPTY_DATA, |
| 347 }, [ | 253 }, [ |
| 348 'warning: Script file at "a.dart" not found. (web/test.html 1 0)', | 254 'warning: Script file at "a.dart" not found. (web/test.html 1 0)', |
| 349 ]); | 255 ]); |
| 350 | 256 |
| 351 testPhases('many script src around, valid and invalid', phases, { | 257 testPhases('many script src around, valid and invalid', phases, { |
| 352 'a|web/test.html': | 258 'a|web/test.html': |
| 353 '<!DOCTYPE html><html><body>' | 259 '<!DOCTYPE html><html><body>' |
| 354 '<script type="application/dart;component=1" src="a.dart"></script>' | 260 '<script type="application/dart" src="a.dart"></script>' |
| 355 '\n<script type="application/dart;component=1" src="b.dart"></script>' | 261 '\n<script type="application/dart" src="b.dart"></script>' |
| 356 '\n<script type="application/dart;component=1" src="c.dart"></script>' | 262 '\n<script type="application/dart" src="c.dart"></script>' |
| 357 '\n<script type="application/dart;component=1" src="d.dart"></script>' | 263 '\n<script type="application/dart" src="d.dart"></script>' |
| 358 '</body></html>', | 264 '</body></html>', |
| 359 'a|web/a.dart': 'main() {}', | 265 'a|web/a.dart': 'main() {}', |
| 360 'a|web/c.dart': 'main() {}', | 266 'a|web/c.dart': 'main() {}', |
| 361 }, { | 267 }, { |
| 362 'a|web/test.html.scriptUrls': '[["a","web/a.dart"],["a","web/c.dart"]]', | 268 'a|web/test.html._data': expectedData(['web/a.dart', 'web/c.dart']), |
| 363 }, [ | 269 }, [ |
| 364 'warning: Script file at "b.dart" not found. (web/test.html 1 0)', | 270 'warning: Script file at "b.dart" not found. (web/test.html 1 0)', |
| 365 'warning: Script file at "d.dart" not found. (web/test.html 3 0)', | 271 'warning: Script file at "d.dart" not found. (web/test.html 3 0)', |
| 366 ]); | 272 ]); |
| 367 } | 273 } |
| OLD | NEW |