Diff
Modified: trunk/LayoutTests/ChangeLog (247275 => 247276)
--- trunk/LayoutTests/ChangeLog 2019-07-09 20:41:12 UTC (rev 247275)
+++ trunk/LayoutTests/ChangeLog 2019-07-09 20:44:07 UTC (rev 247276)
@@ -1,3 +1,17 @@
+2019-07-09 Youenn Fablet <[email protected]>
+
+ XHR CORS requests logged twice in the server
+ https://bugs.webkit.org/show_bug.cgi?id=199492
+ <rdar://problem/52757558>
+
+ Reviewed by Chris Dumez.
+
+ * 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-09 Rob Buis <[email protected]>
Remove rel=subresource tests
Added: trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt (0 => 247276)
--- trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads-expected.txt 2019-07-09 20:44:07 UTC (rev 247276)
@@ -0,0 +1,4 @@
+
+PASS Ensure fetch is not speculatively loaded
+PASS Ensure XHR is not speculatively loaded
+
Added: trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html (0 => 247276)
--- trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/disable-speculative-load-for-xhr-and-fetch-loads.html 2019-07-09 20:44:07 UTC (rev 247276)
@@ -0,0 +1,73 @@
+<!doctype html>
+<script src=""
+<script src=""
+<script src=""
+<script>
+function loadIFrame(src) {
+ return new Promise(function(resolve, reject) {
+ var iframe = document.createElement('iframe');
+ iframe._onload_ = function() { resolve(iframe); };
+
+ iframe.src = ""
+
+ document.documentElement.appendChild(iframe);
+ });
+}
+
+function resetIFrame(iframe)
+{
+ const promise = new Promise(resolve => { iframe._onload_ = resolve; });
+ iframe.src = ""
+ return promise;
+}
+
+function navigateIFrame(iframe, src)
+{
+ const promise = new Promise(resolve => window.resolveToken = resolve);
+ iframe.src = ""
+ 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>
Added: trunk/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py (0 => 247276)
--- trunk/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/resources/fetch-xhr-load.py 2019-07-09 20:44:07 UTC (rev 247276)
@@ -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)
Added: trunk/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html (0 => 247276)
--- trunk/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/resources/xhr-and-fetch.html 2019-07-09 20:44:07 UTC (rev 247276)
@@ -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>
Modified: trunk/Source/WebKit/ChangeLog (247275 => 247276)
--- trunk/Source/WebKit/ChangeLog 2019-07-09 20:41:12 UTC (rev 247275)
+++ trunk/Source/WebKit/ChangeLog 2019-07-09 20:44:07 UTC (rev 247276)
@@ -1,3 +1,20 @@
+2019-07-09 Youenn Fablet <[email protected]>
+
+ XHR CORS requests logged twice in the server
+ https://bugs.webkit.org/show_bug.cgi?id=199492
+ <rdar://problem/52757558>
+
+ Reviewed by Chris Dumez.
+
+ 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-09 Chris Dumez <[email protected]>
Fix validation of method signature in decodeInvocation()
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (247275 => 247276)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2019-07-09 20:41:12 UTC (rev 247275)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2019-07-09 20:44:07 UTC (rev 247276)
@@ -269,6 +269,19 @@
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 @@
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