Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: pkg/polymer/test/build/import_inliner_test.dart

Issue 394523002: Sanitize library names generated from file paths (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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' show JSON;
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';
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 'a|web/test.html.1.dart': 'library a.web.test2_html_0;\n/*forth*/', 152 'a|web/test.html.1.dart': 'library a.web.test2_html_0;\n/*forth*/',
153 'a|web/test.html.0.dart': 'library a.web.test_html_0;\n/*fifth*/', 153 'a|web/test.html.0.dart': 'library a.web.test_html_0;\n/*fifth*/',
154 'a|web/test2.html': 154 'a|web/test2.html':
155 '<!DOCTYPE html><html><head></head><body><script>/*third*/</script>' 155 '<!DOCTYPE html><html><head></head><body><script>/*third*/</script>'
156 '<polymer-element>2</polymer-element></body></html>', 156 '<polymer-element>2</polymer-element></body></html>',
157 'a|web/test2.html._data': expectedData(['web/test2.html.0.dart']), 157 'a|web/test2.html._data': expectedData(['web/test2.html.0.dart']),
158 'a|web/test2.html.0.dart': 'library a.web.test2_html_0;\n/*forth*/', 158 'a|web/test2.html.0.dart': 'library a.web.test2_html_0;\n/*forth*/',
159 'a|web/second.js': '/*second*/' 159 'a|web/second.js': '/*second*/'
160 }); 160 });
161 161
162 testPhases('Cleans library names generated from file paths.', phases,
163 {
164 'a|web/01_test.html':
165 '<!DOCTYPE html><html><head>'
166 '<script type="application/dart">/*1*/</script>'
167 '</head></html>',
168 'a|web/foo_02_test.html':
169 '<!DOCTYPE html><html><head>'
170 '<script type="application/dart">/*2*/</script>'
171 '</head></html>',
172 'a|web/test_03.html':
173 '<!DOCTYPE html><html><head>'
174 '<script type="application/dart">/*3*/</script>'
175 '</head></html>',
176 'a|web/*test_%foo_04!.html':
177 '<!DOCTYPE html><html><head>'
178 '<script type="application/dart">/*4*/</script>'
179 '</head></html>',
180 'a|web/%05_test.html':
181 '<!DOCTYPE html><html><head>'
182 '<script type="application/dart">/*5*/</script>'
183 '</head></html>',
184 }, {
185 'a|web/01_test.html.0.dart':
186 'library a.web._01_test_html_0;\n/*1*/', // Appends an _ if it s tarts with a number.
Siggi Cherem (dart-lang) 2014/07/14 19:34:11 nit: long lines. We can simply move the comments t
187 'a|web/foo_02_test.html.0.dart':
188 'library a.web.foo_02_test_html_0;\n/*2*/', // Allows numbers in th e middle.
189 'a|web/test_03.html.0.dart':
190 'library a.web.test_03_html_0;\n/*3*/', // Allows numbers at th e end.
191 'a|web/*test_%foo_04!.html.0.dart':
192 'library a.web.test_foo_04_html_0;\n/*4*/', // Strips invalid chara cters.
193 'a|web/%05_test.html.0.dart':
194 'library a.web._05_test_html_0;\n/*5*/', // Strips invalid chara cters and appends an _.
195 });
196
162 testPhases('no transformation outside web/', phases, 197 testPhases('no transformation outside web/', phases,
163 { 198 {
164 'a|lib/test.html': 199 'a|lib/test.html':
165 '<!DOCTYPE html><html><head>' 200 '<!DOCTYPE html><html><head>'
166 '<link rel="import" href="test2.html">' 201 '<link rel="import" href="test2.html">'
167 '</head></html>', 202 '</head></html>',
168 'a|lib/test2.html': 203 'a|lib/test2.html':
169 '<!DOCTYPE html><html><head>' 204 '<!DOCTYPE html><html><head>'
170 '</head><body><polymer-element>2</polymer-element></html>', 205 '</head><body><polymer-element>2</polymer-element></html>',
171 }, { 206 }, {
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 'a|web/test.html': 769 'a|web/test.html':
735 '<!DOCTYPE html><html><head></head><body>' 770 '<!DOCTYPE html><html><head></head><body>'
736 '<style>.first { color: black }</style>' 771 '<style>.first { color: black }</style>'
737 '<style>h1 { font-size: 70px; }</style>' 772 '<style>h1 { font-size: 70px; }</style>'
738 '<style>.second { color: black }</style>' 773 '<style>.second { color: black }</style>'
739 '</body></html>', 774 '</body></html>',
740 'a|web/test.html._data': EMPTY_DATA, 775 'a|web/test.html._data': EMPTY_DATA,
741 'a|web/test2.css': 776 'a|web/test2.css':
742 'h1 { font-size: 70px; }', 777 'h1 { font-size: 70px; }',
743 }); 778 });
744 779
745 testPhases('inlined tags keep original attributes', phases, { 780 testPhases('inlined tags keep original attributes', phases, {
746 'a|web/test.html': 781 'a|web/test.html':
747 '<!DOCTYPE html><html><head>' 782 '<!DOCTYPE html><html><head>'
748 '<link rel="stylesheet" href="foo.css" no-shim>' 783 '<link rel="stylesheet" href="foo.css" no-shim>'
749 '<link rel="stylesheet" href="bar.css" shim-shadow foo>' 784 '<link rel="stylesheet" href="bar.css" shim-shadow foo>'
750 '</head></html>', 785 '</head></html>',
751 'a|web/foo.css': 786 'a|web/foo.css':
752 'h1 { font-size: 70px; }', 787 'h1 { font-size: 70px; }',
753 'a|web/bar.css': 788 'a|web/bar.css':
754 'h2 { font-size: 35px; }', 789 'h2 { font-size: 35px; }',
(...skipping 25 matching lines...) Expand all
780 }, { 815 }, {
781 'a|web/test.html': 816 'a|web/test.html':
782 '<!DOCTYPE html><html><head></head><body>' 817 '<!DOCTYPE html><html><head></head><body>'
783 '<script src="foo/baz.jpg"></script>' // normalized 818 '<script src="foo/baz.jpg"></script>' // normalized
784 '<foo-element src="baz.jpg"></foo-element>' // left alone (custom) 819 '<foo-element src="baz.jpg"></foo-element>' // left alone (custom)
785 '</body></html>', 820 '</body></html>',
786 'a|web/foo/test_1.html': 821 'a|web/foo/test_1.html':
787 '<script src="baz.jpg"></script>', 822 '<script src="baz.jpg"></script>',
788 'a|web/foo/test_2.html': 823 'a|web/foo/test_2.html':
789 '<foo-element src="baz.jpg"></foo-element>', 824 '<foo-element src="baz.jpg"></foo-element>',
790 }); 825 });
791 } 826 }
792 827
793 void entryPointTests() { 828 void entryPointTests() {
794 testPhases('one level deep entry points normalize correctly', phases, { 829 testPhases('one level deep entry points normalize correctly', phases, {
795 'a|web/test/test.html': 830 'a|web/test/test.html':
796 '<!DOCTYPE html><html><head>' 831 '<!DOCTYPE html><html><head>'
797 '<link rel="import" href="../../packages/a/foo/foo.html">' 832 '<link rel="import" href="../../packages/a/foo/foo.html">'
798 '</head></html>', 833 '</head></html>',
799 'a|lib/foo/foo.html': 834 'a|lib/foo/foo.html':
800 '<script rel="import" href="../../../packages/b/bar/bar.js">' 835 '<script rel="import" href="../../../packages/b/bar/bar.js">'
801 '</script>', 836 '</script>',
802 'b|lib/bar/bar.js': 837 'b|lib/bar/bar.js':
803 'console.log("here");', 838 'console.log("here");',
804 }, { 839 }, {
805 'a|web/test/test.html': 840 'a|web/test/test.html':
806 '<!DOCTYPE html><html><head></head><body>' 841 '<!DOCTYPE html><html><head></head><body>'
807 '<script rel="import" href="../packages/b/bar/bar.js"></script>' 842 '<script rel="import" href="../packages/b/bar/bar.js"></script>'
808 '</body></html>', 843 '</body></html>',
809 }); 844 });
810 845
811 testPhases('two level deep entry points normalize correctly', phases, { 846 testPhases('two level deep entry points normalize correctly', phases, {
812 'a|web/test/well/test.html': 847 'a|web/test/well/test.html':
813 '<!DOCTYPE html><html><head>' 848 '<!DOCTYPE html><html><head>'
814 '<link rel="import" href="../../../packages/a/foo/foo.html">' 849 '<link rel="import" href="../../../packages/a/foo/foo.html">'
815 '</head></html>', 850 '</head></html>',
816 'a|lib/foo/foo.html': 851 'a|lib/foo/foo.html':
817 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>', 852 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>',
818 'b|lib/bar/bar.js': 853 'b|lib/bar/bar.js':
819 'console.log("here");', 854 'console.log("here");',
820 }, { 855 }, {
821 'a|web/test/well/test.html': 856 'a|web/test/well/test.html':
822 '<!DOCTYPE html><html><head></head><body>' 857 '<!DOCTYPE html><html><head></head><body>'
823 '<script rel="import" href="../../packages/b/bar/bar.js"></script>' 858 '<script rel="import" href="../../packages/b/bar/bar.js"></script>'
824 '</body></html>', 859 '</body></html>',
825 }); 860 });
826 } 861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698