Changeset 245825 in webkit
- Timestamp:
- May 28, 2019 2:10:47 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 29 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245821 r245825 1 2019-05-28 Shawn Roberts <sroberts@apple.com> 2 3 Unreviewed, rolling out r245475. 4 5 Newly imported test is flaky. Features need flags. 6 7 Reverted changeset: 8 9 "Implement imagesrcset and imagesizes attributes on link 10 rel=preload" 11 https://bugs.webkit.org/show_bug.cgi?id=192950 12 https://trac.webkit.org/changeset/245475 13 1 14 2019-05-28 Devin Rousso <drousso@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/ChangeLog
r245820 r245825 1 2019-05-28 Shawn Roberts <sroberts@apple.com> 2 3 Unreviewed, rolling out r245475. 4 5 Newly imported test is flaky. Features need flags. 6 7 Reverted changeset: 8 9 "Implement imagesrcset and imagesizes attributes on link 10 rel=preload" 11 https://bugs.webkit.org/show_bug.cgi?id=192950 12 https://trac.webkit.org/changeset/245475 13 1 14 2019-05-28 Antoine Quint <graouts@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub-expected.txt
r245475 r245825 13 13 CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/sound_5.oga because it does not appear in the media-src directive of the Content Security Policy. 14 14 CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/foo.vtt because it does not appear in the media-src directive of the Content Security Policy. 15 CONSOLE MESSAGE: line 1 4: <link rel=preload> must have a valid `as` value16 CONSOLE MESSAGE: line 1 5: <link rel=preload> must have a valid `as` value15 CONSOLE MESSAGE: line 16: <link rel=preload> must have a valid `as` value 16 CONSOLE MESSAGE: line 17: <link rel=preload> must have a valid `as` value 17 17 18 18 PASS Makes sure that preload requests respect CSP -
trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub.html
r245475 r245825 1 1 <!DOCTYPE html> 2 2 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; font-src 'none'; style-src 'none'; img-src 'none'; media-src 'none'; connect-src 'none'"> 3 <title>Makes sure that preload requests respect CSP</title>4 3 <script src="/resources/testharness.js"></script> 5 4 <script src="/resources/testharnessreport.js"></script> 6 5 <script src="/preload/resources/preload_helper.js"></script> 6 <script> 7 var t = async_test('Makes sure that preload requests respect CSP'); 8 </script> 7 9 <link rel=preload href="{{host}}:{{ports[http][1]}}/preload/resources/dummy.js" as=style> 8 10 <link rel=preload href="resources/dummy.css" as=style> … … 16 18 <body> 17 19 <script> 18 setup({explicit_done: true}); 19 20 var iterations = 0; 21 22 function check_finished() { 23 if (numberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js") == 0 && 24 numberOfResourceTimingEntries("resources/dummy.css") == 0 && 25 numberOfResourceTimingEntries("resources/square.png") == 0 && 26 numberOfResourceTimingEntries("/fonts/CanvasTest.ttf") == 0 && 27 numberOfResourceTimingEntries("resources/white.mp4") == 0 && 28 numberOfResourceTimingEntries("resources/sound_5.oga") == 0 && 29 numberOfResourceTimingEntries("resources/foo.vtt") == 0 && 30 numberOfResourceTimingEntries("resources/dummy.xml") == 0) { 31 done(); 32 } 33 iterations++; 34 if (iterations == 10) { 35 // At least one is expected to fail, but this should give details to the exact failure(s). 20 window.onload = t.step_func(function() { 21 t.step_timeout(function() { 22 verifyPreloadAndRTSupport(); 36 23 verifyNumberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js", 0); 37 24 verifyNumberOfResourceTimingEntries("resources/dummy.css", 0); … … 42 29 verifyNumberOfResourceTimingEntries("resources/foo.vtt", 0); 43 30 verifyNumberOfResourceTimingEntries("resources/dummy.xml", 0); 44 done(); 45 } else { 46 step_timeout(check_finished, 500); 47 } 48 } 49 50 window.addEventListener("load", function() { 51 verifyPreloadAndRTSupport(); 52 step_timeout(check_finished, 500); 31 t.done(); 32 }, 5000); 53 33 }); 54 34 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub-expected.txt
r245475 r245825 13 13 CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/sound_5.oga because it appears in neither the media-src directive nor the default-src directive of the Content Security Policy. 14 14 CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/foo.vtt because it appears in neither the media-src directive nor the default-src directive of the Content Security Policy. 15 CONSOLE MESSAGE: line 1 4: <link rel=preload> must have a valid `as` value16 CONSOLE MESSAGE: line 1 5: <link rel=preload> must have a valid `as` value15 CONSOLE MESSAGE: line 16: <link rel=preload> must have a valid `as` value 16 CONSOLE MESSAGE: line 17: <link rel=preload> must have a valid `as` value 17 17 18 18 PASS Makes sure that preload requests respect CSP -
trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub.html
r245475 r245825 1 1 <!DOCTYPE html> 2 2 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; default-src 'none'"> 3 <title>Makes sure that preload requests respect CSP</title>4 3 <script src="/resources/testharness.js"></script> 5 4 <script src="/resources/testharnessreport.js"></script> 6 5 <script src="/preload/resources/preload_helper.js"></script> 6 <script> 7 var t = async_test('Makes sure that preload requests respect CSP'); 8 </script> 7 9 <link rel=preload href="{{host}}:{{ports[http][1]}}/preload/resources/dummy.js" as=style> 8 10 <link rel=preload href="resources/dummy.css" as=style> … … 16 18 <body> 17 19 <script> 18 setup({explicit_done: true}); 19 20 var iterations = 0; 21 22 function check_finished() { 23 if (numberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js") == 0 && 24 numberOfResourceTimingEntries("resources/dummy.css") == 0 && 25 numberOfResourceTimingEntries("resources/square.png") == 0 && 26 numberOfResourceTimingEntries("/fonts/CanvasTest.ttf") == 0 && 27 numberOfResourceTimingEntries("resources/white.mp4") == 0 && 28 numberOfResourceTimingEntries("resources/sound_5.oga") == 0 && 29 numberOfResourceTimingEntries("resources/foo.vtt") == 0 && 30 numberOfResourceTimingEntries("resources/dummy.xml") == 0) { 31 done(); 32 } 33 iterations++; 34 if (iterations == 10) { 35 // At least one is expected to fail, but this should give details to the exact failure(s). 20 window.onload = t.step_func(function() { 21 t.step_timeout(function() { 22 verifyPreloadAndRTSupport(); 36 23 verifyNumberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js", 0); 37 24 verifyNumberOfResourceTimingEntries("resources/dummy.css", 0); … … 42 29 verifyNumberOfResourceTimingEntries("resources/foo.vtt", 0); 43 30 verifyNumberOfResourceTimingEntries("resources/dummy.xml", 0); 44 done(); 45 } else { 46 step_timeout(check_finished, 500); 47 } 48 } 49 50 window.addEventListener("load", function() { 51 verifyPreloadAndRTSupport(); 52 step_timeout(check_finished, 500); 31 t.done(); 32 }, 5000); 53 33 }); 54 34 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/preload/resources/preload_helper.js
r245475 r245825 13 13 function verifyNumberOfResourceTimingEntries(url, number) 14 14 { 15 assert_equals(numberOfResourceTimingEntries(url), number, url); 16 } 17 18 function numberOfResourceTimingEntries(url) 19 { 20 return performance.getEntriesByName(getAbsoluteURL(url)).length; 15 var numEntries = performance.getEntriesByName(getAbsoluteURL(url)).length; 16 assert_equals(numEntries, number, url); 21 17 } 22 18 -
trunk/Source/WebCore/ChangeLog
r245823 r245825 1 2019-05-28 Shawn Roberts <sroberts@apple.com> 2 3 Unreviewed, rolling out r245475. 4 5 Newly imported test is flaky. Features need flags. 6 7 Reverted changeset: 8 9 "Implement imagesrcset and imagesizes attributes on link 10 rel=preload" 11 https://bugs.webkit.org/show_bug.cgi?id=192950 12 https://trac.webkit.org/changeset/245475 13 1 14 2019-05-28 Brent Fulgham <bfulgham@apple.com> 2 15 -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r245475 r245825 145 145 http_equiv 146 146 id 147 imagesizes148 imagesrcset149 147 incremental 150 148 indeterminate -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r245475 r245825 263 263 URL url = getNonEmptyURLAttribute(hrefAttr); 264 264 265 if (!m_linkLoader.loadLink(m_relAttribute, url, attributeWithoutSynchronization(asAttr), attributeWithoutSynchronization(mediaAttr), attributeWithoutSynchronization(typeAttr), attributeWithoutSynchronization(crossoriginAttr), attributeWithoutSynchronization(imagesrcsetAttr), attributeWithoutSynchronization(imagesizesAttr),document()))265 if (!m_linkLoader.loadLink(m_relAttribute, url, attributeWithoutSynchronization(asAttr), attributeWithoutSynchronization(mediaAttr), attributeWithoutSynchronization(typeAttr), attributeWithoutSynchronization(crossoriginAttr), document())) 266 266 return; 267 267 -
trunk/Source/WebCore/html/HTMLLinkElement.idl
r245475 r245825 36 36 [CEReactions=NotNeeded] attribute DOMString as; 37 37 [CEReactions=NotNeeded] attribute DOMString? crossOrigin; 38 [CEReactions=NotNeeded, Reflect] attribute DOMString imageSrcset;39 [CEReactions=NotNeeded, Reflect] attribute DOMString imageSizes;40 38 41 39 // DOM Level 2 Style -
trunk/Source/WebCore/loader/LinkHeader.cpp
r245475 r245825 166 166 if (equalLettersIgnoringASCIICase(name, "as")) 167 167 return LinkHeader::LinkParameterAs; 168 if (equalLettersIgnoringASCIICase(name, "imagesrcset"))169 return LinkHeader::LinkParameterImageSrcSet;170 if (equalLettersIgnoringASCIICase(name, "imagesizes"))171 return LinkHeader::LinkParameterImageSizes;172 168 return LinkHeader::LinkParameterUnknown; 173 169 } … … 269 265 } 270 266 271 void LinkHeader::setValue(LinkParameterName name, String &&value)267 void LinkHeader::setValue(LinkParameterName name, String value) 272 268 { 273 269 switch (name) { 274 270 case LinkParameterRel: 275 271 if (!m_rel) 276 m_rel = WTFMove(value);272 m_rel = value; 277 273 break; 278 274 case LinkParameterAnchor: … … 280 276 break; 281 277 case LinkParameterCrossOrigin: 282 m_crossOrigin = WTFMove(value);278 m_crossOrigin = value; 283 279 break; 284 280 case LinkParameterAs: 285 m_as = WTFMove(value);281 m_as = value; 286 282 break; 287 283 case LinkParameterType: 288 m_mimeType = WTFMove(value);284 m_mimeType = value; 289 285 break; 290 286 case LinkParameterMedia: 291 m_media = WTFMove(value); 292 break; 293 case LinkParameterImageSrcSet: 294 m_imageSrcSet = WTFMove(value); 295 break; 296 case LinkParameterImageSizes: 297 m_imageSizes = WTFMove(value); 287 m_media = value; 298 288 break; 299 289 case LinkParameterTitle: … … 347 337 } 348 338 349 setValue(parameterName, WTFMove(parameterValue));339 setValue(parameterName, parameterValue); 350 340 } 351 341 findNextHeader(position, end); -
trunk/Source/WebCore/loader/LinkHeader.h
r245475 r245825 42 42 const String& media() const { return m_media; } 43 43 const String& crossOrigin() const { return m_crossOrigin; } 44 const String& imageSrcSet() const { return m_imageSrcSet; }45 const String& imageSizes() const { return m_imageSizes; }46 44 bool valid() const { return m_isValid; } 47 bool isViewportDependent() const { return !media().isEmpty() || !imageSrcSet().isEmpty() || !imageSizes().isEmpty(); }48 45 49 46 enum LinkParameterName { … … 59 56 LinkParameterCrossOrigin, 60 57 LinkParameterAs, 61 LinkParameterImageSrcSet,62 LinkParameterImageSizes,63 58 }; 64 59 65 60 private: 66 void setValue(LinkParameterName, String &&value);61 void setValue(LinkParameterName, String value); 67 62 68 63 String m_url; … … 72 67 String m_media; 73 68 String m_crossOrigin; 74 String m_imageSrcSet;75 String m_imageSizes;76 69 bool m_isValid { true }; 77 70 }; -
trunk/Source/WebCore/loader/LinkLoader.cpp
r245475 r245825 45 45 #include "FrameLoaderClient.h" 46 46 #include "FrameView.h" 47 #include "HTMLSrcsetParser.h"48 47 #include "LinkHeader.h" 49 48 #include "LinkPreloadResourceClients.h" … … 51 50 #include "LoaderStrategy.h" 52 51 #include "MIMETypeRegistry.h" 53 #include "MediaList.h"54 52 #include "MediaQueryEvaluator.h" 55 53 #include "PlatformStrategies.h" … … 57 55 #include "RuntimeEnabledFeatures.h" 58 56 #include "Settings.h" 59 #include "SizesAttributeParser.h"60 57 #include "StyleResolver.h" 61 58 … … 101 98 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) 102 99 continue; 103 if ((mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty && !header.isViewportDependent())104 || (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeEmpty && header.isViewportDependent())) {100 if ((mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty && header.media().isEmpty()) 101 || (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeEmpty && !header.media().isEmpty())) { 105 102 continue; 106 103 } … … 112 109 continue; 113 110 preconnectIfNeeded(relAttribute, url, document, header.crossOrigin()); 114 preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), header.imageSrcSet(), header.imageSizes(),nullptr);111 preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), nullptr); 115 112 } 116 113 } … … 231 228 } 232 229 233 std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, const String& imageSrcSet, const String& imageSizes,LinkLoader* loader)230 std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, LinkLoader* loader) 234 231 { 235 232 if (!document.loader() || !relAttribute.isLinkPreload) … … 237 234 238 235 ASSERT(RuntimeEnabledFeatures::sharedFeatures().linkPreloadEnabled()); 236 if (!href.isValid()) { 237 document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `href` value"_s); 238 return nullptr; 239 } 239 240 auto type = LinkLoader::resourceTypeFromAsAttribute(as); 240 241 if (!type) { … … 242 243 return nullptr; 243 244 } 244 URL url;245 if (type == CachedResource::Type::ImageResource && !imageSrcSet.isEmpty()) {246 auto sourceSize = SizesAttributeParser(imageSizes, document).length();247 auto candidate = bestFitSourceForImageAttributes(document.deviceScaleFactor(), href.string(), imageSrcSet, sourceSize);248 url = document.completeURL(URL({ }, candidate.string.toString()));249 } else250 url = document.completeURL(href);251 252 if (!url.isValid()) {253 if (imageSrcSet.isEmpty())254 document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `href` value"_s);255 else256 document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `imagesrcset` value"_s);257 return nullptr;258 }259 245 if (!MediaQueryEvaluator::mediaAttributeMatches(document, media)) 260 246 return nullptr; … … 263 249 264 250 auto options = CachedResourceLoader::defaultCachedResourceOptions(); 265 auto linkRequest = createPotentialAccessControlRequest( url, document, crossOriginMode, WTFMove(options));251 auto linkRequest = createPotentialAccessControlRequest(document.completeURL(href), document, crossOriginMode, WTFMove(options)); 266 252 linkRequest.setPriority(CachedResource::defaultPriorityForResourceType(type.value())); 267 253 linkRequest.setInitiator("link"); … … 314 300 } 315 301 316 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, const String& as, const String& media, const String& mimeType, const String& crossOrigin, const String& imageSrcSet, const String& imageSizes,Document& document)302 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, const String& as, const String& media, const String& mimeType, const String& crossOrigin, Document& document) 317 303 { 318 304 if (relAttribute.isDNSPrefetch) { … … 326 312 327 313 if (m_client.shouldLoadLink()) { 328 auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, imageSrcSet, imageSizes,this);314 auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, this); 329 315 if (m_preloadResourceClient) 330 316 m_preloadResourceClient->clear(); -
trunk/Source/WebCore/loader/LinkLoader.h
r245475 r245825 51 51 virtual ~LinkLoader(); 52 52 53 bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& media, const String& type, const String& crossOrigin, const String& imageSrcSet, const String& imageSizes,Document&);53 bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& media, const String& type, const String& crossOrigin, Document&); 54 54 static Optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as); 55 55 … … 64 64 void notifyFinished(CachedResource&) override; 65 65 static void preconnectIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& crossOrigin); 66 static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, const String&, const String&,LinkLoader*);66 static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, LinkLoader*); 67 67 void prefetchIfNeeded(const LinkRelAttribute&, const URL& href, Document&); 68 68
Note: See TracChangeset
for help on using the changeset viewer.