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 = |
| 23 [[new PolyfillInjector(new TransformOptions(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 }, {'a|web/test.html': '<!DOCTYPE html><html></html>',}); |
| 33 |
| 34 testPhases('no changes under lib ', phases, { |
| 35 'a|lib/test.html': '<!DOCTYPE html><html><head></head><body>' |
| 36 '<script type="application/dart" src="a.dart"></script>', |
| 37 }, { |
| 38 'a|lib/test.html': '<!DOCTYPE html><html><head></head><body>' |
| 39 '<script type="application/dart" src="a.dart"></script>', |
| 40 }); |
| 41 |
| 42 testPhases('with some script', phases, { |
| 43 'a|web/test.html': '<!DOCTYPE html><html><head></head><body>' |
| 44 '<script type="application/dart" src="a.dart"></script>', |
| 45 }, { |
| 46 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 47 '$COMPATIBILITY_JS_TAGS' |
| 48 '</head><body>' |
| 49 '<script ${type}src="a.dart$ext"$async></script>' |
| 50 '$dartJsTag' |
| 51 '</body></html>', |
| 52 }); |
| 53 |
| 54 testPhases('interop/shadow dom already present', phases, { |
| 55 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 56 '$COMPATIBILITY_JS_TAGS' |
| 57 '</head><body>' |
| 58 '<script type="application/dart" src="a.dart"></script>' |
| 59 '$dartJsTag' |
| 60 }, { |
| 61 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 62 '$COMPATIBILITY_JS_TAGS' |
| 63 '</head><body>' |
| 64 '<script ${type}src="a.dart$ext"$async></script>' |
| 65 '$dartJsTag' |
| 66 '</body></html>', |
| 67 }); |
| 68 |
| 69 testPhases('dart_support.js after webcomponents.js, web_components present', |
| 70 phases, { |
| 71 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 72 '$WEB_COMPONENTS_JS_TAG' |
| 73 '</head><body>' |
| 74 '<script type="application/dart" src="a.dart"></script>' |
| 75 '$dartJsTag' |
| 76 }, { |
| 77 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 78 '$COMPATIBILITY_JS_TAGS' |
| 79 '</head><body>' |
| 80 '<script ${type}src="a.dart$ext"$async></script>' |
| 81 '$dartJsTag' |
| 82 '</body></html>', |
| 83 }); |
| 84 |
| 85 testPhases('dart_support.js after webcomponents.js, dart_support present', |
| 86 phases, { |
| 87 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 88 '$DART_SUPPORT_TAG' |
| 89 '</head><body>' |
| 90 '<script type="application/dart" src="a.dart"></script>' |
| 91 '$dartJsTag' |
| 92 }, { |
| 93 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 94 '$COMPATIBILITY_JS_TAGS' |
| 95 '</head><body>' |
| 96 '<script ${type}src="a.dart$ext"$async></script>' |
| 97 '$dartJsTag' |
| 98 '</body></html>', |
| 99 }); |
| 100 |
| 101 testPhases('polyfills after base tags', phases, { |
| 102 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 103 '<base href="/">' |
| 104 '</head><body>' |
| 105 '<script type="application/dart" src="a.dart"></script>' |
| 106 '$dartJsTag' |
| 107 }, { |
| 108 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 109 '<base href="/">' |
| 110 '$COMPATIBILITY_JS_TAGS' |
| 111 '</head><body>' |
| 112 '<script ${type}src="a.dart$ext"$async></script>' |
| 113 '$dartJsTag' |
| 114 '</body></html>', |
| 115 }); |
| 116 |
| 117 testPhases('platform.js -> webcomponents.js', phases, { |
| 118 'a|web/test.html': '<!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': '<!DOCTYPE html><html><head>' |
| 125 '$COMPATIBILITY_JS_TAGS' |
| 126 '</head><body>' |
| 127 '<script ${type}src="a.dart$ext"$async></script>' |
| 128 '$dartJsTag' |
| 129 '</body></html>', |
| 130 }); |
| 131 |
| 132 testPhases('in subfolder', phases, { |
| 133 'a|web/sub/test.html': '<!DOCTYPE html><html><head></head><body>' |
| 134 '<script type="application/dart" src="a.dart"></script>', |
| 135 }, { |
| 136 'a|web/sub/test.html': '<!DOCTYPE html><html><head>' |
| 137 '${COMPATIBILITY_JS_TAGS.replaceAll('packages', '../packages')}' |
| 138 '</head><body>' |
| 139 '<script ${type}src="a.dart$ext"$async></script>' |
| 140 '$dartJsTag' |
| 141 '</body></html>', |
| 142 }); |
| 143 |
| 144 var noWebComponentsPhases = [ |
| 145 [ |
| 146 new PolyfillInjector(new TransformOptions( |
| 147 directlyIncludeJS: js, injectWebComponentsJs: false)) |
| 148 ] |
| 149 ]; |
| 150 |
| 151 testPhases('with no webcomponents.js', noWebComponentsPhases, { |
| 152 'a|web/test.html': '<!DOCTYPE html><html><head></head><body>' |
| 153 '<script type="application/dart" src="a.dart"></script>', |
| 154 }, { |
| 155 'a|web/test.html': '<!DOCTYPE html><html><head>' |
| 156 '$DART_SUPPORT_TAG' |
| 157 '</head><body>' |
| 158 '<script ${type}src="a.dart$ext"$async></script>' |
| 159 '$dartJsTag' |
| 160 '</body></html>', |
| 161 }); |
| 162 } |
OLD | NEW |