Resources from non-HTTP schemes should not be cached indefinitely
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2013 02:54:06 +0000 (02:54 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2013 02:54:06 +0000 (02:54 +0000)
commit0a1f0ec71e2c4bd4868069fe22ab19ece21da50d
treecef6042af979d0236e949a83a30f3aea66d1e114
parent5eb796654e827c577cc0782d88cfbde77d553bd4
Resources from non-HTTP schemes should not be cached indefinitely
https://bugs.webkit.org/show_bug.cgi?id=113626

Reviewed by Ryosuke Niwa.

Source/WebCore:

With the exception of schemes that we know will always return the same
result for a given URL, we should not indefinitely cache non-HTTP
resources when their freshness cannot be verified.

Writing a test for this is blocked on https://webkit.org/b/116199.

The following two existing tests of memory cache behavior were
converted to HTTP tests so that they continue to function as expected:

Tests: http/tests/cache/display-image-unset-allows-cached-image-load.html
       http/tests/cache/willsendrequest-returns-null-for-memory-cache-load.html

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::freshnessLifetime): Returned a freshness
lifetime of 0 for non-HTTP schemes that can't be indefinitely cached.
* platform/SchemeRegistry.cpp:
(WebCore::SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely):
Checked whether the scheme is blob:, data:, or applewebdata:.
* platform/SchemeRegistry.h:

LayoutTests:

Convert existing memory cache tests to HTTP tests.

* fast/loader/resources/compass.jpg: Removed.
* fast/loader/resources/image1.html: Removed.
* fast/loader/resources/image2.html: Removed.
* fast/loader/willsendrequest-returns-null-for-memory-cache-load-expected.txt: Removed.
* http/tests/cache/display-image-unset-allows-cached-image-load-expected.txt: Renamed from LayoutTests/fast/loader/display-image-unset-allows-cached-image-load-expected.txt.
* http/tests/cache/display-image-unset-allows-cached-image-load.html: Renamed from LayoutTests/fast/loader/display-image-unset-allows-cached-image-load.html.
* http/tests/cache/resources/cached-image.html: Renamed from LayoutTests/fast/loader/resources/cached-image.html.
* http/tests/cache/resources/image1.html: Added.
* http/tests/cache/resources/image2.html: Added.
* http/tests/cache/willsendrequest-returns-null-for-memory-cache-load-expected.txt: Added.
* http/tests/cache/willsendrequest-returns-null-for-memory-cache-load.html: Renamed from LayoutTests/fast/loader/willsendrequest-returns-null-for-memory-cache-load.html.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@150169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/loader/resources/compass.jpg [deleted file]
LayoutTests/fast/loader/resources/image1.html [deleted file]
LayoutTests/fast/loader/resources/image2.html [deleted file]
LayoutTests/fast/loader/willsendrequest-returns-null-for-memory-cache-load-expected.txt [deleted file]
LayoutTests/http/tests/cache/display-image-unset-allows-cached-image-load-expected.txt [moved from LayoutTests/fast/loader/display-image-unset-allows-cached-image-load-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/display-image-unset-allows-cached-image-load.html [moved from LayoutTests/fast/loader/display-image-unset-allows-cached-image-load.html with 100% similarity]
LayoutTests/http/tests/cache/resources/cached-image.html [moved from LayoutTests/fast/loader/resources/cached-image.html with 50% similarity]
LayoutTests/http/tests/cache/resources/image1.html [new file with mode: 0644]
LayoutTests/http/tests/cache/resources/image2.html [new file with mode: 0644]
LayoutTests/http/tests/cache/willsendrequest-returns-null-for-memory-cache-load-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/willsendrequest-returns-null-for-memory-cache-load.html [moved from LayoutTests/fast/loader/willsendrequest-returns-null-for-memory-cache-load.html with 87% similarity]
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/platform/SchemeRegistry.cpp
Source/WebCore/platform/SchemeRegistry.h