Title: [199486] releases/WebKitGTK/webkit-2.12
- Revision
- 199486
- Author
- [email protected]
- Date
- 2016-04-13 08:03:52 -0700 (Wed, 13 Apr 2016)
Log Message
Merge r199061 - We sometimes fail to remove outdated entry from the disk cache after revalidation and when the resource is no longer cacheable
https://bugs.webkit.org/show_bug.cgi?id=156048
<rdar://problem/25514480>
Reviewed by Antti Koivisto.
Source/WebKit2:
We would sometimes fail to remove outdated entry from the disk cache
after revalidation and when the resource is no longer cacheable. This
was due to Storage::removeFromPendingWriteOperations() only removing
the first pending write operation with a given key instead of actually
removing all of the operations with this key.
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::removeFromPendingWriteOperations):
* NetworkProcess/cache/NetworkCacheStorage.h:
LayoutTests:
Add test coverage for the bug.
* http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html: Added.
* http/tests/cache/disk-cache/resources/json.php: Added.
Modified Paths
Added Paths
Diff
Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (199485 => 199486)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-04-13 14:59:51 UTC (rev 199485)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-04-13 15:03:52 UTC (rev 199486)
@@ -1,3 +1,17 @@
+2016-04-05 Chris Dumez <[email protected]>
+
+ We sometimes fail to remove outdated entry from the disk cache after revalidation and when the resource is no longer cacheable
+ https://bugs.webkit.org/show_bug.cgi?id=156048
+ <rdar://problem/25514480>
+
+ Reviewed by Antti Koivisto.
+
+ Add test coverage for the bug.
+
+ * http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes-expected.txt: Added.
+ * http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html: Added.
+ * http/tests/cache/disk-cache/resources/json.php: Added.
+
2016-04-04 Zalan Bujtas <[email protected]>
CSS Triangles Rendering Regression affecting CSS Ribbons.
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes-expected.txt (0 => 199486)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes-expected.txt 2016-04-13 15:03:52 UTC (rev 199486)
@@ -0,0 +1,15 @@
+Make sure that we properly remove cached entry if the entry is no longer cacheable after revalidation
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+200: {"version":1}
+200: {"version":1}
+404: {"not":"found"}
+200: {"version":2}
+200: {"version":2}
+PASS bugReproduced is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html (0 => 199486)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html 2016-04-13 15:03:52 UTC (rev 199486)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+description("Make sure that we properly remove cached entry if the entry is no longer cacheable after revalidation");
+jsTestIsAsync = true;
+
+var id = Math.floor((Math.random() * 1000000000000));
+var bugReproduced = true;
+
+function fetch(url) {
+ return new Promise(function (resolve, reject) {
+ var xhr = new XMLHttpRequest(url);
+ xhr._onerror_ = reject;
+ xhr._onload_ = function () {
+ resolve({status: xhr.status, body: JSON.parse(xhr.responseText)});
+ };
+ xhr.open('GET', url);
+ xhr.send();
+ })
+}
+
+function fetchResource() {
+ return fetch('resources/json.php?id=' + id).then(function (resp) {
+ if (resp.body.version === 2) {
+ bugReproduced = false;
+ }
+ debug(resp.status + ': ' + JSON.stringify(resp.body));
+ });
+}
+
+_onload_ = function() {
+ fetchResource()
+ .then(fetchResource)
+ .then(fetchResource)
+ .then(fetchResource)
+ .then(fetchResource)
+ .then(function () {
+ shouldBeFalse("bugReproduced");
+ finishJSTest();
+ })
+ .catch(console.log.bind(console));
+}
+
+</script>
+<script src=""
+</body>
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/resources/json.php (0 => 199486)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/resources/json.php (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/cache/disk-cache/resources/json.php 2016-04-13 15:03:52 UTC (rev 199486)
@@ -0,0 +1,42 @@
+<?php
+
+function send304()
+{
+ header("HTTP/1.1 304 Not Modified");
+ header("ETag: foo");
+}
+
+$id = $_GET["id"];
+$count = 1;
+if (isset($_COOKIE[$id])) {
+ $count = $_COOKIE[$id];
+}
+
+setcookie($id, $count + 1);
+
+if ($count == 1) {
+ header("Cache-Control: must-revalidate");
+ header("ETag: foo");
+ header("Content-Type: application/json");
+ echo '{"version": 1}';
+} else if ($count == 2) {
+ send304();
+} else if ($count == 3) {
+ header("HTTP/1.1 404 Not Found");
+ header("Cache-Control: must-revalidate");
+ header("Content-Type: application/json");
+ echo '{"not": "found"}';
+} else if ($count == 4) {
+ if ($_SERVER["HTTP_IF_NONE_MATCH"] == "foo") {
+ send304();
+ } else {
+ header("Cache-Control: must-revalidate");
+ header("ETag: foo");
+ header("Content-Type: application/json");
+ echo '{"version": 2}';
+ }
+} else {
+ send304();
+}
+
+?>
Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog (199485 => 199486)
--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog 2016-04-13 14:59:51 UTC (rev 199485)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog 2016-04-13 15:03:52 UTC (rev 199486)
@@ -1,3 +1,21 @@
+2016-04-05 Chris Dumez <[email protected]>
+
+ We sometimes fail to remove outdated entry from the disk cache after revalidation and when the resource is no longer cacheable
+ https://bugs.webkit.org/show_bug.cgi?id=156048
+ <rdar://problem/25514480>
+
+ Reviewed by Antti Koivisto.
+
+ We would sometimes fail to remove outdated entry from the disk cache
+ after revalidation and when the resource is no longer cacheable. This
+ was due to Storage::removeFromPendingWriteOperations() only removing
+ the first pending write operation with a given key instead of actually
+ removing all of the operations with this key.
+
+ * NetworkProcess/cache/NetworkCacheStorage.cpp:
+ (WebKit::NetworkCache::Storage::removeFromPendingWriteOperations):
+ * NetworkProcess/cache/NetworkCacheStorage.h:
+
2016-04-04 Jiewen Tan <[email protected]>
Tapping on tabs in webpages caused WK crash at WebKit: WebKit::WebFrame::didReceivePolicyDecision
Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (199485 => 199486)
--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2016-04-13 14:59:51 UTC (rev 199485)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2016-04-13 15:03:52 UTC (rev 199486)
@@ -523,16 +523,18 @@
return { headerData };
}
-bool Storage::removeFromPendingWriteOperations(const Key& key)
+void Storage::removeFromPendingWriteOperations(const Key& key)
{
- auto end = m_pendingWriteOperations.end();
- for (auto it = m_pendingWriteOperations.begin(); it != end; ++it) {
- if ((*it)->record.key == key) {
- m_pendingWriteOperations.remove(it);
- return true;
- }
+ while (true) {
+ auto found = m_pendingWriteOperations.findIf([&key](const std::unique_ptr<WriteOperation>& operation) {
+ return operation->record.key == key;
+ });
+
+ if (found == m_pendingWriteOperations.end())
+ break;
+
+ m_pendingWriteOperations.remove(found);
}
- return false;
}
void Storage::remove(const Key& key)
Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h (199485 => 199486)
--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2016-04-13 14:59:51 UTC (rev 199485)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2016-04-13 15:03:52 UTC (rev 199486)
@@ -122,7 +122,7 @@
void readRecord(ReadOperation&, const Data&);
void updateFileModificationTime(const String& path);
- bool removeFromPendingWriteOperations(const Key&);
+ void removeFromPendingWriteOperations(const Key&);
WorkQueue& ioQueue() { return m_ioQueue.get(); }
WorkQueue& backgroundIOQueue() { return m_backgroundIOQueue.get(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes