Cannot abort multiple XHR POSTs made to same url
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2013 18:25:16 +0000 (18:25 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2013 18:25:16 +0000 (18:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106937

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Test: http/tests/cache/cancel-multiple-post-xhrs.html

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::removeClient): Call allClientsRemoved() regardless
    of whether this resource is inCache(). Otherwise, CachedRawResources will
    not have the opportunity to cancel as expected. However, don't cancel
    if the last client was removed because we're in the middle of switching
    the clients over to a successfully revalidated resource.

LayoutTests:

* http/tests/cache/cancel-multiple-post-xhrs-expected.txt: Added.
* http/tests/cache/cancel-multiple-post-xhrs.html: Added.
* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140174 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/cache/cancel-multiple-post-xhrs-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/cancel-multiple-post-xhrs.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp

index c2342e3..aaef71c 100644 (file)
@@ -1,3 +1,14 @@
+2013-01-18  Nate Chapin  <japhet@chromium.org>
+
+        Cannot abort multiple XHR POSTs made to same url
+        https://bugs.webkit.org/show_bug.cgi?id=106937
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/cache/cancel-multiple-post-xhrs-expected.txt: Added.
+        * http/tests/cache/cancel-multiple-post-xhrs.html: Added.
+        * platform/mac/TestExpectations:
+
 2013-01-18  Dima Gorbik  <dgorbik@apple.com>
 
         Implement ::cue() pseudo element property whitelist
diff --git a/LayoutTests/http/tests/cache/cancel-multiple-post-xhrs-expected.txt b/LayoutTests/http/tests/cache/cancel-multiple-post-xhrs-expected.txt
new file mode 100644 (file)
index 0000000..27c670d
--- /dev/null
@@ -0,0 +1,7 @@
+http://127.0.0.1:8000/cache/resources/empty.txt - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/empty.txt, main document URL http://127.0.0.1:8000/cache/cancel-multiple-post-xhrs.html, http method POST> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/empty.txt - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/empty.txt, main document URL http://127.0.0.1:8000/cache/cancel-multiple-post-xhrs.html, http method POST> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/empty.txt - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/empty.txt, main document URL http://127.0.0.1:8000/cache/cancel-multiple-post-xhrs.html, http method POST> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/empty.txt - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://127.0.0.1:8000/cache/resources/empty.txt">
+http://127.0.0.1:8000/cache/resources/empty.txt - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://127.0.0.1:8000/cache/resources/empty.txt">
+http://127.0.0.1:8000/cache/resources/empty.txt - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://127.0.0.1:8000/cache/resources/empty.txt">
+
diff --git a/LayoutTests/http/tests/cache/cancel-multiple-post-xhrs.html b/LayoutTests/http/tests/cache/cancel-multiple-post-xhrs.html
new file mode 100644 (file)
index 0000000..f14b2d4
--- /dev/null
@@ -0,0 +1,18 @@
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.dumpResourceLoadCallbacks();
+}
+
+var xhrs = new Array(3);
+for (var i = 0; i < 3; i++) {
+    xhrs[i] = new XMLHttpRequest();
+    xhrs[i].open("POST", 'resources/empty.txt', true);   
+    xhrs[i].send(i);
+}
+
+for (var i = 0; i < 3; i++)
+    xhrs[i].abort();
+</script>
+</body>
index 90e5581..4641fee 100644 (file)
@@ -379,10 +379,6 @@ webarchive/test-link-rel-icon.html
 http/tests/inspector/network/network-size-chunked.html
 http/tests/inspector/network/network-size-sync.html
 
-# https://bugs.webkit.org/show_bug.cgi?id=64097
-http/tests/inspector/network/network-disable-cache-memory.html
-http/tests/inspector/network/network-disable-cache-xhrs.html
-
 # Quota API is not supported.
 storage/storageinfo-missing-arguments.html
 storage/storageinfo-no-callbacks.html
index 611b16d..590dec7 100644 (file)
@@ -1,3 +1,19 @@
+2013-01-18  Nate Chapin  <japhet@chromium.org>
+
+        Cannot abort multiple XHR POSTs made to same url
+        https://bugs.webkit.org/show_bug.cgi?id=106937
+
+        Reviewed by Alexey Proskuryakov.
+
+        Test: http/tests/cache/cancel-multiple-post-xhrs.html
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::removeClient): Call allClientsRemoved() regardless
+            of whether this resource is inCache(). Otherwise, CachedRawResources will
+            not have the opportunity to cancel as expected. However, don't cancel
+            if the last client was removed because we're in the middle of switching
+            the clients over to a successfully revalidated resource.
+
 2013-01-18  Dima Gorbik  <dgorbik@apple.com>
 
         Implement ::cue() pseudo element property whitelist
index 88cf286..c59de73 100644 (file)
@@ -525,10 +525,13 @@ void CachedResource::removeClient(CachedResourceClient* client)
     }
 
     bool deleted = deleteIfPossible();
-    if (!deleted && !hasClients() && inCache()) {
-        memoryCache()->removeFromLiveResourcesSize(this);
-        memoryCache()->removeFromLiveDecodedResourcesList(this);
-        allClientsRemoved();
+    if (!deleted && !hasClients()) {
+        if (inCache()) {
+            memoryCache()->removeFromLiveResourcesSize(this);
+            memoryCache()->removeFromLiveDecodedResourcesList(this);
+        }
+        if (!m_switchingClientsToRevalidatedResource)
+            allClientsRemoved();
         destroyDecodedDataIfNeeded();
         if (response().cacheControlContainsNoStore()) {
             // RFC2616 14.9.2: