Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4395)

Unified Diff: chrome/browser/net/cookie_policy_browsertest.cc

Issue 2860012: Revert 50296 (Causes DCHECK failures) - Make CookieMonster NonThreadSafe.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | net/base/cookie_monster.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/cookie_policy_browsertest.cc
===================================================================
--- chrome/browser/net/cookie_policy_browsertest.cc (revision 50356)
+++ chrome/browser/net/cookie_policy_browsertest.cc (working copy)
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task.h"
-#include "base/waitable_event.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/profile.h"
@@ -12,51 +10,10 @@
#include "chrome/test/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"
-namespace {
-
-class GetCookiesTask : public Task {
- public:
- GetCookiesTask(const GURL& url,
- URLRequestContextGetter* context_getter,
- base::WaitableEvent* event,
- std::string* cookies)
- : url_(url),
- context_getter_(context_getter),
- event_(event),
- cookies_(cookies) {}
-
- virtual void Run() {
- *cookies_ = context_getter_->GetCookieStore()->GetCookies(url_);
- event_->Signal();
- }
-
- private:
- const GURL& url_;
- URLRequestContextGetter* const context_getter_;
- base::WaitableEvent* const event_;
- std::string* const cookies_;
-
- DISALLOW_COPY_AND_ASSIGN(GetCookiesTask);
-};
-
class CookiePolicyBrowserTest : public InProcessBrowserTest {
- protected:
+ public:
CookiePolicyBrowserTest() {}
- std::string GetCookies(const GURL& url) {
- std::string cookies;
- base::WaitableEvent event(true /* manual reset */,
- false /* not initially signaled */);
- URLRequestContextGetter* context_getter =
- browser()->profile()->GetRequestContext();
- EXPECT_TRUE(
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
- new GetCookiesTask(url, context_getter, &event, &cookies)));
- EXPECT_TRUE(event.Wait());
- return cookies;
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(CookiePolicyBrowserTest);
};
@@ -69,17 +26,21 @@
browser()->profile()->GetHostContentSettingsMap()->
SetBlockThirdPartyCookies(true);
+ net::CookieStore* cookie_store =
+ browser()->profile()->GetRequestContext()->GetCookieStore();
+
GURL url = server->TestServerPage("set-cookie?cookie1");
- std::string cookie = GetCookies(url);
+ std::string cookie = cookie_store->GetCookies(url);
ASSERT_EQ("", cookie);
ui_test_utils::NavigateToURL(browser(), url);
- cookie = GetCookies(url);
+ cookie = cookie_store->GetCookies(url);
EXPECT_EQ("cookie1", cookie);
}
+
// Visits a page that is a redirect across domain boundary to a page that sets
// a first-party cookie.
IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest,
@@ -90,6 +51,9 @@
browser()->profile()->GetHostContentSettingsMap()->
SetBlockThirdPartyCookies(true);
+ net::CookieStore* cookie_store =
+ browser()->profile()->GetRequestContext()->GetCookieStore();
+
GURL url = server->TestServerPage("server-redirect?");
GURL redirected_url = server->TestServerPage("set-cookie?cookie2");
@@ -102,7 +66,7 @@
replacements.SetHostStr(new_host);
redirected_url = redirected_url.ReplaceComponents(replacements);
- std::string cookie = GetCookies(redirected_url);
+ std::string cookie = cookie_store->GetCookies(redirected_url);
ASSERT_EQ("", cookie);
host_resolver()->AddRule("www.example.com", "127.0.0.1");
@@ -110,8 +74,6 @@
ui_test_utils::NavigateToURL(browser(),
GURL(url.spec() + redirected_url.spec()));
- cookie = GetCookies(redirected_url);
+ cookie = cookie_store->GetCookies(redirected_url);
EXPECT_EQ("cookie2", cookie);
}
-
-} // namespace
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | net/base/cookie_monster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698