WebKit Bugzilla
Attachment 373676 Details for
Bug 199492
: XHR CORS requests logged twice in the server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199492-20190708160055.patch (text/plain), 8.71 KB, created by
youenn fablet
on 2019-07-08 16:00:56 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-07-08 16:00:56 PDT
Size:
8.71 KB
patch
obsolete
>Subversion Revision: 247200 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f50f49e6bba7edf93e50fe99e14bfa7b19171433..00d67c819822465ad60d885484f2bc26b00a8d73 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2019-07-08 Youenn Fablet <youenn@apple.com> >+ >+ XHR CORS requests logged twice in the server >+ https://bugs.webkit.org/show_bug.cgi?id=199492 >+ <rdar://problem/52757558> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Disable speculative loading for XHR and fetch. >+ These speculative requests might have specific headers that are no longer relevant >+ when reloading the page. This might then confuse servers. >+ >+ * NetworkProcess/cache/NetworkCache.cpp: >+ (WebKit::NetworkCache::makeStoreDecision): >+ (WebKit::NetworkCache::canRequestUseSpeculativeRevalidation): >+ (WebKit::NetworkCache::Cache::retrieve): >+ > 2019-07-07 Zalan Bujtas <zalan@apple.com> > > [ContentChangeObserver] Difficult to control videos on iqiyi.com as the actions are mouse hover >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >index 1310931b4b0af70d8f65ad774d2f4d9abd4701f3..20e0758f8459a8da8fa453a097b31f6adb7d57af 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >@@ -269,6 +269,19 @@ static StoreDecision makeStoreDecision(const WebCore::ResourceRequest& originalR > return StoreDecision::Yes; > } > >+#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) >+static bool inline canRequestUseSpeculativeRevalidation(const ResourceRequest& request) >+{ >+ if (request.isConditional()) >+ return false; >+ >+ if (cachePolicyAllowsExpired(request.cachePolicy())) >+ return false; >+ >+ return request.requester() != ResourceRequest::Requester::XHR && request.requester() != ResourceRequest::Requester::Fetch; >+} >+#endif >+ > void Cache::retrieve(const WebCore::ResourceRequest& request, const GlobalFrameID& frameID, RetrieveCompletionHandler&& completionHandler) > { > ASSERT(request.url().protocolIsInHTTPFamily()); >@@ -283,7 +296,7 @@ void Cache::retrieve(const WebCore::ResourceRequest& request, const GlobalFrameI > info.priority = priority; > > #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) >- bool canUseSpeculativeRevalidation = m_speculativeLoadManager && !request.isConditional() && !cachePolicyAllowsExpired(request.cachePolicy()); >+ bool canUseSpeculativeRevalidation = m_speculativeLoadManager && canRequestUseSpeculativeRevalidation(request); > if (canUseSpeculativeRevalidation) > m_speculativeLoadManager->registerLoad(frameID, request, storageKey); > #endif >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 668c3504d1983581cb1c990b609259203ce43873..d8e0e127c325ef6eb72ae9c041c9bca8587db928 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2019-07-08 Youenn Fablet <youenn@apple.com> >+ >+ XHR CORS requests logged twice in the server >+ https://bugs.webkit.org/show_bug.cgi?id=199492 >+ <rdar://problem/52757558> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt: Added. >+ * http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html: Added. >+ * http/wpt/fetch/resources/fetch-xhr-load.py: Added. >+ (main): >+ * http/wpt/fetch/resources/xhr-and-fetch.html: Added. >+ > 2019-07-07 Zalan Bujtas <zalan@apple.com> > > [ContentChangeObserver] Difficult to control videos on iqiyi.com as the actions are mouse hover >diff --git a/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt b/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..ea5c8c7da7ece5054ddbefaea5bffd5039def003 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt >@@ -0,0 +1,4 @@ >+ >+PASS Ensure fetch is not speculatively loaded >+PASS Ensure XHR is not speculatively loaded >+ >diff --git a/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html b/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html >new file mode 100644 >index 0000000000000000000000000000000000000000..7a7d1acd5c57f04004f3f2f0a1909c5fb3cd54fe >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html >@@ -0,0 +1,73 @@ >+<!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); >+ }); >+} >+ >+function resetIFrame(iframe) >+{ >+ const promise = new Promise(resolve => { iframe.onload = resolve; }); >+ iframe.src = "about:blank"; >+ return promise; >+} >+ >+function navigateIFrame(iframe, src) >+{ >+ const promise = new Promise(resolve => window.resolveToken = resolve); >+ iframe.src = "resources/xhr-and-fetch.html#xhr"; >+ return promise; >+} >+ >+function reloadIFrame(iframe, src) >+{ >+ const promise = new Promise(resolve => window.resolveToken = resolve); >+ iframe.contentWindow.location.reload(); >+ return promise; >+} >+ >+promise_test(async (test) => { >+ window.uuid = token(); >+ window.fetchTest = true; >+ const iframe = await loadIFrame("about:blank"); >+ >+ const token1 = await navigateIFrame(iframe, "resources/xhr-and-fetch.html?fetch"); >+ await resetIFrame(iframe); >+ const token2 = await navigateIFrame(iframe, "resources/xhr-and-fetch.html?fetch"); >+ const token3 = await reloadIFrame(iframe); >+ >+ assert_equals(token1, "0", "navigating to"); >+ assert_equals(token2, "0", "after reload"); >+ // token2 revalidation + token3 reload hence two loads. >+ assert_equals(token3, "2", "after reload"); >+ >+ iframe.remove(); >+}, "Ensure fetch is not speculatively loaded"); >+ >+promise_test(async (test) => { >+ window.uuid = token(); >+ window.fetchTest = false; >+ const iframe = await loadIFrame("about:blank"); >+ >+ const token1 = await navigateIFrame(iframe, "resources/xhr-and-fetch.html?xhr"); >+ await resetIFrame(iframe); >+ const token2 = await navigateIFrame(iframe, "resources/xhr-and-fetch.html?xhr"); >+ const token3 = await reloadIFrame(iframe); >+ >+ assert_equals(token1, "0", "navigating to"); >+ assert_equals(token2, "0", "after reload"); >+ // token2 revalidation + token3 reload hence two loads. >+ assert_equals(token3, "2", "after reload"); >+ >+ iframe.remove(); >+}, "Ensure XHR is not speculatively loaded"); >+</script> >diff --git a/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py b/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py >new file mode 100644 >index 0000000000000000000000000000000000000000..5d7cddf1ed0339303647665ed389ed6394a85a07 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py >@@ -0,0 +1,24 @@ >+ETAG = '"123abc"' >+ >+ >+def main(request, response): >+ test_id = request.GET.first("uuid") >+ stashed_count = request.server.stash.take(test_id) >+ if stashed_count is not None: >+ stashed_count = stashed_count + 1 >+ else: >+ stashed_count = 0; >+ >+ 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", 'text/plain') >+ response.headers.set("Cache-Control", "max-age=0"); >+ return str(stashed_count) >diff --git a/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html b/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0833261b84b507523bde83a7746d0735ade40119 >--- /dev/null >+++ b/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html >@@ -0,0 +1,13 @@ >+<!doctype html> >+<script> >+if (parent.window.fetchTest) { >+ fetch("fetch-xhr-load.py?fetch&uuid=" + parent.window.uuid).then(async response => { >+ parent.window.resolveToken(await response.text()); >+ }); >+} else { >+ const xhr = new XMLHttpRequest(); >+ xhr.open("GET", "fetch-xhr-load.py?xhr&uuid=" + parent.window.uuid, false); >+ xhr.send(); >+ parent.window.resolveToken(xhr.responseText); >+} >+</script>
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 199492
: 373676