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
3 // found in the LICENSE file.
6 #include "core/html/parser/HTMLPreloadScanner.h"
8 #include "core/MediaTypeNames.h"
9 #include "core/css/MediaValuesCached.h"
10 #include "core/fetch/ClientHintsPreferences.h"
11 #include "core/frame/Settings.h"
12 #include "core/html/CrossOriginAttribute.h"
13 #include "core/html/parser/HTMLParserOptions.h"
14 #include "core/html/parser/HTMLResourcePreloader.h"
15 #include "core/testing/DummyPageHolder.h"
16 #include <gtest/gtest.h>
22 const char* inputHTML
;
23 const char* preloadedURL
; // Or nullptr if no preload is expected.
24 const char* outputBaseURL
;
27 ClientHintsPreferences preferences
;
30 struct PreconnectTestCase
{
32 const char* inputHTML
;
33 const char* preconnectedHost
;
34 CrossOriginAttributeValue crossOrigin
;
37 struct ReferrerPolicyTestCase
{
39 const char* inputHTML
;
40 const char* preloadedURL
; // Or nullptr if no preload is expected.
41 const char* outputBaseURL
;
44 ReferrerPolicy referrerPolicy
;
47 class MockHTMLResourcePreloader
: public ResourcePreloader
{
49 void preloadRequestVerification(Resource::Type type
, const char* url
, const char* baseURL
, int width
, const ClientHintsPreferences
& preferences
)
52 EXPECT_FALSE(m_preloadRequest
);
55 EXPECT_FALSE(m_preloadRequest
->isPreconnect());
56 EXPECT_EQ(type
, m_preloadRequest
->resourceType());
57 EXPECT_STREQ(url
, m_preloadRequest
->resourceURL().ascii().data());
58 EXPECT_STREQ(baseURL
, m_preloadRequest
->baseURL().string().ascii().data());
59 EXPECT_EQ(width
, m_preloadRequest
->resourceWidth());
60 EXPECT_EQ(preferences
.shouldSendDPR(), m_preloadRequest
->preferences().shouldSendDPR());
61 EXPECT_EQ(preferences
.shouldSendResourceWidth(), m_preloadRequest
->preferences().shouldSendResourceWidth());
62 EXPECT_EQ(preferences
.shouldSendViewportWidth(), m_preloadRequest
->preferences().shouldSendViewportWidth());
65 void preloadRequestVerification(Resource::Type type
, const char* url
, const char* baseURL
, int width
, ReferrerPolicy referrerPolicy
)
67 preloadRequestVerification(type
, url
, baseURL
, width
, ClientHintsPreferences());
68 EXPECT_EQ(referrerPolicy
, m_preloadRequest
->referrerPolicy());
71 void preconnectRequestVerification(const String
& host
, CrossOriginAttributeValue crossOrigin
)
74 EXPECT_TRUE(m_preloadRequest
->isPreconnect());
75 EXPECT_STREQ(m_preloadRequest
->resourceURL().ascii().data(), host
.ascii().data());
76 EXPECT_EQ(m_preloadRequest
->isCORS(), crossOrigin
!= CrossOriginAttributeNotSet
);
77 EXPECT_EQ(m_preloadRequest
->isAllowCredentials(), crossOrigin
== CrossOriginAttributeUseCredentials
);
82 void preload(PassOwnPtr
<PreloadRequest
> preloadRequest
, const NetworkHintsInterface
&) override
84 m_preloadRequest
= preloadRequest
;
88 OwnPtr
<PreloadRequest
> m_preloadRequest
;
91 class HTMLPreloadScannerTest
: public testing::Test
{
103 HTMLPreloadScannerTest()
104 : m_dummyPageHolder(DummyPageHolder::create())
108 PassRefPtrWillBeRawPtr
<MediaValues
> createMediaValues()
110 MediaValuesCached::MediaValuesCachedData data
;
111 data
.viewportWidth
= 500;
112 data
.viewportHeight
= 600;
113 data
.deviceWidth
= 700;
114 data
.deviceHeight
= 800;
115 data
.devicePixelRatio
= 2.0;
116 data
.colorBitsPerComponent
= 24;
117 data
.monochromeBitsPerComponent
= 0;
118 data
.primaryPointerType
= PointerTypeFine
;
119 data
.defaultFontSize
= 16;
120 data
.threeDEnabled
= true;
121 data
.mediaType
= MediaTypeNames::screen
;
122 data
.strictMode
= true;
123 data
.displayMode
= WebDisplayModeBrowser
;
124 return MediaValuesCached::create(data
);
127 void runSetUp(ViewportState viewportState
, PreloadState preloadState
= PreloadEnabled
)
129 HTMLParserOptions
options(&m_dummyPageHolder
->document());
130 KURL
documentURL(ParsedURLString
, "http://whatever.test/");
131 m_dummyPageHolder
->document().settings()->setViewportEnabled(viewportState
== ViewportEnabled
);
132 m_dummyPageHolder
->document().settings()->setViewportMetaEnabled(viewportState
== ViewportEnabled
);
133 m_dummyPageHolder
->document().settings()->setDoHtmlPreloadScanning(preloadState
== PreloadEnabled
);
134 m_scanner
= HTMLPreloadScanner::create(options
, documentURL
, CachedDocumentParameters::create(&m_dummyPageHolder
->document(), createMediaValues()));
137 void SetUp() override
139 runSetUp(ViewportEnabled
);
142 void test(TestCase testCase
)
144 MockHTMLResourcePreloader preloader
;
145 KURL
baseURL(ParsedURLString
, testCase
.baseURL
);
146 m_scanner
->appendToEnd(String(testCase
.inputHTML
));
147 m_scanner
->scan(&preloader
, baseURL
);
149 preloader
.preloadRequestVerification(testCase
.type
, testCase
.preloadedURL
, testCase
.outputBaseURL
, testCase
.resourceWidth
, testCase
.preferences
);
152 void test(PreconnectTestCase testCase
)
154 MockHTMLResourcePreloader preloader
;
155 KURL
baseURL(ParsedURLString
, testCase
.baseURL
);
156 m_scanner
->appendToEnd(String(testCase
.inputHTML
));
157 m_scanner
->scan(&preloader
, baseURL
);
158 preloader
.preconnectRequestVerification(testCase
.preconnectedHost
, testCase
.crossOrigin
);
161 void test(ReferrerPolicyTestCase testCase
)
163 MockHTMLResourcePreloader preloader
;
164 KURL
baseURL(ParsedURLString
, testCase
.baseURL
);
165 m_scanner
->appendToEnd(String(testCase
.inputHTML
));
166 m_scanner
->scan(&preloader
, baseURL
);
168 preloader
.preloadRequestVerification(testCase
.type
, testCase
.preloadedURL
, testCase
.outputBaseURL
, testCase
.resourceWidth
, testCase
.referrerPolicy
);
172 OwnPtr
<DummyPageHolder
> m_dummyPageHolder
;
173 OwnPtr
<HTMLPreloadScanner
> m_scanner
;
176 TEST_F(HTMLPreloadScannerTest
, testImages
)
178 TestCase testCases
[] = {
179 {"http://example.test", "<img src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 0},
180 {"http://example.test", "<img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
181 {"http://example.test", "<img sizes='50vw' src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 250},
182 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 1x'>", "bla2.gif", "http://example.test/", Resource::Image
, 250},
183 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 0.5x'>", "bla.gif", "http://example.test/", Resource::Image
, 250},
184 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w'>", "bla2.gif", "http://example.test/", Resource::Image
, 250},
185 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w'>", "bla3.gif", "http://example.test/", Resource::Image
, 250},
186 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
187 {"http://example.test", "<img src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
188 {"http://example.test", "<img src='bla.gif' sizes='50vw' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
189 {"http://example.test", "<img sizes='50vw' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
190 {"http://example.test", "<img srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' src='bla.gif' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
191 {"http://example.test", "<img srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' sizes='50vw' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
192 {"http://example.test", "<img src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 0},
195 for (const auto& testCase
: testCases
)
199 TEST_F(HTMLPreloadScannerTest
, testImagesWithViewport
)
201 TestCase testCases
[] = {
202 {"http://example.test", "<meta name=viewport content='width=160'><img srcset='bla.gif 320w, blabla.gif 640w'>", "bla.gif", "http://example.test/", Resource::Image
, 0},
203 {"http://example.test", "<img src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 0},
204 {"http://example.test", "<img sizes='50vw' src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 80},
205 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 1x'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
206 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 0.5x'>", "bla.gif", "http://example.test/", Resource::Image
, 80},
207 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
208 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
209 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
210 {"http://example.test", "<img src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' sizes='50vw'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
211 {"http://example.test", "<img src='bla.gif' sizes='50vw' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
212 {"http://example.test", "<img sizes='50vw' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' src='bla.gif'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
213 {"http://example.test", "<img srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' src='bla.gif' sizes='50vw'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
214 {"http://example.test", "<img srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' sizes='50vw' src='bla.gif'>", "bla2.gif", "http://example.test/", Resource::Image
, 80},
217 for (const auto& testCase
: testCases
)
221 TEST_F(HTMLPreloadScannerTest
, testImagesWithViewportDeviceWidth
)
223 TestCase testCases
[] = {
224 {"http://example.test", "<meta name=viewport content='width=device-width'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
225 {"http://example.test", "<img src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 0},
226 {"http://example.test", "<img sizes='50vw' src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 350},
227 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 1x'>", "bla2.gif", "http://example.test/", Resource::Image
, 350},
228 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 0.5x'>", "bla.gif", "http://example.test/", Resource::Image
, 350},
229 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w'>", "bla2.gif", "http://example.test/", Resource::Image
, 350},
230 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w'>", "bla3.gif", "http://example.test/", Resource::Image
, 350},
231 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
232 {"http://example.test", "<img src='bla.gif' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
233 {"http://example.test", "<img src='bla.gif' sizes='50vw' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
234 {"http://example.test", "<img sizes='50vw' srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
235 {"http://example.test", "<img srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' src='bla.gif' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
236 {"http://example.test", "<img srcset='bla2.gif 160w, bla3.gif 250w, bla4.gif 500w' sizes='50vw' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 350},
239 for (const auto& testCase
: testCases
)
243 TEST_F(HTMLPreloadScannerTest
, testImagesWithViewportDisabled
)
245 runSetUp(ViewportDisabled
);
246 TestCase testCases
[] = {
247 {"http://example.test", "<meta name=viewport content='width=160'><img src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 0},
248 {"http://example.test", "<img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
249 {"http://example.test", "<img sizes='50vw' src='bla.gif'>", "bla.gif", "http://example.test/", Resource::Image
, 250},
250 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 1x'>", "bla2.gif", "http://example.test/", Resource::Image
, 250},
251 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 0.5x'>", "bla.gif", "http://example.test/", Resource::Image
, 250},
252 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w'>", "bla2.gif", "http://example.test/", Resource::Image
, 250},
253 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w'>", "bla3.gif", "http://example.test/", Resource::Image
, 250},
254 {"http://example.test", "<img sizes='50vw' src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
255 {"http://example.test", "<img src='bla.gif' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
256 {"http://example.test", "<img src='bla.gif' sizes='50vw' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
257 {"http://example.test", "<img sizes='50vw' srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
258 {"http://example.test", "<img srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' src='bla.gif' sizes='50vw'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
259 {"http://example.test", "<img srcset='bla2.gif 100w, bla3.gif 250w, bla4.gif 500w' sizes='50vw' src='bla.gif'>", "bla4.gif", "http://example.test/", Resource::Image
, 250},
262 for (const auto& testCase
: testCases
)
266 TEST_F(HTMLPreloadScannerTest
, testViewportNoContent
)
268 TestCase testCases
[] = {
269 {"http://example.test", "<meta name=viewport><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
270 {"http://example.test", "<meta name=viewport content=sdkbsdkjnejjha><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
273 for (const auto& testCase
: testCases
)
277 TEST_F(HTMLPreloadScannerTest
, testMetaAcceptCH
)
279 ClientHintsPreferences dpr
;
280 ClientHintsPreferences resourceWidth
;
281 ClientHintsPreferences all
;
282 ClientHintsPreferences viewportWidth
;
283 dpr
.setShouldSendDPR(true);
284 all
.setShouldSendDPR(true);
285 resourceWidth
.setShouldSendResourceWidth(true);
286 all
.setShouldSendResourceWidth(true);
287 viewportWidth
.setShouldSendViewportWidth(true);
288 all
.setShouldSendViewportWidth(true);
289 TestCase testCases
[] = {
290 {"http://example.test", "<meta http-equiv='accept-ch' content='bla'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
291 {"http://example.test", "<meta http-equiv='accept-ch' content='dprw'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
292 {"http://example.test", "<meta http-equiv='accept-ch'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0},
293 {"http://example.test", "<meta http-equiv='accept-ch' content='dpr \t'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0, dpr
},
294 {"http://example.test", "<meta http-equiv='accept-ch' content='bla,dpr \t'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0, dpr
},
295 {"http://example.test", "<meta http-equiv='accept-ch' content=' width '><img sizes='100vw' srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 500, resourceWidth
},
296 {"http://example.test", "<meta http-equiv='accept-ch' content=' width , wutever'><img sizes='300px' srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 300, resourceWidth
},
297 {"http://example.test", "<meta http-equiv='accept-ch' content=' viewport-width '><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0, viewportWidth
},
298 {"http://example.test", "<meta http-equiv='accept-ch' content=' viewport-width , wutever'><img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 0, viewportWidth
},
299 {"http://example.test", "<meta http-equiv='accept-ch' content=' viewport-width ,width, wutever, dpr \t'><img sizes='90vw' srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image
, 450, all
},
302 for (const auto& testCase
: testCases
) {
303 runSetUp(ViewportDisabled
);
308 TEST_F(HTMLPreloadScannerTest
, testPreconnect
)
310 PreconnectTestCase testCases
[] = {
311 {"http://example.test", "<link rel=preconnect href=http://example2.test>", "http://example2.test", CrossOriginAttributeNotSet
},
312 {"http://example.test", "<link rel=preconnect href=http://example2.test crossorigin=anonymous>", "http://example2.test", CrossOriginAttributeAnonymous
},
313 {"http://example.test", "<link rel=preconnect href=http://example2.test crossorigin='use-credentials'>", "http://example2.test", CrossOriginAttributeUseCredentials
},
314 {"http://example.test", "<link rel=preconnected href=http://example2.test crossorigin='use-credentials'>", nullptr, CrossOriginAttributeNotSet
},
315 {"http://example.test", "<link rel=preconnect href=ws://example2.test crossorigin='use-credentials'>", nullptr, CrossOriginAttributeNotSet
},
318 for (const auto& testCase
: testCases
)
322 TEST_F(HTMLPreloadScannerTest
, testDisables
)
324 runSetUp(ViewportEnabled
, PreloadDisabled
);
326 TestCase testCases
[] = {
327 {"http://example.test", "<img src='bla.gif'>"},
330 for (const auto& testCase
: testCases
)
334 TEST_F(HTMLPreloadScannerTest
, testPicture
)
336 TestCase testCases
[] = {
337 {"http://example.test", "<picture><source srcset='srcset_bla.gif'><img src='bla.gif'></picture>", "srcset_bla.gif", "http://example.test/", Resource::Image
, 0},
338 {"http://example.test", "<picture><source sizes='50vw' srcset='srcset_bla.gif'><img src='bla.gif'></picture>", "srcset_bla.gif", "http://example.test/", Resource::Image
, 250},
339 {"http://example.test", "<picture><source sizes='50vw' srcset='srcset_bla.gif'><img sizes='50w' src='bla.gif'></picture>", "srcset_bla.gif", "http://example.test/", Resource::Image
, 250},
340 {"http://example.test", "<picture><source srcset='srcset_bla.gif' sizes='50vw'><img sizes='50w' src='bla.gif'></picture>", "srcset_bla.gif", "http://example.test/", Resource::Image
, 250},
341 {"http://example.test", "<picture><source srcset='srcset_bla.gif'><img sizes='50w' src='bla.gif'></picture>", "srcset_bla.gif", "http://example.test/", Resource::Image
, 0},
344 for (const auto& testCase
: testCases
)
348 TEST_F(HTMLPreloadScannerTest
, testReferrerPolicy
)
350 ReferrerPolicyTestCase testCases
[] = {
351 { "http://example.test", "<img src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyDefault
},
352 { "http://example.test", "<img referrerpolicy='origin' src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyOrigin
},
353 { "http://example.test", "<meta name='referrer' content='not-a-valid-policy'><img src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyDefault
},
354 { "http://example.test", "<img referrerpolicy='origin' referrerpolicy='origin-when-crossorigin' src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyOrigin
},
355 { "http://example.test", "<img referrerpolicy='not-a-valid-policy' src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyDefault
},
356 { "http://example.test", "<meta name='referrer' content='no-referrer'><img referrerpolicy='origin' src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyOrigin
},
357 // The scanner's state is not reset between test cases, so all subsequent test cases have a document referrer policy of no-referrer.
358 { "http://example.test", "<img referrerpolicy='not-a-valid-policy' src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyNever
},
359 { "http://example.test", "<img src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image
, 0, ReferrerPolicyNever
}
362 for (const auto& testCase
: testCases
)