Index: third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp |
index bc584d1ee13aa9b7327b6ef5e13a7c4d5d3013eb..8932e764e1acf0d1930904352a8db6e250197721 100644 |
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp |
@@ -414,4 +414,33 @@ TEST_F(HTMLPreloadScannerTest, testLinkRelPreload) |
test(testCase); |
} |
+// The preload scanner should follow the same policy that the ScriptLoader does |
+// with regard to the type and language attribute. |
+TEST_F(HTMLPreloadScannerTest, testScriptTypeAndLanguage) |
+{ |
+ TestCase testCases[] = { |
+ // Allow empty src and language attributes. |
+ {"http://example.test", "<script src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ {"http://example.test", "<script type='' language='' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ // Allow standard language and type attributes. |
+ {"http://example.test", "<script type='text/javascript' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ {"http://example.test", "<script type='text/javascript' language='javascript' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ // Allow legacy languages in the "language" attribute with an empty |
+ // type. |
+ {"http://example.test", "<script language='javascript1.1' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ // Allow legacy languages in the "type" attribute. |
+ {"http://example.test", "<script type='javascript' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ {"http://example.test", "<script type='javascript1.7' src='test.js'></script>", "test.js", "http://example.test/", Resource::Script, 0}, |
+ // Do not allow invalid types in the "type" attribute. |
+ {"http://example.test", "<script type='invalid' src='test.js'></script>", nullptr, "http://example.test/", Resource::Script, 0}, |
+ {"http://example.test", "<script type='asdf' src='test.js'></script>", nullptr, "http://example.test/", Resource::Script, 0}, |
+ // Do not allow invalid languages. |
+ {"http://example.test", "<script language='french' src='test.js'></script>", nullptr, "http://example.test/", Resource::Script, 0}, |
+ {"http://example.test", "<script language='python' src='test.js'></script>", nullptr, "http://example.test/", Resource::Script, 0}, |
+ }; |
+ |
+ for (const auto& testCase : testCases) |
+ test(testCase); |
+} |
+ |
} // namespace blink |