summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 15:37:11 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 15:37:11 +0000
commit14e5bca82b5ac6f0a2b59d087d3f38e19017c127 (patch)
tree216afa47b5a6e9436010323c2df30145c9eb3947 /chrome/browser/automation
parent9f71149c6d3188836bd1e4cfc3997a51b38a3f01 (diff)
downloadchromium_src-14e5bca82b5ac6f0a2b59d087d3f38e19017c127.zip
chromium_src-14e5bca82b5ac6f0a2b59d087d3f38e19017c127.tar.gz
chromium_src-14e5bca82b5ac6f0a2b59d087d3f38e19017c127.tar.bz2
Fix FullTabModeIE_ChromeFrameDeleteCookieTest. The problem was that a domain cookie was being set twice although only set once by the server.
The test itself needed fixing as well as an extra check for domain cookies set by a different url than the current url. There's one other problem remaining however which was initially reported in bug 30786 and I'll get on that next (bug reopened). TEST=Run the FullTabModeIE_ChromeFrameDeleteCookieTest test. BUG=32546, 30786 Review URL: http://codereview.chromium.org/546104 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r--chrome/browser/automation/automation_profile_impl.cc4
-rw-r--r--chrome/browser/automation/url_request_automation_job.cc60
2 files changed, 46 insertions, 18 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.cc b/chrome/browser/automation/automation_profile_impl.cc
index b8685be..3a1387d 100644
--- a/chrome/browser/automation/automation_profile_impl.cc
+++ b/chrome/browser/automation/automation_profile_impl.cc
@@ -110,6 +110,10 @@ class AutomationCookieStore : public net::CookieStore {
return original_cookie_store_->DeleteCookie(url, cookie_name);
}
+ virtual net::CookieMonster* GetCookieMonster() {
+ return original_cookie_store_->GetCookieMonster();
+ }
+
protected:
void SendIPCMessageOnIOThread(IPC::Message* m) {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc
index ec01660..5e35ab8 100644
--- a/chrome/browser/automation/url_request_automation_job.cc
+++ b/chrome/browser/automation/url_request_automation_job.cc
@@ -49,6 +49,24 @@ URLRequest::ProtocolFactory* URLRequestAutomationJob::old_http_factory_
URLRequest::ProtocolFactory* URLRequestAutomationJob::old_https_factory_
= NULL;
+namespace {
+
+// Returns true if the cookie passed in exists in the list of cookies
+// parsed from the HTTP response header.
+bool IsParsedCookiePresentInCookieHeader(
+ const net::CookieMonster::ParsedCookie& parsed_cookie,
+ const std::vector<std::string>& header_cookies) {
+ for (size_t i = 0; i < header_cookies.size(); ++i) {
+ net::CookieMonster::ParsedCookie parsed_header_cookie(header_cookies[i]);
+ if (parsed_header_cookie.Name() == parsed_cookie.Name())
+ return true;
+ }
+
+ return false;
+}
+
+} // end namespace
+
URLRequestAutomationJob::URLRequestAutomationJob(URLRequest* request, int tab,
int request_id, AutomationResourceMessageFilter* filter)
: URLRequestJob(request),
@@ -291,6 +309,13 @@ void URLRequestAutomationJob::OnRequestStarted(int tab, int id,
url_for_cookies, request_->first_party_for_cookies())) {
StringTokenizer cookie_parser(response.persistent_cookies, ";");
+ std::vector<net::CookieMonster::CanonicalCookie> existing_cookies;
+ net::CookieMonster* monster = ctx->cookie_store()->GetCookieMonster();
+ DCHECK(monster);
+ if (monster) {
+ monster->GetRawCookies(url_for_cookies, &existing_cookies);
+ }
+
while (cookie_parser.GetNext()) {
std::string cookie_string = cookie_parser.token();
// Only allow cookies with valid name value pairs.
@@ -298,12 +323,20 @@ void URLRequestAutomationJob::OnRequestStarted(int tab, int id,
TrimWhitespace(cookie_string, TRIM_ALL, &cookie_string);
// Ignore duplicate cookies, i.e. cookies passed in from the host
// browser which also exist in the response header.
- if (!IsCookiePresentInCookieHeader(cookie_string,
- response_cookies)) {
- net::CookieOptions options;
- ctx->cookie_store()->SetCookieWithOptions(url_for_cookies,
- cookie_string,
- options);
+ net::CookieMonster::ParsedCookie parsed_cookie(cookie_string);
+ std::vector<net::CookieMonster::CanonicalCookie>::const_iterator i;
+ for (i = existing_cookies.begin(); i != existing_cookies.end(); ++i) {
+ if ((*i).Name() == parsed_cookie.Name())
+ break;
+ }
+
+ if (i == existing_cookies.end() &&
+ !IsParsedCookiePresentInCookieHeader(parsed_cookie,
+ response_cookies)) {
+ net::CookieOptions options;
+ ctx->cookie_store()->SetCookieWithOptions(url_for_cookies,
+ cookie_string,
+ options);
}
}
}
@@ -449,17 +482,8 @@ void URLRequestAutomationJob::DisconnectFromMessageFilter() {
}
bool URLRequestAutomationJob::IsCookiePresentInCookieHeader(
- const std::string& cookie_line,
+ const std::string& cookie_name,
const std::vector<std::string>& header_cookies) {
- net::CookieMonster::ParsedCookie parsed_current_cookie(cookie_line);
- for (size_t index = 0; index < header_cookies.size(); index++) {
- net::CookieMonster::ParsedCookie parsed_header_cookie(
- header_cookies[index]);
-
- if (parsed_header_cookie.Name() == parsed_current_cookie.Name())
- return true;
- }
-
- return false;
+ net::CookieMonster::ParsedCookie parsed_cookie(cookie_name);
+ return IsParsedCookiePresentInCookieHeader(parsed_cookie, header_cookies);
}
-