Make storing cross-origin top-level prefetches in HTTP cache optional
https://bugs.webkit.org/show_bug.cgi?id=199499
Patch by Rob Buis <rbuis@igalia.com> on 2019-07-26
Reviewed by Youenn Fablet.
Source/WebCore:
Add Internals API for adding an event listener to prefetch load.
Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html
* bindings/js/JSEventListener.h:
* dom/EventTarget.h:
(WebCore::EventTarget::addEventListener):
* dom/Node.h:
* html/HTMLLinkElement.h:
* testing/Internals.cpp:
(WebCore::Internals::addPrefetchLoadEventListener):
* testing/Internals.h:
* testing/Internals.idl:
Source/WebKit:
Currently when we navigate we check if there is a cross-origin top-level
prefetch we can use for the navigation. The current solution uses the
HTTP cache as a way to store the prefetch and to immediately use it for
the navigation load. However this solution fails in case the prefetch is
not cacheable.
Instead of this, simulate a HTTP Cache entry to process the load and
afterwards try to store the navigation load into the HTTP cache, where
normal store decisions will be applied.
Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::retrieveCacheEntry):
(WebKit::NetworkResourceLoader::retrieveCacheEntryInternal):
* NetworkProcess/NetworkResourceLoader.h:
LayoutTests:
Remove unneeded Cache-Control headers and verify that Cache-Control
effects whether the navigation gets stored in the disk cache or not.
* http/tests/cache/resources/prefetched-main-resource-iframe.php:
* http/tests/cache/resources/prefetched-main-resource.php:
* http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt: Added.
* http/wpt/prefetch/link-prefetch-skip-disk-cache.html: Added.
* http/wpt/prefetch/resources/main-resource-skip-disk-cache.py: Added.
(main):
* http/wpt/prefetch/resources/navigate-skip-disk-cache.html: Added.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247860
268f45cc-cd09-0410-ab3c-
d52691b4dbfc