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 "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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 void SetUp() override | 136 void SetUp() override |
137 { | 137 { |
138 runSetUp(ViewportEnabled); | 138 runSetUp(ViewportEnabled); |
139 } | 139 } |
140 | 140 |
141 void test(TestCase testCase) | 141 void test(TestCase testCase) |
142 { | 142 { |
143 MockHTMLResourcePreloader preloader; | 143 MockHTMLResourcePreloader preloader; |
144 KURL baseURL(ParsedURLString, testCase.baseURL); | 144 KURL baseURL(ParsedURLString, testCase.baseURL); |
145 m_scanner->appendToEnd(String(testCase.inputHTML)); | 145 m_scanner->appendToEnd(String(testCase.inputHTML)); |
146 m_scanner->scan(&preloader, baseURL); | 146 m_scanner->scan(&preloader, baseURL, nullptr); |
147 | 147 |
148 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR
L, testCase.outputBaseURL, testCase.resourceWidth, testCase.preferences); | 148 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR
L, testCase.outputBaseURL, testCase.resourceWidth, testCase.preferences); |
149 } | 149 } |
150 | 150 |
151 void test(PreconnectTestCase testCase) | 151 void test(PreconnectTestCase testCase) |
152 { | 152 { |
153 MockHTMLResourcePreloader preloader; | 153 MockHTMLResourcePreloader preloader; |
154 KURL baseURL(ParsedURLString, testCase.baseURL); | 154 KURL baseURL(ParsedURLString, testCase.baseURL); |
155 m_scanner->appendToEnd(String(testCase.inputHTML)); | 155 m_scanner->appendToEnd(String(testCase.inputHTML)); |
156 m_scanner->scan(&preloader, baseURL); | 156 m_scanner->scan(&preloader, baseURL, nullptr); |
157 preloader.preconnectRequestVerification(testCase.preconnectedHost, testC
ase.crossOrigin); | 157 preloader.preconnectRequestVerification(testCase.preconnectedHost, testC
ase.crossOrigin); |
158 } | 158 } |
159 | 159 |
160 void test(ReferrerPolicyTestCase testCase) | 160 void test(ReferrerPolicyTestCase testCase) |
161 { | 161 { |
162 MockHTMLResourcePreloader preloader; | 162 MockHTMLResourcePreloader preloader; |
163 KURL baseURL(ParsedURLString, testCase.baseURL); | 163 KURL baseURL(ParsedURLString, testCase.baseURL); |
164 m_scanner->appendToEnd(String(testCase.inputHTML)); | 164 m_scanner->appendToEnd(String(testCase.inputHTML)); |
165 m_scanner->scan(&preloader, baseURL); | 165 m_scanner->scan(&preloader, baseURL, nullptr); |
166 | 166 |
167 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR
L, testCase.outputBaseURL, testCase.resourceWidth, testCase.referrerPolicy); | 167 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR
L, testCase.outputBaseURL, testCase.resourceWidth, testCase.referrerPolicy); |
168 } | 168 } |
169 | 169 |
170 private: | 170 private: |
171 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 171 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
172 OwnPtr<HTMLPreloadScanner> m_scanner; | 172 OwnPtr<HTMLPreloadScanner> m_scanner; |
173 }; | 173 }; |
174 | 174 |
175 TEST_F(HTMLPreloadScannerTest, testImages) | 175 TEST_F(HTMLPreloadScannerTest, testImages) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 {"http://example.test", "<link rel=preload href=bla as=font>", "bla", "h
ttp://example.test/", Resource::Font, 0}, | 372 {"http://example.test", "<link rel=preload href=bla as=font>", "bla", "h
ttp://example.test/", Resource::Font, 0}, |
373 {"http://example.test", "<link rel=preload href=bla as=media>", "bla", "
http://example.test/", Resource::Media, 0}, | 373 {"http://example.test", "<link rel=preload href=bla as=media>", "bla", "
http://example.test/", Resource::Media, 0}, |
374 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", "
http://example.test/", Resource::TextTrack, 0}, | 374 {"http://example.test", "<link rel=preload href=bla as=track>", "bla", "
http://example.test/", Resource::TextTrack, 0}, |
375 }; | 375 }; |
376 | 376 |
377 for (const auto& testCase : testCases) | 377 for (const auto& testCase : testCases) |
378 test(testCase); | 378 test(testCase); |
379 } | 379 } |
380 | 380 |
381 } // namespace blink | 381 } // namespace blink |
OLD | NEW |