Changeset 247860 in webkit
- Timestamp:
- Jul 26, 2019 12:29:55 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247842 r247860 1 2019-07-26 Rob Buis <rbuis@igalia.com> 2 3 Make storing cross-origin top-level prefetches in HTTP cache optional 4 https://bugs.webkit.org/show_bug.cgi?id=199499 5 6 Reviewed by Youenn Fablet. 7 8 Remove unneeded Cache-Control headers and verify that Cache-Control 9 effects whether the navigation gets stored in the disk cache or not. 10 11 * http/tests/cache/resources/prefetched-main-resource-iframe.php: 12 * http/tests/cache/resources/prefetched-main-resource.php: 13 * http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt: Added. 14 * http/wpt/prefetch/link-prefetch-skip-disk-cache.html: Added. 15 * http/wpt/prefetch/resources/main-resource-skip-disk-cache.py: Added. 16 (main): 17 * http/wpt/prefetch/resources/navigate-skip-disk-cache.html: Added. 18 * platform/mac-wk1/TestExpectations: 19 * platform/win/TestExpectations: 20 1 21 2019-07-25 Commit Queue <commit-queue@webkit.org> 2 22 -
trunk/LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php
r247825 r247860 1 1 <?php 2 2 if ($_SERVER["HTTP_PURPOSE"] == "prefetch") { 3 header('Cache-Control: max-age=3600');4 header("Access-Control-Allow-Origin: http://127.0.0.1:8000");5 6 3 echo "<script>"; 7 4 echo "parent.window.postMessage('FAIL', '*');"; … … 11 8 } 12 9 13 header("Access-Control-Allow-Origin: http://127.0.0.1:8000");14 15 10 echo "<script>"; 16 11 echo "parent.window.postMessage('PASS', '*');"; -
trunk/LayoutTests/http/tests/cache/resources/prefetched-main-resource.php
r247825 r247860 7 7 <script> 8 8 9 if (window.testRunner) 10 testRunner.notifyDone(); 9 if (window.testRunner) { 10 fetch('http://localhost:8000/cache/resources/prefetched-main-resource.php').then(function(response) { 11 if (internals.fetchResponseSource(response) != "Disk cache") { 12 document.getElementById('log').innerText = 'FAIL: resource is not in the disk cache.'; 13 } 14 testRunner.notifyDone(); 15 }); 16 } 11 17 12 18 </script> 13 <?php 14 if ($_SERVER["HTTP_PURPOSE"] == "prefetch") { 15 print('PASS'); 16 } else { 17 print('FAIL'); 18 } 19 ?> 19 <div id="log"><?php if ($_SERVER["HTTP_PURPOSE"] == "prefetch") echo 'PASS'; else echo 'FAIL'; ?></div> 20 20 </body> 21 21 </html> -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r247825 r247860 737 737 738 738 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ] 739 webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ] 739 740 740 741 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ] -
trunk/LayoutTests/platform/win/TestExpectations
r247825 r247860 4425 4425 4426 4426 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ] 4427 webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ] 4427 4428 4428 4429 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r247846 r247860 1 2019-07-26 Rob Buis <rbuis@igalia.com> 2 3 Make storing cross-origin top-level prefetches in HTTP cache optional 4 https://bugs.webkit.org/show_bug.cgi?id=199499 5 6 Reviewed by Youenn Fablet. 7 8 Add Internals API for adding an event listener to prefetch load. 9 10 Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html 11 12 * bindings/js/JSEventListener.h: 13 * dom/EventTarget.h: 14 (WebCore::EventTarget::addEventListener): 15 * dom/Node.h: 16 * html/HTMLLinkElement.h: 17 * testing/Internals.cpp: 18 (WebCore::Internals::addPrefetchLoadEventListener): 19 * testing/Internals.h: 20 * testing/Internals.idl: 21 1 22 2019-07-25 Tim Horton <timothy_horton@apple.com> 2 23 -
trunk/Source/WebCore/bindings/js/JSEventListener.h
r247825 r247860 39 39 class JSEventListener : public EventListener { 40 40 public: 41 static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);42 static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&);41 WEBCORE_EXPORT static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&); 42 WEBCORE_EXPORT static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&); 43 43 44 44 virtual ~JSEventListener(); -
trunk/Source/WebCore/dom/EventTarget.h
r247825 r247860 89 89 WEBCORE_EXPORT ExceptionOr<bool> dispatchEventForBindings(Event&); 90 90 91 virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { });91 WEBCORE_EXPORT virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { }); 92 92 virtual bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&); 93 93 -
trunk/Source/WebCore/dom/Node.h
r247825 r247860 473 473 ScriptExecutionContext* scriptExecutionContext() const final; // Implemented in Document.h 474 474 475 bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;475 WEBCORE_EXPORT bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override; 476 476 bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&) override; 477 477 -
trunk/Source/WebCore/html/HTMLLinkElement.h
r247825 r247860 49 49 50 50 URL href() const; 51 const AtomString& rel() const;51 WEBCORE_EXPORT const AtomString& rel() const; 52 52 53 53 String target() const final; -
trunk/Source/WebCore/testing/Internals.cpp
r247835 r247860 69 69 #include "Element.h" 70 70 #include "EventHandler.h" 71 #include "EventListener.h" 72 #include "EventNames.h" 71 73 #include "ExtendableEvent.h" 72 74 #include "ExtensionStyleSheets.h" … … 5145 5147 } 5146 5148 5149 void Internals::addPrefetchLoadEventListener(HTMLLinkElement& link, RefPtr<EventListener>&& listener) 5150 { 5151 if (RuntimeEnabledFeatures::sharedFeatures().linkPrefetchEnabled() && equalLettersIgnoringASCIICase(link.rel(), "prefetch")) 5152 link.addEventListener(eventNames().loadEvent, listener.releaseNonNull(), false); 5153 } 5154 5147 5155 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r247825 r247860 60 60 class Document; 61 61 class Element; 62 class EventListener; 62 63 class ExtendableEvent; 63 64 class FetchResponse; … … 867 868 TextIndicatorInfo textIndicatorForRange(const Range&, TextIndicatorOptions); 868 869 870 void addPrefetchLoadEventListener(HTMLLinkElement&, RefPtr<EventListener>&&); 871 869 872 private: 870 873 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r247825 r247860 782 782 783 783 TextIndicatorInfo textIndicatorForRange(Range range, TextIndicatorOptions options); 784 }; 784 785 void addPrefetchLoadEventListener(HTMLLinkElement link, EventListener? callback); 786 }; -
trunk/Source/WebKit/ChangeLog
r247856 r247860 1 2019-07-26 Rob Buis <rbuis@igalia.com> 2 3 Make storing cross-origin top-level prefetches in HTTP cache optional 4 https://bugs.webkit.org/show_bug.cgi?id=199499 5 6 Reviewed by Youenn Fablet. 7 8 Currently when we navigate we check if there is a cross-origin top-level 9 prefetch we can use for the navigation. The current solution uses the 10 HTTP cache as a way to store the prefetch and to immediately use it for 11 the navigation load. However this solution fails in case the prefetch is 12 not cacheable. 13 14 Instead of this, simulate a HTTP Cache entry to process the load and 15 afterwards try to store the navigation load into the HTTP cache, where 16 normal store decisions will be applied. 17 18 Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html 19 20 * NetworkProcess/NetworkResourceLoader.cpp: 21 (WebKit::NetworkResourceLoader::retrieveCacheEntry): 22 (WebKit::NetworkResourceLoader::retrieveCacheEntryInternal): 23 * NetworkProcess/NetworkResourceLoader.h: 24 1 25 2019-07-25 Zan Dobersek <zdobersek@igalia.com> 2 26 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r247825 r247860 219 219 if (auto* session = m_connection->networkProcess().networkSession(sessionID())) { 220 220 if (auto entry = session->prefetchCache().take(request.url())) { 221 // FIXME: Deal with credentials (https://bugs.webkit.org/show_bug.cgi?id=200000) 221 222 if (!entry->redirectRequest.isNull()) { 223 auto cacheEntry = m_cache->makeRedirectEntry(request, entry->response, entry->redirectRequest); 224 loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request }); 222 225 auto maxAgeCap = validateCacheEntryForMaxAgeCapValidation(request, entry->redirectRequest, entry->response); 223 226 m_cache->storeRedirect(request, entry->response, entry->redirectRequest, maxAgeCap); 224 } else 225 m_cache->store(request, entry->response, entry->releaseBuffer(), nullptr); 227 return; 228 } 229 auto buffer = entry->releaseBuffer(); 230 auto cacheEntry = m_cache->makeEntry(request, entry->response, buffer.copyRef()); 231 loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request }); 232 m_cache->store(request, entry->response, WTFMove(buffer), nullptr); 233 return; 226 234 } 227 235 } … … 240 248 return; 241 249 } 250 loader->retrieveCacheEntryInternal(WTFMove(entry), WTFMove(request)); 251 }); 252 } 253 254 void NetworkResourceLoader::retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&& entry, WebCore::ResourceRequest&& request) 255 { 242 256 #if ENABLE(RESOURCE_LOAD_STATISTICS) 243 244 245 246 247 loader->startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes);248 249 257 if (entry->hasReachedPrevalentResourceAgeCap()) { 258 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource has reached prevalent resource age cap (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 259 m_cacheEntryForMaxAgeCapValidation = WTFMove(entry); 260 ResourceRequest revalidationRequest = originalRequest(); 261 startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes); 262 return; 263 } 250 264 #endif 251 if (entry->redirectRequest()) { 252 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 253 loader->dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry)); 254 return; 255 } 256 if (loader->m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) { 257 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 258 loader->startNetworkLoad(WTFMove(request), FirstLoad::Yes); 259 return; 260 } 261 if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) { 262 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 263 loader->validateCacheEntry(WTFMove(entry)); 264 return; 265 } 266 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 267 loader->didRetrieveCacheEntry(WTFMove(entry)); 268 }); 265 if (entry->redirectRequest()) { 266 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 267 dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry)); 268 return; 269 } 270 if (m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) { 271 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 272 startNetworkLoad(WTFMove(request), FirstLoad::Yes); 273 return; 274 } 275 if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) { 276 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 277 validateCacheEntry(WTFMove(entry)); 278 return; 279 } 280 RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous()); 281 didRetrieveCacheEntry(WTFMove(entry)); 269 282 } 270 283 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h
r247825 r247860 130 130 void tryStoreAsCacheEntry(); 131 131 void retrieveCacheEntry(const WebCore::ResourceRequest&); 132 void retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&&, WebCore::ResourceRequest&&); 132 133 void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>); 133 134 void sendResultForCacheEntry(std::unique_ptr<NetworkCache::Entry>);
Note: See TracChangeset
for help on using the changeset viewer.