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