Make storing cross-origin top-level prefetches in HTTP cache optional
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 15:37:09 +0000 (15:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 15:37:09 +0000 (15:37 +0000)
commit2275df0d90088d0215ec2f57b9883eeba0e80dc9
tree6dab6037cc03d8c17dda7d929ec3593ae35bf651
parent86e65377c664d6e944410efbd798330e2c7e2039
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-25
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@247821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php
LayoutTests/http/tests/cache/resources/prefetched-main-resource.php
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/dom/EventTarget.h
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoader.h