WebKit Bugzilla
Attachment 373778 Details for
Bug 199644
: Disable speculative loading if cache is not to be used for the load
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199644-20190709152351.patch (text/plain), 8.96 KB, created by
youenn fablet
on 2019-07-09 15:23:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-07-09 15:23:52 PDT
Size:
8.96 KB
patch
obsolete
>Subversion Revision: 247200 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index aa50f46cbb869b2ad92a231fda80403c01f00393..aef5b4e98e3f0c1ab8bd98a6bdaeb70d6190956c 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2019-07-09 Youenn Fablet <youenn@apple.com> >+ >+ Disable speculative loading if cache is not to be used for the load >+ https://bugs.webkit.org/show_bug.cgi?id=199644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When the page is reloaded, loads are instructed to not use the cache. >+ It is therefore unneeded to do speculative revalidation. >+ Allow speculative revalidation if the cache policy is either the default HTTP policy or >+ if policy is to refresh all cache data. >+ Covered by added test. >+ >+ * NetworkProcess/cache/NetworkCache.cpp: >+ (WebKit::NetworkCache::cachePolicyValidForSpeculativeRevalidation): >+ (WebKit::NetworkCache::canRequestUseSpeculativeRevalidation): >+ > 2019-07-09 Youenn Fablet <youenn@apple.com> > > Revert conditional WebPageProxy check to grant universal file read sandbox upon correct sandbox creation >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >index 20e0758f8459a8da8fa453a097b31f6adb7d57af..48263e9321c6f765b9d476f64485319748272389 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >@@ -270,12 +270,29 @@ static StoreDecision makeStoreDecision(const WebCore::ResourceRequest& originalR > } > > #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) >+static bool cachePolicyValidForSpeculativeRevalidation(WebCore::ResourceRequestCachePolicy policy) >+{ >+ switch (policy) { >+ case WebCore::ResourceRequestCachePolicy::ReturnCacheDataElseLoad: >+ case WebCore::ResourceRequestCachePolicy::ReturnCacheDataDontLoad: >+ case WebCore::ResourceRequestCachePolicy::ReloadIgnoringCacheData: >+ return false; >+ case WebCore::ResourceRequestCachePolicy::UseProtocolCachePolicy: >+ case WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData: >+ return true; >+ case WebCore::ResourceRequestCachePolicy::DoNotUseAnyCache: >+ ASSERT_NOT_REACHED(); >+ return false; >+ } >+ return false; >+} >+ > static bool inline canRequestUseSpeculativeRevalidation(const ResourceRequest& request) > { > if (request.isConditional()) > return false; > >- if (cachePolicyAllowsExpired(request.cachePolicy())) >+ if (cachePolicyValidForSpeculativeRevalidation(request.cachePolicy())) > return false; > > return request.requester() != ResourceRequest::Requester::XHR && request.requester() != ResourceRequest::Requester::Fetch; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 864be45b1493f577e3c2f231c6fb5a446a8d7829..dab6fac0c55cec1d8944a87b7c69070d09b069c9 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,19 @@ >+2019-07-09 Youenn Fablet <youenn@apple.com> >+ >+ Disable speculative loading if cache is not to be used for the load >+ https://bugs.webkit.org/show_bug.cgi?id=199644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/wpt/fetch/disable-speculative-for-reload-expected.txt: Added. >+ * http/wpt/fetch/disable-speculative-for-reload.html: Added. >+ * http/wpt/fetch/resources/iframe-with-image.py: Added. >+ (main): >+ * http/wpt/fetch/resources/image-load-count.py: Added. >+ (main): >+ * http/wpt/fetch/resources/image-load.py: Added. >+ (main): >+ > 2019-07-09 Youenn Fablet <youenn@apple.com> > > Stopping a cloned MediaStream video track should not stop any other video track >diff --git a/LayoutTests/http/wpt/fetch/disable-speculative-for-reload-expected.txt b/LayoutTests/http/wpt/fetch/disable-speculative-for-reload-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..fa6f9cc485a77952153982bfbf698453a10da9ea >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/disable-speculative-for-reload-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Ensure image is not speculatively loaded after a reload >+ >diff --git a/LayoutTests/http/wpt/fetch/disable-speculative-for-reload.html b/LayoutTests/http/wpt/fetch/disable-speculative-for-reload.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4a8d2a67b83e5c8be3c450120a638b83c497ee94 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/disable-speculative-for-reload.html >@@ -0,0 +1,61 @@ >+<!doctype html> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="/common/utils.js"></script> >+<script> >+function loadIFrame(src) { >+ return new Promise(function(resolve, reject) { >+ var iframe = document.createElement('iframe'); >+ iframe.onload = function() { resolve(iframe); }; >+ >+ iframe.src = src; >+ >+ document.documentElement.appendChild(iframe); >+ }); >+} >+ >+async function imageLoadCount(uuid) >+{ >+ const response = await fetch('resources/image-load.py?uuid=' + uuid, { method: 'POST' }); >+ return response.text(); >+} >+ >+async function navigateIFrame(iframe, uuid) >+{ >+ const promise = new Promise(resolve => iframe.onload = resolve); >+ iframe.src = "resources/iframe-with-image.py?uuid=" + uuid; >+ await promise; >+ return imageLoadCount(uuid); >+} >+ >+async function reloadIFrame(iframe, uuid) >+{ >+ const promise = new Promise(resolve => iframe.onload = resolve); >+ iframe.contentWindow.location.reload(); >+ await promise; >+ return imageLoadCount(uuid); >+} >+ >+function resetIFrame(iframe) >+{ >+ const promise = new Promise(resolve => { iframe.onload = resolve; }); >+ iframe.src = "about:blank"; >+ return promise; >+} >+ >+promise_test(async (test) => { >+ const uuid = token(); >+ const iframe = await loadIFrame("about:blank"); >+ >+ const token1 = await navigateIFrame(iframe, uuid); >+ await resetIFrame(iframe); >+ const token2 = await navigateIFrame(iframe, uuid); >+ const token3 = await reloadIFrame(iframe, uuid); >+ >+ assert_equals(token1, "1", "navigating to"); >+ assert_equals(token2, "2", "after new navigation"); >+ assert_equals(token3, "3", "after reload"); >+ >+ iframe.remove(); >+}, "Ensure image is not speculatively loaded after a reload"); >+</script> >diff --git a/LayoutTests/http/wpt/fetch/resources/iframe-with-image.py b/LayoutTests/http/wpt/fetch/resources/iframe-with-image.py >new file mode 100644 >index 0000000000000000000000000000000000000000..7a0a40bbfa192b78823757d136284e06a98fa033 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/resources/iframe-with-image.py >@@ -0,0 +1,8 @@ >+ETAG = '"123abc"' >+ >+ >+def main(request, response): >+ test_id = request.GET.first("uuid") >+ response.status = (200, "OK") >+ response.headers.set("Content-Type", 'text/html') >+ return "<!doctype html><image src='image-load.py?uuid=" + test_id + "'></image>" >diff --git a/LayoutTests/http/wpt/fetch/resources/image-load-count.py b/LayoutTests/http/wpt/fetch/resources/image-load-count.py >new file mode 100644 >index 0000000000000000000000000000000000000000..2d0dbb78862fe5d693cd12c403c0289f86c55c01 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/resources/image-load-count.py >@@ -0,0 +1,11 @@ >+def main(request, response): >+ test_id = request.GET.first("uuid") >+ stashed_count = request.server.stash.take(test_id) >+ if stashed_count is None: >+ stashed_count = test_id + " none" >+ >+ request.server.stash.put(test_id, stashed_count) >+ >+ response.status = (200, "OK") >+ response.headers.set("Content-Type", 'text/plain') >+ return str(stashed_count) >diff --git a/LayoutTests/http/wpt/fetch/resources/image-load.py b/LayoutTests/http/wpt/fetch/resources/image-load.py >new file mode 100644 >index 0000000000000000000000000000000000000000..3f5480d00e446ac9cfa73f42bb1dc447a0718d74 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/resources/image-load.py >@@ -0,0 +1,36 @@ >+ETAG = '"123abc"' >+ >+ >+def main(request, response): >+ test_id = request.GET.first("uuid") >+ >+ if request.method == "POST": >+ stashed_count = request.server.stash.take(test_id) >+ if stashed_count is None: >+ stashed_count = 0 >+ >+ request.server.stash.put(test_id, stashed_count) >+ >+ response.status = (200, "OK") >+ response.headers.set("Content-Type", 'text/plain') >+ return str(stashed_count) >+ >+ stashed_count = request.server.stash.take(test_id) >+ if stashed_count is not None: >+ stashed_count = stashed_count + 1 >+ else: >+ stashed_count = 1 >+ request.server.stash.put(test_id, stashed_count) >+ >+ etag = request.headers.get("If-None-Match", None) >+ if etag == ETAG: >+ response.headers.set("X-HTTP-STATUS", 304) >+ response.status = (304, "Not Modified") >+ return "" >+ >+ # cache miss, so respond with the actual content >+ response.status = (200, "OK") >+ response.headers.set("ETag", ETAG) >+ response.headers.set("Content-Type", 'image/png') >+ response.headers.set("Cache-Control", "max-age=0"); >+ return 'myimagecontent'
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199644
:
373778
|
374828
|
375430