| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library polymer.test.build.polyfill_injector_test; | |
| 6 | |
| 7 import 'package:polymer/src/build/common.dart'; | |
| 8 import 'package:polymer/src/build/polyfill_injector.dart'; | |
| 9 import 'package:unittest/compact_vm_config.dart'; | |
| 10 import 'package:unittest/unittest.dart'; | |
| 11 | |
| 12 import 'common.dart'; | |
| 13 | |
| 14 void main() { | |
| 15 useCompactVMConfiguration(); | |
| 16 | |
| 17 group('js', () => runTests()); | |
| 18 group('dart', () => runTests(js: false)); | |
| 19 } | |
| 20 | |
| 21 void runTests({bool js: true}) { | |
| 22 var phases = [[new PolyfillInjector(new TransformOptions( | |
| 23 directlyIncludeJS: js))]]; | |
| 24 | |
| 25 var ext = js ? '.js' : ''; | |
| 26 var type = js ? '' : 'type="application/dart" '; | |
| 27 var dartJsTag = js ? '' : DART_JS_TAG; | |
| 28 var async = js ? ' async=""' : ''; | |
| 29 | |
| 30 testPhases('no changes', phases, { | |
| 31 'a|web/test.html': '<!DOCTYPE html><html></html>', | |
| 32 }, { | |
| 33 'a|web/test.html': '<!DOCTYPE html><html></html>', | |
| 34 }); | |
| 35 | |
| 36 testPhases('no changes under lib ', phases, { | |
| 37 'a|lib/test.html': | |
| 38 '<!DOCTYPE html><html><head></head><body>' | |
| 39 '<script type="application/dart" src="a.dart"></script>', | |
| 40 }, { | |
| 41 'a|lib/test.html': | |
| 42 '<!DOCTYPE html><html><head></head><body>' | |
| 43 '<script type="application/dart" src="a.dart"></script>', | |
| 44 }); | |
| 45 | |
| 46 testPhases('with some script', phases, { | |
| 47 'a|web/test.html': | |
| 48 '<!DOCTYPE html><html><head></head><body>' | |
| 49 '<script type="application/dart" src="a.dart"></script>', | |
| 50 }, { | |
| 51 'a|web/test.html': | |
| 52 '<!DOCTYPE html><html><head>' | |
| 53 '$COMPATIBILITY_JS_TAGS' | |
| 54 '</head><body>' | |
| 55 '<script ${type}src="a.dart$ext"$async></script>' | |
| 56 '$dartJsTag' | |
| 57 '</body></html>', | |
| 58 }); | |
| 59 | |
| 60 testPhases('interop/shadow dom already present', phases, { | |
| 61 'a|web/test.html': | |
| 62 '<!DOCTYPE html><html><head>' | |
| 63 '$COMPATIBILITY_JS_TAGS' | |
| 64 '</head><body>' | |
| 65 '<script type="application/dart" src="a.dart"></script>' | |
| 66 '$dartJsTag' | |
| 67 }, { | |
| 68 'a|web/test.html': | |
| 69 '<!DOCTYPE html><html><head>' | |
| 70 '$COMPATIBILITY_JS_TAGS' | |
| 71 '</head><body>' | |
| 72 '<script ${type}src="a.dart$ext"$async></script>' | |
| 73 '$dartJsTag' | |
| 74 '</body></html>', | |
| 75 }); | |
| 76 | |
| 77 testPhases( | |
| 78 'dart_support.js after webcomponents.js, web_components present', phases, | |
| 79 { | |
| 80 'a|web/test.html': | |
| 81 '<!DOCTYPE html><html><head>' | |
| 82 '$WEB_COMPONENTS_JS_TAG' | |
| 83 '</head><body>' | |
| 84 '<script type="application/dart" src="a.dart"></script>' | |
| 85 '$dartJsTag' | |
| 86 }, { | |
| 87 'a|web/test.html': | |
| 88 '<!DOCTYPE html><html><head>' | |
| 89 '$COMPATIBILITY_JS_TAGS' | |
| 90 '</head><body>' | |
| 91 '<script ${type}src="a.dart$ext"$async></script>' | |
| 92 '$dartJsTag' | |
| 93 '</body></html>', | |
| 94 }); | |
| 95 | |
| 96 testPhases( | |
| 97 'dart_support.js after webcomponents.js, dart_support present', phases, | |
| 98 { | |
| 99 'a|web/test.html': | |
| 100 '<!DOCTYPE html><html><head>' | |
| 101 '$DART_SUPPORT_TAG' | |
| 102 '</head><body>' | |
| 103 '<script type="application/dart" src="a.dart"></script>' | |
| 104 '$dartJsTag' | |
| 105 }, { | |
| 106 'a|web/test.html': | |
| 107 '<!DOCTYPE html><html><head>' | |
| 108 '$COMPATIBILITY_JS_TAGS' | |
| 109 '</head><body>' | |
| 110 '<script ${type}src="a.dart$ext"$async></script>' | |
| 111 '$dartJsTag' | |
| 112 '</body></html>', | |
| 113 }); | |
| 114 | |
| 115 testPhases('platform.js -> webcomponents.js', phases, | |
| 116 { | |
| 117 'a|web/test.html': | |
| 118 '<!DOCTYPE html><html><head>' | |
| 119 '$PLATFORM_JS_TAG' | |
| 120 '</head><body>' | |
| 121 '<script type="application/dart" src="a.dart"></script>' | |
| 122 '$dartJsTag' | |
| 123 }, { | |
| 124 'a|web/test.html': | |
| 125 '<!DOCTYPE html><html><head>' | |
| 126 '$COMPATIBILITY_JS_TAGS' | |
| 127 '</head><body>' | |
| 128 '<script ${type}src="a.dart$ext"$async></script>' | |
| 129 '$dartJsTag' | |
| 130 '</body></html>', | |
| 131 }); | |
| 132 | |
| 133 var noWebComponentsPhases = [[new PolyfillInjector(new TransformOptions( | |
| 134 directlyIncludeJS: js, injectWebComponentsJs: false))]]; | |
| 135 | |
| 136 testPhases('with no webcomponents.js', noWebComponentsPhases, { | |
| 137 'a|web/test.html': | |
| 138 '<!DOCTYPE html><html><head></head><body>' | |
| 139 '<script type="application/dart" src="a.dart"></script>', | |
| 140 }, { | |
| 141 'a|web/test.html': | |
| 142 '<!DOCTYPE html><html><head>' | |
| 143 '$DART_SUPPORT_TAG' | |
| 144 '</head><body>' | |
| 145 '<script ${type}src="a.dart$ext"$async></script>' | |
| 146 '$dartJsTag' | |
| 147 '</body></html>', | |
| 148 }); | |
| 149 } | |
| OLD | NEW |