Make storing cross-origin top-level prefetches in HTTP cache optional
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 07:29:55 +0000 (07:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 07:29:55 +0000 (07:29 +0000)
commit55310ae29ce8ee3e41eb58165243ecaa8af167e1
tree82de8e97504b14496e846c1ec6b0563c1bd73865
parent34cc04b47c5109a72513a617d6d358e382996f77
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
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