| 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 library polymer.test.build.polyfill_injector_test; | 5 library polymer.test.build.polyfill_injector_test; |
| 6 | 6 |
| 7 import 'package:polymer/src/build/common.dart'; | 7 import 'package:polymer/src/build/common.dart'; |
| 8 import 'package:polymer/src/build/polyfill_injector.dart'; | 8 import 'package:polymer/src/build/polyfill_injector.dart'; |
| 9 import 'package:unittest/compact_vm_config.dart'; | 9 import 'package:unittest/compact_vm_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import 'common.dart'; | 12 import 'common.dart'; |
| 13 | 13 |
| 14 void main() { | 14 void main() { |
| 15 useCompactVMConfiguration(); | 15 useCompactVMConfiguration(); |
| 16 | 16 |
| 17 group('js', () => runTests()); | 17 group('js', () => runTests()); |
| 18 group('csp', () => runTests(csp: true)); | 18 group('csp', () => runTests(csp: true)); |
| 19 group('dart', () => runTests(js: false)); | 19 group('dart', () => runTests(js: false)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void runTests({bool js: true, bool csp: false}) { | 22 void runTests({bool js: true, bool csp: false}) { |
| 23 var phases = [[new PolyfillInjector(new TransformOptions( | 23 var phases = [[new PolyfillInjector(new TransformOptions( |
| 24 directlyIncludeJS: js, | 24 directlyIncludeJS: js, |
| 25 contentSecurityPolicy: csp))]]; | 25 contentSecurityPolicy: csp))]]; |
| 26 | 26 |
| 27 var ext = js ? (csp ? '.precompiled.js' : '.js') : ''; | 27 var ext = js ? (csp ? '.precompiled.js' : '.js') : ''; |
| 28 var type = js ? '' : 'type="application/dart" '; | 28 var type = js ? '' : 'type="application/dart" '; |
| 29 var dartJsTag = js ? '' : DART_JS_TAG; | 29 var dartJsTag = js ? '' : DART_JS_TAG; |
| 30 var async = js ? ' async=""' : ''; |
| 30 | 31 |
| 31 testPhases('no changes', phases, { | 32 testPhases('no changes', phases, { |
| 32 'a|web/test.html': '<!DOCTYPE html><html></html>', | 33 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 33 }, { | 34 }, { |
| 34 'a|web/test.html': '<!DOCTYPE html><html></html>', | 35 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 35 }); | 36 }); |
| 36 | 37 |
| 37 testPhases('no changes under lib ', phases, { | 38 testPhases('no changes under lib ', phases, { |
| 38 'a|lib/test.html': | 39 'a|lib/test.html': |
| 39 '<!DOCTYPE html><html><head></head><body>' | 40 '<!DOCTYPE html><html><head></head><body>' |
| 40 '<script type="application/dart" src="a.dart"></script>', | 41 '<script type="application/dart" src="a.dart"></script>', |
| 41 }, { | 42 }, { |
| 42 'a|lib/test.html': | 43 'a|lib/test.html': |
| 43 '<!DOCTYPE html><html><head></head><body>' | 44 '<!DOCTYPE html><html><head></head><body>' |
| 44 '<script type="application/dart" src="a.dart"></script>', | 45 '<script type="application/dart" src="a.dart"></script>', |
| 45 }); | 46 }); |
| 46 | 47 |
| 47 testPhases('with some script', phases, { | 48 testPhases('with some script', phases, { |
| 48 'a|web/test.html': | 49 'a|web/test.html': |
| 49 '<!DOCTYPE html><html><head></head><body>' | 50 '<!DOCTYPE html><html><head></head><body>' |
| 50 '<script type="application/dart" src="a.dart"></script>', | 51 '<script type="application/dart" src="a.dart"></script>', |
| 51 }, { | 52 }, { |
| 52 'a|web/test.html': | 53 'a|web/test.html': |
| 53 '<!DOCTYPE html><html><head>' | 54 '<!DOCTYPE html><html><head>' |
| 54 '$WEB_COMPONENTS_TAG' | 55 '$WEB_COMPONENTS_TAG' |
| 55 '</head><body>' | 56 '</head><body>' |
| 56 '<script ${type}src="a.dart$ext"></script>' | 57 '<script ${type}src="a.dart$ext"$async></script>' |
| 57 '$dartJsTag' | 58 '$dartJsTag' |
| 58 '</body></html>', | 59 '</body></html>', |
| 59 }); | 60 }); |
| 60 | 61 |
| 61 testPhases('interop/shadow dom already present', phases, { | 62 testPhases('interop/shadow dom already present', phases, { |
| 62 'a|web/test.html': | 63 'a|web/test.html': |
| 63 '<!DOCTYPE html><html><head>' | 64 '<!DOCTYPE html><html><head>' |
| 64 '$WEB_COMPONENTS_TAG' | 65 '$WEB_COMPONENTS_TAG' |
| 65 '</head><body>' | 66 '</head><body>' |
| 66 '<script type="application/dart" src="a.dart"></script>' | 67 '<script type="application/dart" src="a.dart"></script>' |
| 67 '$dartJsTag' | 68 '$dartJsTag' |
| 68 }, { | 69 }, { |
| 69 'a|web/test.html': | 70 'a|web/test.html': |
| 70 '<!DOCTYPE html><html><head>' | 71 '<!DOCTYPE html><html><head>' |
| 71 '$WEB_COMPONENTS_TAG' | 72 '$WEB_COMPONENTS_TAG' |
| 72 '</head><body>' | 73 '</head><body>' |
| 73 '<script ${type}src="a.dart$ext"></script>' | 74 '<script ${type}src="a.dart$ext"$async></script>' |
| 74 '$dartJsTag' | 75 '$dartJsTag' |
| 75 '</body></html>', | 76 '</body></html>', |
| 76 }); | 77 }); |
| 77 } | 78 } |
| OLD | NEW |