OLD | NEW |
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 <memory> | 7 #include <memory> |
8 #include "core/MediaTypeNames.h" | 8 #include "core/MediaTypeNames.h" |
9 #include "core/css/MediaValuesCached.h" | 9 #include "core/css/MediaValuesCached.h" |
10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 "bla.gif", "http://example.test/", Resource::kImage, 0, | 790 "bla.gif", "http://example.test/", Resource::kImage, 0, |
791 kReferrerPolicyAlways, nullptr}, | 791 kReferrerPolicyAlways, nullptr}, |
792 }; | 792 }; |
793 | 793 |
794 for (const auto& test_case : test_cases) | 794 for (const auto& test_case : test_cases) |
795 Test(test_case); | 795 Test(test_case); |
796 } | 796 } |
797 | 797 |
798 TEST_F(HTMLPreloadScannerTest, testLinkRelPreload) { | 798 TEST_F(HTMLPreloadScannerTest, testLinkRelPreload) { |
799 TestCase test_cases[] = { | 799 TestCase test_cases[] = { |
800 {"http://example.test", "<link rel=preload href=bla>", "bla", | 800 {"http://example.test", "<link rel=preload as=fetch href=bla>", "bla", |
801 "http://example.test/", Resource::kRaw, 0}, | 801 "http://example.test/", Resource::kRaw, 0}, |
802 {"http://example.test", "<link rel=preload href=bla as=script>", "bla", | 802 {"http://example.test", "<link rel=preload href=bla as=script>", "bla", |
803 "http://example.test/", Resource::kScript, 0}, | 803 "http://example.test/", Resource::kScript, 0}, |
804 {"http://example.test", | 804 {"http://example.test", |
805 "<link rel=preload href=bla as=script type='script/foo'>", "bla", | 805 "<link rel=preload href=bla as=script type='script/foo'>", "bla", |
806 "http://example.test/", Resource::kScript, 0}, | 806 "http://example.test/", Resource::kScript, 0}, |
807 {"http://example.test", "<link rel=preload href=bla as=style>", "bla", | 807 {"http://example.test", "<link rel=preload href=bla as=style>", "bla", |
808 "http://example.test/", Resource::kCSSStyleSheet, 0}, | 808 "http://example.test/", Resource::kCSSStyleSheet, 0}, |
809 {"http://example.test", | 809 {"http://example.test", |
810 "<link rel=preload href=bla as=style type='text/css'>", "bla", | 810 "<link rel=preload href=bla as=style type='text/css'>", "bla", |
(...skipping 20 matching lines...) Expand all Loading... |
831 {"http://example.test", "<link rel=preload href=bla as=video>", "bla", | 831 {"http://example.test", "<link rel=preload href=bla as=video>", "bla", |
832 "http://example.test/", Resource::kMedia, 0}, | 832 "http://example.test/", Resource::kMedia, 0}, |
833 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", | 833 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", |
834 "http://example.test/", Resource::kTextTrack, 0}, | 834 "http://example.test/", Resource::kTextTrack, 0}, |
835 {"http://example.test", | 835 {"http://example.test", |
836 "<link rel=preload href=bla as=image media=\"(max-width: 800px)\">", | 836 "<link rel=preload href=bla as=image media=\"(max-width: 800px)\">", |
837 "bla", "http://example.test/", Resource::kImage, 0}, | 837 "bla", "http://example.test/", Resource::kImage, 0}, |
838 {"http://example.test", | 838 {"http://example.test", |
839 "<link rel=preload href=bla as=image media=\"(max-width: 400px)\">", | 839 "<link rel=preload href=bla as=image media=\"(max-width: 400px)\">", |
840 nullptr, "http://example.test/", Resource::kImage, 0}, | 840 nullptr, "http://example.test/", Resource::kImage, 0}, |
| 841 {"http://example.test", "<link rel=preload href=bla>", nullptr, |
| 842 "http://example.test/", Resource::kRaw, 0}, |
841 }; | 843 }; |
842 | 844 |
843 for (const auto& test_case : test_cases) | 845 for (const auto& test_case : test_cases) |
844 Test(test_case); | 846 Test(test_case); |
845 } | 847 } |
846 | 848 |
847 TEST_F(HTMLPreloadScannerTest, testNoDataUrls) { | 849 TEST_F(HTMLPreloadScannerTest, testNoDataUrls) { |
848 TestCase test_cases[] = { | 850 TestCase test_cases[] = { |
849 {"http://example.test", | 851 {"http://example.test", |
850 "<link rel=preload href='data:text/html,<p>data</data>'>", nullptr, | 852 "<link rel=preload href='data:text/html,<p>data</data>'>", nullptr, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 "sheet.css", | 935 "sheet.css", |
934 "http://example.test/", | 936 "http://example.test/", |
935 Resource::kCSSStyleSheet, | 937 Resource::kCSSStyleSheet, |
936 0, | 938 0, |
937 kReferrerPolicyAlways, | 939 kReferrerPolicyAlways, |
938 "http://whatever.test/"}; | 940 "http://whatever.test/"}; |
939 Test(test_case); | 941 Test(test_case); |
940 } | 942 } |
941 | 943 |
942 } // namespace blink | 944 } // namespace blink |
OLD | NEW |