| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 true); | 56 true); |
| 57 | 57 |
| 58 GURL url(test_server()->GetURL("server-redirect?")); | 58 GURL url(test_server()->GetURL("server-redirect?")); |
| 59 GURL redirected_url(test_server()->GetURL("set-cookie?cookie2")); | 59 GURL redirected_url(test_server()->GetURL("set-cookie?cookie2")); |
| 60 | 60 |
| 61 // Change the host name from 127.0.0.1 to www.example.com so it triggers | 61 // Change the host name from 127.0.0.1 to www.example.com so it triggers |
| 62 // third-party cookie blocking if the first party for cookies URL is not | 62 // third-party cookie blocking if the first party for cookies URL is not |
| 63 // changed when we follow a redirect. | 63 // changed when we follow a redirect. |
| 64 ASSERT_EQ("127.0.0.1", redirected_url.host()); | 64 ASSERT_EQ("127.0.0.1", redirected_url.host()); |
| 65 GURL::Replacements replacements; | 65 GURL::Replacements replacements; |
| 66 std::string new_host("www.example.com"); | 66 replacements.SetHostStr("www.example.com"); |
| 67 replacements.SetHostStr(new_host); | |
| 68 redirected_url = redirected_url.ReplaceComponents(replacements); | 67 redirected_url = redirected_url.ReplaceComponents(replacements); |
| 69 | 68 |
| 70 std::string cookie = | 69 std::string cookie = |
| 71 content::GetCookies(browser()->profile(), redirected_url); | 70 content::GetCookies(browser()->profile(), redirected_url); |
| 72 ASSERT_EQ("", cookie); | 71 ASSERT_EQ("", cookie); |
| 73 | 72 |
| 74 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 73 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 75 | 74 |
| 76 ui_test_utils::NavigateToURL(browser(), | 75 ui_test_utils::NavigateToURL(browser(), |
| 77 GURL(url.spec() + redirected_url.spec())); | 76 GURL(url.spec() + redirected_url.spec())); |
| 78 | 77 |
| 79 cookie = content::GetCookies(browser()->profile(), redirected_url); | 78 cookie = content::GetCookies(browser()->profile(), redirected_url); |
| 80 EXPECT_EQ("cookie2", cookie); | 79 EXPECT_EQ("cookie2", cookie); |
| 81 } | 80 } |
| 82 | 81 |
| 83 } // namespace | 82 } // namespace |
| OLD | NEW |