Index: pkg/polymer/test/build/code_extractor.dart |
diff --git a/pkg/polymer/test/build/code_extractor.dart b/pkg/polymer/test/build/code_extractor.dart |
index a375ff0f07f835a7552620d58f2e4ea4c738258e..beeafcbbd4c365f458870d6186b989c14e75a62d 100644 |
--- a/pkg/polymer/test/build/code_extractor.dart |
+++ b/pkg/polymer/test/build/code_extractor.dart |
@@ -24,7 +24,20 @@ void codeExtractorTests() { |
'</body></html>', |
'a|web/test.html.0.dart': |
- 'library a.web.test_html;\nmain() { }', |
+ 'library a.web.test_html_0;\nmain() { }', |
+ }); |
+ |
+ testPhases('component script, no library in script', phases, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head>' |
+ '<script type="application/dart;component=1">main() { }</script>', |
+ }, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head></head><body>' |
+ '</body></html>', |
+ |
+ 'a|web/test.html.0.dart': |
+ 'library a.web.test_html_0;\nmain() { }', |
}); |
testPhases('single script, with library', phases, { |
@@ -44,14 +57,18 @@ void codeExtractorTests() { |
testPhases('under lib/ directory not transformed', phases, { |
'a|lib/test.html': |
'<!DOCTYPE html><html><head>' |
- '<script type="application/dart">library f;\nmain() { }</script>', |
+ '<script type="application/dart">library f;\nmain() { }</script>' |
+ '<script type="application/dart;component=1">' |
+ 'library g;\nmain() { }</script>', |
}, { |
'a|lib/test.html': |
'<!DOCTYPE html><html><head>' |
'<script type="application/dart">library f;\nmain() { }</script>' |
+ '<script type="application/dart;component=1">' |
+ 'library g;\nmain() { }</script>', |
}); |
- testPhases('multiple scripts - only emit first', phases, { |
+ testPhases('multiple scripts allowed', phases, { |
'a|web/test.html': |
'<!DOCTYPE html><html><head>' |
'<script type="application/dart">library a1;\nmain1() { }</script>' |
@@ -60,10 +77,33 @@ void codeExtractorTests() { |
'a|web/test.html': |
'<!DOCTYPE html><html><head></head><body>' |
'<script type="application/dart" src="test.html.0.dart"></script>' |
+ '<script type="application/dart" src="test.html.1.dart"></script>' |
'</body></html>', |
'a|web/test.html.0.dart': |
'library a1;\nmain1() { }', |
+ 'a|web/test.html.1.dart': |
+ 'library a2;\nmain2() { }', |
+ }); |
+ |
+ testPhases('component scripts removed', phases, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head>' |
+ '<script type="application/dart;component=1">' |
+ 'library a1;\nmain1() { }</script>' |
+ '<script type="application/dart;component=1">' |
+ 'library a2;\nmain2() { }</script>', |
+ }, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head></head><body>' |
+ '</body></html>', |
+ 'a|web/test.html.scriptUrls': JSON.encode([ |
+ ["a", "web/test.html.0.dart"], |
+ ["a", "web/test.html.1.dart"]]), |
+ 'a|web/test.html.0.dart': |
+ 'library a1;\nmain1() { }', |
+ 'a|web/test.html.1.dart': |
+ 'library a2;\nmain2() { }', |
}); |
testPhases('multiple deeper scripts', phases, { |
@@ -80,11 +120,18 @@ void codeExtractorTests() { |
'<!DOCTYPE html><html><head>' |
'</head><body>' |
'<script type="application/dart" src="test.html.0.dart"></script>' |
- '<div></div><div><div>' |
+ '<div>' |
+ '<script type="application/dart" src="test.html.1.dart"></script>' |
+ '</div><div><div>' |
+ '<script type="application/dart" src="test.html.2.dart"></script>' |
'</div></div></body></html>', |
'a|web/test.html.0.dart': |
- 'library a.web.test_html;\nmain1() { }', |
+ 'library a.web.test_html_0;\nmain1() { }', |
+ 'a|web/test.html.1.dart': |
+ 'library a.web.test_html_1;\nmain2() { }', |
+ 'a|web/test.html.2.dart': |
+ 'library a.web.test_html_2;\nmain3() { }', |
}); |
testPhases('multiple imported scripts', phases, { |
@@ -94,13 +141,13 @@ void codeExtractorTests() { |
'<link rel="import" href="packages/a/foo/test.html">' |
'<link rel="import" href="packages/b/test.html">', |
'a|web/test2.html': |
- '<script type="application/dart">main1() { }', |
+ '<script type="application/dart;component=1">main1() { }', |
'a|web/bar/test.html': |
- '<script type="application/dart">main2() { }', |
+ '<script type="application/dart;component=1">main2() { }', |
'a|lib/foo/test.html': |
- '<script type="application/dart">main3() { }', |
+ '<script type="application/dart;component=1">main3() { }', |
'b|lib/test.html': |
- '<script type="application/dart">main4() { }' |
+ '<script type="application/dart;component=1">main4() { }' |
}, { |
'a|web/test.html': |
'<html><head></head><body></body></html>', |
@@ -110,10 +157,10 @@ void codeExtractorTests() { |
["a", "web/test.html.2.dart"], |
["a", "web/test.html.3.dart"], |
]), |
- 'a|web/test.html.0.dart': 'library a.web.test2_html;\nmain1() { }', |
- 'a|web/test.html.1.dart': 'library a.web.bar.test_html;\nmain2() { }', |
- 'a|web/test.html.2.dart': 'library a.foo.test_html;\nmain3() { }', |
- 'a|web/test.html.3.dart': 'library b.test_html;\nmain4() { }' |
+ 'a|web/test.html.0.dart': 'library a.web.test2_html_0;\nmain1() { }', |
+ 'a|web/test.html.1.dart': 'library a.web.bar.test_html_1;\nmain2() { }', |
+ 'a|web/test.html.2.dart': 'library a.foo.test_html_2;\nmain3() { }', |
+ 'a|web/test.html.3.dart': 'library b.test_html_3;\nmain4() { }' |
}); |
group('fixes import/export/part URIs', dartUriTests); |
@@ -137,10 +184,12 @@ dartUriTests() { |
'</body></html>', |
}, { |
'a|web/test.html': |
- '<!DOCTYPE html><html><head></head><body></body></html>', |
- 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', |
+ '<!DOCTYPE html><html><head></head><body>' |
+ '<script type="application/dart" src="test.html.0.dart"></script>' |
+ '</body></html>', |
+ 'a|web/test.html.scriptUrls': '[]', |
'a|web/test.html.0.dart': |
- "library a.web.test2.foo_html;\n" |
+ "library a.web.test2.foo_html_0;\n" |
"import 'package:qux/qux.dart';" |
"import 'test2/foo.dart';" |
"export 'test2/bar.dart';" |
@@ -151,7 +200,42 @@ dartUriTests() { |
'</body></html>', |
'a|web/test2/foo.html.scriptUrls': '[]', |
'a|web/test2/foo.html.0.dart': |
- "library a.web.test2.foo_html;\n" |
+ "library a.web.test2.foo_html_0;\n" |
+ "import 'package:qux/qux.dart';" |
+ "import 'foo.dart';" |
+ "export 'bar.dart';" |
+ "part 'baz.dart';", |
+ }); |
+ |
+ testPhases('from web folder, component', phases, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head>' |
+ '<link rel="import" href="test2/foo.html">' |
+ '</head><body></body></html>', |
+ 'a|web/test2/foo.html': |
+ '<!DOCTYPE html><html><head></head><body>' |
+ '<script type="application/dart;component=1">' |
+ "import 'package:qux/qux.dart';" |
+ "import 'foo.dart';" |
+ "export 'bar.dart';" |
+ "part 'baz.dart';" |
+ '</script>' |
+ '</body></html>', |
+ }, { |
+ 'a|web/test.html': |
+ '<!DOCTYPE html><html><head></head><body></body></html>', |
+ 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', |
+ 'a|web/test.html.0.dart': |
+ "library a.web.test2.foo_html_0;\n" |
+ "import 'package:qux/qux.dart';" |
+ "import 'test2/foo.dart';" |
+ "export 'test2/bar.dart';" |
+ "part 'test2/baz.dart';", |
+ 'a|web/test2/foo.html': |
+ '<!DOCTYPE html><html><head></head><body></body></html>', |
+ 'a|web/test2/foo.html.scriptUrls': '[["a","web/test2/foo.html.0.dart"]]', |
+ 'a|web/test2/foo.html.0.dart': |
+ "library a.web.test2.foo_html_0;\n" |
"import 'package:qux/qux.dart';" |
"import 'foo.dart';" |
"export 'bar.dart';" |
@@ -165,7 +249,7 @@ dartUriTests() { |
'</head><body></body></html>', |
'a|lib/test2/foo.html': |
'<!DOCTYPE html><html><head></head><body>' |
- '<script type="application/dart">' |
+ '<script type="application/dart;component=1">' |
"import 'package:qux/qux.dart';" |
"import 'foo.dart';" |
"export 'bar.dart';" |
@@ -177,14 +261,14 @@ dartUriTests() { |
'<!DOCTYPE html><html><head></head><body></body></html>', |
'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', |
'a|web/test.html.0.dart': |
- "library a.test2.foo_html;\n" |
+ "library a.test2.foo_html_0;\n" |
"import 'package:qux/qux.dart';" |
"import 'package:a/test2/foo.dart';" |
"export 'package:a/test2/bar.dart';" |
"part 'package:a/test2/baz.dart';", |
'a|lib/test2/foo.html': |
'<!DOCTYPE html><html><head></head><body>' |
- '<script type="application/dart">' |
+ '<script type="application/dart;component=1">' |
"import 'package:qux/qux.dart';" |
"import 'foo.dart';" |
"export 'bar.dart';" |
@@ -200,7 +284,7 @@ dartUriTests() { |
'</head><body></body></html>', |
'b|lib/test2/foo.html': |
'<!DOCTYPE html><html><head></head><body>' |
- '<script type="application/dart">' |
+ '<script type="application/dart;component=1">' |
"import 'package:qux/qux.dart';" |
"import 'foo.dart';" |
"export 'bar.dart';" |
@@ -212,14 +296,14 @@ dartUriTests() { |
'<!DOCTYPE html><html><head></head><body></body></html>', |
'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', |
'a|web/test.html.0.dart': |
- "library b.test2.foo_html;\n" |
+ "library b.test2.foo_html_0;\n" |
"import 'package:qux/qux.dart';" |
"import 'package:b/test2/foo.dart';" |
"export 'package:b/test2/bar.dart';" |
"part 'package:b/test2/baz.dart';", |
'b|lib/test2/foo.html': |
'<!DOCTYPE html><html><head></head><body>' |
- '<script type="application/dart">' |
+ '<script type="application/dart;component=1">' |
"import 'package:qux/qux.dart';" |
"import 'foo.dart';" |
"export 'bar.dart';" |