OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.runner.browser.server; | 5 library test.runner.browser.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 import '../load_exception.dart'; | 29 import '../load_exception.dart'; |
30 import 'browser.dart'; | 30 import 'browser.dart'; |
31 import 'browser_manager.dart'; | 31 import 'browser_manager.dart'; |
32 import 'compiler_pool.dart'; | 32 import 'compiler_pool.dart'; |
33 import 'chrome.dart'; | 33 import 'chrome.dart'; |
34 import 'content_shell.dart'; | 34 import 'content_shell.dart'; |
35 import 'dartium.dart'; | 35 import 'dartium.dart'; |
36 import 'firefox.dart'; | 36 import 'firefox.dart'; |
37 import 'internet_explorer.dart'; | 37 import 'internet_explorer.dart'; |
38 import 'phantom_js.dart'; | 38 import 'phantom_js.dart'; |
| 39 import 'polymer.dart'; |
39 import 'safari.dart'; | 40 import 'safari.dart'; |
40 | 41 |
41 /// A server that serves JS-compiled tests to browsers. | 42 /// A server that serves JS-compiled tests to browsers. |
42 /// | 43 /// |
43 /// A test suite may be loaded for a given file using [loadSuite]. | 44 /// A test suite may be loaded for a given file using [loadSuite]. |
44 class BrowserServer { | 45 class BrowserServer { |
45 /// Starts the server. | 46 /// Starts the server. |
46 /// | 47 /// |
47 /// [root] is the root directory that the server should serve. It defaults to | 48 /// [root] is the root directory that the server should serve. It defaults to |
48 /// the working directory. | 49 /// the working directory. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 throw new LoadException( | 257 throw new LoadException( |
257 path, | 258 path, |
258 '"${htmlPath}" must contain <script src="packages/test/dart.js">' | 259 '"${htmlPath}" must contain <script src="packages/test/dart.js">' |
259 '</script>.'); | 260 '</script>.'); |
260 } | 261 } |
261 | 262 |
262 var suiteUrl; | 263 var suiteUrl; |
263 if (_pubServeUrl != null) { | 264 if (_pubServeUrl != null) { |
264 var suitePrefix = p.withoutExtension( | 265 var suitePrefix = p.withoutExtension( |
265 p.relative(path, from: p.join(_root, 'test'))); | 266 p.relative(path, from: p.join(_root, 'test'))); |
266 var jsUrl = _pubServeUrl.resolve( | 267 |
| 268 var jsUrl; |
| 269 // Polymer generates a bootstrap entrypoint that wraps the entrypoint we |
| 270 // see on disk, and modifies the HTML file to point to the bootstrap |
| 271 // instead. To make sure we get the right source maps and wait for the |
| 272 // right file to compile, we have some Polymer-specific logic here to load |
| 273 // the boostrap instead of the unwrapped file. |
| 274 if (isPolymerEntrypoint(path)) { |
| 275 jsUrl = _pubServeUrl.resolve( |
| 276 "$suitePrefix.html.polymer.bootstrap.dart.browser_test.dart.js"); |
| 277 } else { |
| 278 jsUrl = _pubServeUrl.resolve( |
267 '$suitePrefix.dart.browser_test.dart.js'); | 279 '$suitePrefix.dart.browser_test.dart.js'); |
| 280 } |
| 281 |
268 await _pubServeSuite(path, jsUrl); | 282 await _pubServeSuite(path, jsUrl); |
269 suiteUrl = _pubServeUrl.resolveUri(p.toUri('$suitePrefix.html')); | 283 suiteUrl = _pubServeUrl.resolveUri(p.toUri('$suitePrefix.html')); |
270 } else { | 284 } else { |
271 if (browser.isJS) await _compileSuite(path); | 285 if (browser.isJS) await _compileSuite(path); |
272 if (_closed) return null; | 286 if (_closed) return null; |
273 suiteUrl = url.resolveUri(p.toUri( | 287 suiteUrl = url.resolveUri(p.toUri( |
274 p.withoutExtension(p.relative(path, from: _root)) + ".html")); | 288 p.withoutExtension(p.relative(path, from: _root)) + ".html")); |
275 } | 289 } |
276 | 290 |
277 if (_closed) return null; | 291 if (_closed) return null; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 await Future.wait(futures); | 474 await Future.wait(futures); |
461 | 475 |
462 if (_pubServeUrl == null) { | 476 if (_pubServeUrl == null) { |
463 new Directory(_compiledDir).deleteSync(recursive: true); | 477 new Directory(_compiledDir).deleteSync(recursive: true); |
464 } else { | 478 } else { |
465 _http.close(); | 479 _http.close(); |
466 } | 480 } |
467 }); | 481 }); |
468 } | 482 } |
469 } | 483 } |
OLD | NEW |