| 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 | 30 |
| 30 testPhases('no changes', phases, { | 31 testPhases('no changes', phases, { |
| 31 'a|web/test.html': '<!DOCTYPE html><html></html>', | 32 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 32 }, { | 33 }, { |
| 33 'a|web/test.html': '<!DOCTYPE html><html></html>', | 34 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 34 }); | 35 }); |
| 35 | 36 |
| 36 testPhases('no changes under lib ', phases, { | 37 testPhases('no changes under lib ', phases, { |
| 37 'a|lib/test.html': | 38 'a|lib/test.html': |
| 38 '<!DOCTYPE html><html><head></head><body>' | 39 '<!DOCTYPE html><html><head></head><body>' |
| 39 '<script type="application/dart" src="a.dart"></script>', | 40 '<script type="application/dart" src="a.dart"></script>', |
| 40 }, { | 41 }, { |
| 41 'a|lib/test.html': | 42 'a|lib/test.html': |
| 42 '<!DOCTYPE html><html><head></head><body>' | 43 '<!DOCTYPE html><html><head></head><body>' |
| 43 '<script type="application/dart" src="a.dart"></script>', | 44 '<script type="application/dart" src="a.dart"></script>', |
| 44 }); | 45 }); |
| 45 | 46 |
| 46 testPhases('with some script', phases, { | 47 testPhases('with some script', phases, { |
| 47 'a|web/test.html': | 48 'a|web/test.html': |
| 48 '<!DOCTYPE html><html><head></head><body>' | 49 '<!DOCTYPE html><html><head></head><body>' |
| 49 '<script type="application/dart" src="a.dart"></script>', | 50 '<script type="application/dart" src="a.dart"></script>', |
| 50 }, { | 51 }, { |
| 51 'a|web/test.html': | 52 'a|web/test.html': |
| 52 '<!DOCTYPE html><html><head></head><body>' | 53 '<!DOCTYPE html><html><head>' |
| 53 '$SHADOW_DOM_TAG$CUSTOM_ELEMENT_TAG$INTEROP_TAG' | 54 '$SHADOW_DOM_TAG$CUSTOM_ELEMENT_TAG$INTEROP_TAG' |
| 55 '</head><body>' |
| 54 '<script ${type}src="a.dart$ext"></script>' | 56 '<script ${type}src="a.dart$ext"></script>' |
| 57 '$dartJsTag' |
| 55 '</body></html>', | 58 '</body></html>', |
| 56 }); | 59 }); |
| 57 | 60 |
| 58 testPhases('interop/shadow dom already present', phases, { | 61 testPhases('interop/shadow dom already present', phases, { |
| 59 'a|web/test.html': | 62 'a|web/test.html': |
| 60 '<!DOCTYPE html><html><head></head><body>' | 63 '<!DOCTYPE html><html><head>' |
| 61 '<script type="application/dart" src="a.dart"></script>' | |
| 62 '$SHADOW_DOM_TAG' | 64 '$SHADOW_DOM_TAG' |
| 63 '$CUSTOM_ELEMENT_TAG' | 65 '$CUSTOM_ELEMENT_TAG' |
| 64 '$INTEROP_TAG' | 66 '$INTEROP_TAG' |
| 67 '</head><body>' |
| 68 '<script type="application/dart" src="a.dart"></script>' |
| 69 '$dartJsTag' |
| 65 }, { | 70 }, { |
| 66 'a|web/test.html': | 71 'a|web/test.html': |
| 67 '<!DOCTYPE html><html><head></head><body>' | 72 '<!DOCTYPE html><html><head>' |
| 68 '<script ${type}src="a.dart$ext"></script>' | |
| 69 '$SHADOW_DOM_TAG' | 73 '$SHADOW_DOM_TAG' |
| 70 '$CUSTOM_ELEMENT_TAG' | 74 '$CUSTOM_ELEMENT_TAG' |
| 71 '$INTEROP_TAG' | 75 '$INTEROP_TAG' |
| 76 '</head><body>' |
| 77 '<script ${type}src="a.dart$ext"></script>' |
| 78 '$dartJsTag' |
| 72 '</body></html>', | 79 '</body></html>', |
| 73 }); | 80 }); |
| 74 } | 81 } |
| OLD | NEW |