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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp

Issue 2130773002: Revert of Don't preload scripts with invalid type/language attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/parser/HTMLPreloadScanner.h" 5 #include "core/html/parser/HTMLPreloadScanner.h"
6 6
7 #include "core/MediaTypeNames.h" 7 #include "core/MediaTypeNames.h"
8 #include "core/css/MediaValuesCached.h" 8 #include "core/css/MediaValuesCached.h"
9 #include "core/fetch/ClientHintsPreferences.h" 9 #include "core/fetch/ClientHintsPreferences.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 {"http://example.test", "<link rel=preload href=bla as=media>", "bla", " http://example.test/", Resource::Media, 0}, 407 {"http://example.test", "<link rel=preload href=bla as=media>", "bla", " http://example.test/", Resource::Media, 0},
408 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", " http://example.test/", Resource::TextTrack, 0}, 408 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", " http://example.test/", Resource::TextTrack, 0},
409 {"http://example.test", "<link rel=preload href=bla as=image media=\"(ma x-width: 800px)\">", "bla", "http://example.test/", Resource::Image, 0}, 409 {"http://example.test", "<link rel=preload href=bla as=image media=\"(ma x-width: 800px)\">", "bla", "http://example.test/", Resource::Image, 0},
410 {"http://example.test", "<link rel=preload href=bla as=image media=\"(ma x-width: 400px)\">", nullptr, "http://example.test/", Resource::Image, 0}, 410 {"http://example.test", "<link rel=preload href=bla as=image media=\"(ma x-width: 400px)\">", nullptr, "http://example.test/", Resource::Image, 0},
411 }; 411 };
412 412
413 for (const auto& testCase : testCases) 413 for (const auto& testCase : testCases)
414 test(testCase); 414 test(testCase);
415 } 415 }
416 416
417 // The preload scanner should follow the same policy that the ScriptLoader does
418 // with regard to the type and language attribute.
419 TEST_F(HTMLPreloadScannerTest, testScriptTypeAndLanguage)
420 {
421 TestCase testCases[] = {
422 // Allow empty src and language attributes.
423 {"http://example.test", "<script src='test.js'></script>", "test.js", "h ttp://example.test/", Resource::Script, 0},
424 {"http://example.test", "<script type='' language='' src='test.js'></scr ipt>", "test.js", "http://example.test/", Resource::Script, 0},
425 // Allow standard language and type attributes.
426 {"http://example.test", "<script type='text/javascript' src='test.js'></ script>", "test.js", "http://example.test/", Resource::Script, 0},
427 {"http://example.test", "<script type='text/javascript' language='javasc ript' src='test.js'></script>", "test.js", "http://example.test/", Resource::Scr ipt, 0},
428 // Allow legacy languages in the "language" attribute with an empty
429 // type.
430 {"http://example.test", "<script language='javascript1.1' src='test.js'> </script>", "test.js", "http://example.test/", Resource::Script, 0},
431 // Allow legacy languages in the "type" attribute.
432 {"http://example.test", "<script type='javascript' src='test.js'></scrip t>", "test.js", "http://example.test/", Resource::Script, 0},
433 {"http://example.test", "<script type='javascript1.7' src='test.js'></sc ript>", "test.js", "http://example.test/", Resource::Script, 0},
434 // Do not allow invalid types in the "type" attribute.
435 {"http://example.test", "<script type='invalid' src='test.js'></script>" , nullptr, "http://example.test/", Resource::Script, 0},
436 {"http://example.test", "<script type='asdf' src='test.js'></script>", n ullptr, "http://example.test/", Resource::Script, 0},
437 // Do not allow invalid languages.
438 {"http://example.test", "<script language='french' src='test.js'></scrip t>", nullptr, "http://example.test/", Resource::Script, 0},
439 {"http://example.test", "<script language='python' src='test.js'></scrip t>", nullptr, "http://example.test/", Resource::Script, 0},
440 };
441
442 for (const auto& testCase : testCases)
443 test(testCase);
444 }
445
446 } // namespace blink 417 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698