[BlackBerry] HTTP GET header has a "Cookie" when refreshing a page after cookies...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Apr 2012 10:56:38 +0000 (10:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Apr 2012 10:56:38 +0000 (10:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84223

Patch by Jason Liu <jason.liu@torchmobile.com.cn> on 2012-04-18
Reviewed by George Staikos.

.:

* ManualTests/blackberry/clear-cookie-refresh-result.php: Added.
* ManualTests/blackberry/clear-cookie-refresh.php: Added.

Source/WebCore:

Webkit uses the old ResourceRequest when refreshing. Its cookies' header isn't removed after clicking
"clear cookies" button. We need to set cookies for this request again.

We must click "clear button" to test, so have to write a manual test case.

Test: ManualTests/blackberry/clear-cookie-refresh.php

* platform/network/blackberry/ResourceRequestBlackBerry.cpp:
(WebCore::ResourceRequest::initializePlatformRequest):

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

ChangeLog
ManualTests/blackberry/clear-cookie-refresh-result.php [new file with mode: 0644]
ManualTests/blackberry/clear-cookie-refresh.php [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp

index 89cb117..d938986 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-04-18  Jason Liu  <jason.liu@torchmobile.com.cn>
+
+        [BlackBerry] HTTP GET header has a "Cookie" when refreshing a page after cookies have been cleared.
+        https://bugs.webkit.org/show_bug.cgi?id=84223
+
+        Reviewed by George Staikos.
+
+        * ManualTests/blackberry/clear-cookie-refresh-result.php: Added.
+        * ManualTests/blackberry/clear-cookie-refresh.php: Added.
+
 2012-04-17  Yong Li  <yoli@rim.com>
 
         REGRESSION (r105453): Crash when handling touch events
diff --git a/ManualTests/blackberry/clear-cookie-refresh-result.php b/ManualTests/blackberry/clear-cookie-refresh-result.php
new file mode 100644 (file)
index 0000000..30fb0a2
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+    echo 'This tests the function of clear cookies by clicking "Clear Cookies" button from Settings -> Privacy & Security.<br>';
+    echo 'It is for https://bugs.webkit.org/show_bug.cgi?id=84223.<br>';
+    echo 'Please clear the cookies from Settings -> Privacy & Security by pressing "Clear Cookies" button, then refresh this page to see the result.<br>';
+    if (isset($_COOKIE["cookieName"])) {
+        echo 'result: NOT PASS';
+    } else {
+        echo 'result: PASS';
+    }
+?>
diff --git a/ManualTests/blackberry/clear-cookie-refresh.php b/ManualTests/blackberry/clear-cookie-refresh.php
new file mode 100644 (file)
index 0000000..7ab1347
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+    setcookie("cookieName", "cookieValue");
+    header("Location: clear-cookie-refresh-result.php");
+?>
index 5be840f..758b908 100644 (file)
@@ -1,3 +1,20 @@
+2012-04-18  Jason Liu  <jason.liu@torchmobile.com.cn>
+
+        [BlackBerry] HTTP GET header has a "Cookie" when refreshing a page after cookies have been cleared.
+        https://bugs.webkit.org/show_bug.cgi?id=84223
+
+        Reviewed by George Staikos.
+
+        Webkit uses the old ResourceRequest when refreshing. Its cookies' header isn't removed after clicking
+        "clear cookies" button. We need to set cookies for this request again.
+
+        We must click "clear button" to test, so have to write a manual test case.
+
+        Test: ManualTests/blackberry/clear-cookie-refresh.php
+
+        * platform/network/blackberry/ResourceRequestBlackBerry.cpp:
+        (WebCore::ResourceRequest::initializePlatformRequest):
+
 2012-04-17  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: [Chromium] Module's require injects scripts before the debug id is set to the context.
index 9e30ef5..e4221f0 100644 (file)
@@ -190,6 +190,9 @@ void ResourceRequest::initializePlatformRequest(NetworkRequest& platformRequest,
             }
         }
 
+        // When ResourceRequest is reused by CacheResourceLoader, page refreshing or redirection, its cookies may be dirtied. We won't use these cookies any more.
+        bool cookieHeaderMayBeDirty = isRedirect || cachePolicy() == WebCore::ReloadIgnoringCacheData || cachePolicy() == WebCore::ReturnCacheDataElseLoad;
+
         for (HTTPHeaderMap::const_iterator it = httpHeaderFields().begin(); it != httpHeaderFields().end(); ++it) {
             String key = it->first;
             String value = it->second;
@@ -198,14 +201,14 @@ void ResourceRequest::initializePlatformRequest(NetworkRequest& platformRequest,
                 // We wo't use the old cookies of resourceRequest for new location because these cookies may be changed by redirection.
                 if (!equalIgnoringCase(key, "Cookie"))
                     platformRequest.addHeader(key.latin1().data(), value.latin1().data());
-                else if (!isRedirect)
+                else if (!cookieHeaderMayBeDirty)
                     platformRequest.addHeader(key.latin1().data(), value.containsOnlyLatin1() ? value.latin1().data() : value.utf8().data());
             }
         }
-       
-        // Redirection's response may add or update cookies, so we get cookies from CookieManager when redirection happens.
+
+        // If request's cookies may be dirty, they must be set again.
         // If there aren't cookies in the header list, we need trying to add cookies.
-        if (cookiesEnabled && (isRedirect || !httpHeaderFields().contains("Cookie")) && !url().isNull()) {
+        if (cookiesEnabled && (cookieHeaderMayBeDirty || !httpHeaderFields().contains("Cookie")) && !url().isNull()) {
             // Prepare a cookie header if there are cookies related to this url.
             String cookiePairs = cookieManager().getCookie(url(), WithHttpOnlyCookies);
             if (!cookiePairs.isEmpty())