Title: [206855] trunk
Revision
206855
Author
[email protected]
Date
2016-10-06 01:30:01 -0700 (Thu, 06 Oct 2016)

Log Message

[WK2] 304 revalidation on the network process does not update the validated response
https://bugs.webkit.org/show_bug.cgi?id=162973

Patch by Youenn Fablet <[email protected]> on 2016-10-06
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/basic/conditional-get-expected.txt: Added.
* web-platform-tests/fetch/api/basic/conditional-get.html: Added.
* web-platform-tests/fetch/api/resources/cache.py: Added.

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.cpp: Updating cache entry with the revalidated one.

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt:
Rebasing expectation as memory cache revalidation is no longer needed now that the disk cache is updating the response passed to the memory cache.
The disk cache is doing revalidation on the second load. It receives the updated response with longer validity.
As the extended validity response is now passed to the memory cache, the memory cache revalidation no longer happens.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206854 => 206855)


--- trunk/LayoutTests/ChangeLog	2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/ChangeLog	2016-10-06 08:30:01 UTC (rev 206855)
@@ -1,3 +1,15 @@
+2016-10-06  Youenn Fablet  <[email protected]>
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt:
+        Rebasing expectation as memory cache revalidation is no longer needed now that the disk cache is updating the response passed to the memory cache.
+        The disk cache is doing revalidation on the second load. It receives the updated response with longer validity.
+        As the extended validity response is now passed to the memory cache, the memory cache revalidation no longer happens.
+
 2016-10-06  Nan Wang  <[email protected]>
 
         AX:[Mac] Unable to edit text input, textarea fields in iframe using VO naivgation

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt (206854 => 206855)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt	2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt	2016-10-06 08:30:01 UTC (rev 206855)
@@ -12,12 +12,12 @@
 --------Testing loads through memory cache (XHR behavior)--------
 response headers: {"Expires":"now(0)","ETag":"match"}
 response's 'Expires' header is overriden by future date in 304 response
-response source: Memory cache after validation
+response source: Memory cache
 
 --------Testing loads through memory cache (subresource behavior)--------
 response headers: {"Expires":"now(0)","ETag":"match"}
 response's 'Expires' header is overriden by future date in 304 response
-response source: Memory cache after validation
+response source: Memory cache
 
 304 response included an 'Expires' header in the future, so we should not need to revalidate this time.
 --------Testing loads from disk cache--------

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206854 => 206855)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-06 08:30:01 UTC (rev 206855)
@@ -1,3 +1,14 @@
+2016-10-06  Youenn Fablet  <[email protected]>
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/fetch/api/basic/conditional-get-expected.txt: Added.
+        * web-platform-tests/fetch/api/basic/conditional-get.html: Added.
+        * web-platform-tests/fetch/api/resources/cache.py: Added.
+
 2016-10-05  Ryosuke Niwa  <[email protected]>
 
         Import v1 custom elements tests from W3C

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt (0 => 206855)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt	2016-10-06 08:30:01 UTC (rev 206855)
@@ -0,0 +1,3 @@
+
+PASS Testing conditional GET with ETags 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html (0 => 206855)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html	2016-10-06 08:30:01 UTC (rev 206855)
@@ -0,0 +1,51 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Request ETag</title>
+    <meta name="help" href=""
+    <script src=""
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <script>
+    promise_test(function() {
+      var cacheBuster = token(); // ensures first request is uncached
+      var url = "" + cacheBuster;
+      var etag;
+
+      // make the first request
+      return fetch(url).then(function(response) {
+        // ensure we're getting the regular, uncached response
+        assert_equals(response.status, 200);
+        assert_equals(response.headers.get("X-HTTP-STATUS"), null)
+
+        return response.text(); // consuming the body, just to be safe
+      }).then(function(body) {
+        // make a second request
+        return fetch(url);
+      }).then(function(response) {
+        // while the server responds with 304 if our browser sent the correct
+        // If-None-Match request header, at the _javascript_ level this surfaces
+        // as 200
+        assert_equals(response.status, 200);
+        assert_equals(response.headers.get("X-HTTP-STATUS"), "304")
+
+        etag = response.headers.get("ETag")
+
+        return response.text(); // consuming the body, just to be safe
+      }).then(function(body) {
+        // make a third request, explicitly setting If-None-Match request header
+        var headers = { "If-None-Match": etag }
+        return fetch(url, { headers: headers })
+      }).then(function(response) {
+        // 304 now surfaces thanks to the explicit If-None-Match request header
+        assert_equals(response.status, 304);
+      });
+    }, "Testing conditional GET with ETags");
+
+    done();
+    </script>
+  </body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py (0 => 206855)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py	2016-10-06 08:30:01 UTC (rev 206855)
@@ -0,0 +1,18 @@
+ETAG = '"123abc"'
+CONTENT_TYPE = "text/plain"
+CONTENT = "lorem ipsum dolor sit amet"
+
+
+def main(request, response):
+    # let caching kick in if possible (conditional GET)
+    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", CONTENT_TYPE)
+    return CONTENT

Modified: trunk/Source/WebKit2/ChangeLog (206854 => 206855)


--- trunk/Source/WebKit2/ChangeLog	2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-06 08:30:01 UTC (rev 206855)
@@ -1,3 +1,12 @@
+2016-10-06  Youenn Fablet  <[email protected]>
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/NetworkResourceLoader.cpp: Updating cache entry with the revalidated one.
+
 2016-10-05  Wenson Hsieh  <[email protected]>
 
         Introduce InputEvent bindings in preparation for the input events spec

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (206854 => 206855)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2016-10-06 08:30:01 UTC (rev 206855)
@@ -325,9 +325,8 @@
     if (m_cacheEntryForValidation) {
         bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified
         if (validationSucceeded) {
-            NetworkCache::singleton().update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response);
-            // If the request was conditional then this revalidation was not triggered by the network cache and we pass the
-            // 304 response to WebCore.
+            m_cacheEntryForValidation = NetworkCache::singleton().update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response);
+            // If the request was conditional then this revalidation was not triggered by the network cache and we pass the 304 response to WebCore.
             if (originalRequest().isConditional())
                 m_cacheEntryForValidation = nullptr;
         } else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to