| 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.import_inliner_test; | 5 library polymer.test.build.import_inliner_test; |
| 6 | 6 |
| 7 import 'dart:convert' show JSON; | 7 import 'dart:convert'; |
| 8 import 'package:polymer/src/build/common.dart'; | 8 import 'package:polymer/src/build/common.dart'; |
| 9 import 'package:polymer/src/build/import_inliner.dart'; | 9 import 'package:polymer/src/build/import_inliner.dart'; |
| 10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import 'common.dart'; | 12 import 'common.dart'; |
| 13 | 13 |
| 14 part 'code_extractor.dart'; | 14 part 'code_extractor.dart'; |
| 15 | 15 |
| 16 final phases = [[new ImportInliner(new TransformOptions())]]; | 16 final phases = [[new ImportInliner(new TransformOptions())]]; |
| 17 | 17 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 '<!DOCTYPE html><html><head>' | 647 '<!DOCTYPE html><html><head>' |
| 648 '</head><body>' | 648 '</head><body>' |
| 649 '<polymer-element>3</polymer-element>' | 649 '<polymer-element>3</polymer-element>' |
| 650 '<polymer-element>2</polymer-element></body></html>', | 650 '<polymer-element>2</polymer-element></body></html>', |
| 651 'a|web/test_3.html': | 651 'a|web/test_3.html': |
| 652 '<!DOCTYPE html><html><head>' | 652 '<!DOCTYPE html><html><head>' |
| 653 '</head><body>' | 653 '</head><body>' |
| 654 '<polymer-element>3</polymer-element></body></html>', | 654 '<polymer-element>3</polymer-element></body></html>', |
| 655 }); | 655 }); |
| 656 | 656 |
| 657 testPhases("missing styles don't throw errors and are not inlined", phases, { | 657 testLogOutput( |
| 658 'a|web/test.html': | 658 (options) => new ImportInliner(options), |
| 659 '<!DOCTYPE html><html><head>' | 659 "missing styles don't throw errors and are not inlined", { |
| 660 '<link rel="stylesheet" href="foo.css">' | 660 'a|web/test.html': |
| 661 '</head></html>', | 661 '<!DOCTYPE html><html><head>' |
| 662 }, { | 662 '<link rel="stylesheet" href="foo.css">' |
| 663 'a|web/test.html': | 663 '</head></html>', |
| 664 '<!DOCTYPE html><html><head></head><body>' | 664 }, { |
| 665 '<link rel="stylesheet" href="foo.css">' | 665 'a|web/test.html': |
| 666 '</body></html>', | 666 '<!DOCTYPE html><html><head></head><body>' |
| 667 }, [ | 667 '<link rel="stylesheet" href="foo.css">' |
| 668 'warning: Failed to inline stylesheet: ' | 668 '</body></html>', |
| 669 'Could not find asset a|web/foo.css. (web/test.html 0 27)', | 669 }, [ |
| 670 ]); | 670 'warning: Failed to inline stylesheet: ' |
| 671 'Could not find asset a|web/foo.css. (web/test.html 0 27)', |
| 672 ]); |
| 671 | 673 |
| 672 testPhases("missing html imports throw errors", phases, { | 674 testLogOutput( |
| 673 'a|web/test.html': | 675 (options) => new ImportInliner(options), |
| 674 '<!DOCTYPE html><html><head>' | 676 "missing html imports throw errors", { |
| 675 '<link rel="import" href="foo.html">' | 677 'a|web/test.html': |
| 676 '</head></html>', | 678 '<!DOCTYPE html><html><head>' |
| 677 }, {}, [ | 679 '<link rel="import" href="foo.html">' |
| 678 'error: Failed to inline html import: ' | 680 '</head></html>', |
| 679 'Could not find asset a|web/foo.html. (web/test.html 0 27)', | 681 }, { |
| 680 ]); | 682 'a|web/test.html._buildLogs.1': |
| 683 '[{' |
| 684 '"level":"Error",' |
| 685 '"message":"Failed to inline html import: ' |
| 686 'Could not find asset a|web/foo.html.",' |
| 687 '"assetId":{"package":"a","path":"web/foo.html"},' |
| 688 '"span":{' |
| 689 '"location":"web/test.html:1:28",' |
| 690 '"text":"${new HtmlEscape().convert( |
| 691 '<link rel="import" href="foo.html">')}"' |
| 692 '}' |
| 693 '}]', |
| 694 }, [ |
| 695 'error: Failed to inline html import: ' |
| 696 'Could not find asset a|web/foo.html. (web/test.html 0 27)', |
| 697 ]); |
| 681 } | 698 } |
| 682 | 699 |
| 683 void stylesheetTests() { | 700 void stylesheetTests() { |
| 684 | 701 |
| 685 testPhases('empty stylesheet', phases, { | 702 testPhases('empty stylesheet', phases, { |
| 686 'a|web/test.html': | 703 'a|web/test.html': |
| 687 '<!DOCTYPE html><html><head>' | 704 '<!DOCTYPE html><html><head>' |
| 688 '<link rel="stylesheet" href="">' // empty href | 705 '<link rel="stylesheet" href="">' // empty href |
| 689 '</head></html>', | 706 '</head></html>', |
| 690 'a|web/test2.html': | 707 'a|web/test2.html': |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 '<img _src="./{{bar}}">' | 1002 '<img _src="./{{bar}}">' |
| 986 '<a _href="./{{bar}}">test</a>', | 1003 '<a _href="./{{bar}}">test</a>', |
| 987 }, { | 1004 }, { |
| 988 'a|web/test.html': | 1005 'a|web/test.html': |
| 989 '<!DOCTYPE html><html><head></head><body>' | 1006 '<!DOCTYPE html><html><head></head><body>' |
| 990 '<img _src="foo/{{bar}}">' | 1007 '<img _src="foo/{{bar}}">' |
| 991 '<a _href="foo/{{bar}}">test</a>' | 1008 '<a _href="foo/{{bar}}">test</a>' |
| 992 '</body></html>', | 1009 '</body></html>', |
| 993 }); | 1010 }); |
| 994 | 1011 |
| 995 testPhases('warnings are given about _* attributes', phases, { | |
| 996 'a|web/test.html': | |
| 997 '<!DOCTYPE html><html><head></head><body>' | |
| 998 '<img src="foo/{{bar}}">' | |
| 999 '<a _href="foo/bar">test</a>' | |
| 1000 '</body></html>', | |
| 1001 }, {}, [ | |
| 1002 'warning: When using bindings with the "src" attribute you may ' | |
| 1003 'experience errors in certain browsers. Please use the "_src" ' | |
| 1004 'attribute instead. For more information, see http://goo.gl/5av8cU ' | |
| 1005 '(web/test.html 0 40)', | |
| 1006 'warning: The "_href" attribute is only supported when using bindings. ' | |
| 1007 'Please change to the "href" attribute. (web/test.html 0 63)', | |
| 1008 | 1012 |
| 1009 ]); | 1013 testLogOutput( |
| 1014 (options) => new ImportInliner(options), |
| 1015 'warnings are given about _* attributes', { |
| 1016 'a|web/test.html': |
| 1017 '<!DOCTYPE html><html><head></head><body>' |
| 1018 '<img src="foo/{{bar}}">' |
| 1019 '<a _href="foo/bar">test</a>' |
| 1020 '</body></html>', |
| 1021 }, {}, [ |
| 1022 'warning: When using bindings with the "src" attribute you may ' |
| 1023 'experience errors in certain browsers. Please use the "_src" ' |
| 1024 'attribute instead. For more information, see ' |
| 1025 'http://goo.gl/5av8cU (web/test.html 0 40)', |
| 1026 'warning: The "_href" attribute is only supported when using ' |
| 1027 'bindings. Please change to the "href" attribute. ' |
| 1028 '(web/test.html 0 63)', |
| 1029 |
| 1030 ]); |
| 1010 | 1031 |
| 1011 testPhases('arbitrary bindings can exist in paths', phases, { | 1032 testPhases('arbitrary bindings can exist in paths', phases, { |
| 1012 'a|web/test.html': | 1033 'a|web/test.html': |
| 1013 '<!DOCTYPE html><html><head></head><body>' | 1034 '<!DOCTYPE html><html><head></head><body>' |
| 1014 '<img src="./{{(bar[2] + baz[\'foo\']) * 14 / foobar() - 0.5}}.jpg">' | 1035 '<img src="./{{(bar[2] + baz[\'foo\']) * 14 / foobar() - 0.5}}.jpg">' |
| 1015 '<img src="./[[bar[2]]].jpg">' | 1036 '<img src="./[[bar[2]]].jpg">' |
| 1016 '</body></html>', | 1037 '</body></html>', |
| 1017 }, { | 1038 }, { |
| 1018 'a|web/test.html': | 1039 'a|web/test.html': |
| 1019 '<!DOCTYPE html><html><head></head><body>' | 1040 '<!DOCTYPE html><html><head></head><body>' |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 'a|lib/foo/foo.html': | 1096 'a|lib/foo/foo.html': |
| 1076 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>', | 1097 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>', |
| 1077 'b|lib/bar/bar.js': | 1098 'b|lib/bar/bar.js': |
| 1078 'console.log("here");', | 1099 'console.log("here");', |
| 1079 }, { | 1100 }, { |
| 1080 'a|web/test/well/test.html': | 1101 'a|web/test/well/test.html': |
| 1081 '<!DOCTYPE html><html><head></head><body>' | 1102 '<!DOCTYPE html><html><head></head><body>' |
| 1082 '<script rel="import" href="../../packages/b/bar/bar.js"></script>' | 1103 '<script rel="import" href="../../packages/b/bar/bar.js"></script>' |
| 1083 '</body></html>', | 1104 '</body></html>', |
| 1084 }); | 1105 }); |
| 1085 } | 1106 } |
| OLD | NEW |