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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc

Issue 1217563005: Create unique HttpNetworkSession for storage partition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wired up remaining state for HttpNetworkSession. Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/prefs/scoped_user_pref_update.h" 7 #include "base/prefs/scoped_user_pref_update.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings_factory.h" 9 #include "chrome/browser/content_settings/cookie_settings_factory.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/session_storage_namespace.h" 35 #include "content/public/browser/session_storage_namespace.h"
36 #include "content/public/browser/storage_partition.h" 36 #include "content/public/browser/storage_partition.h"
37 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
38 #include "content/public/browser/web_ui_controller.h" 38 #include "content/public/browser/web_ui_controller.h"
39 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
40 #include "content/public/test/browser_test_utils.h" 40 #include "content/public/test/browser_test_utils.h"
41 #include "content/public/test/test_navigation_observer.h" 41 #include "content/public/test/test_navigation_observer.h"
42 #include "google_apis/gaia/fake_gaia.h" 42 #include "google_apis/gaia/fake_gaia.h"
43 #include "google_apis/gaia/gaia_switches.h" 43 #include "google_apis/gaia/gaia_switches.h"
44 #include "net/base/url_util.h" 44 #include "net/base/url_util.h"
45 #include "net/http/http_transaction_factory.h"
45 #include "net/test/embedded_test_server/embedded_test_server.h" 46 #include "net/test/embedded_test_server/embedded_test_server.h"
46 #include "net/test/embedded_test_server/http_request.h" 47 #include "net/test/embedded_test_server/http_request.h"
47 #include "net/test/embedded_test_server/http_response.h" 48 #include "net/test/embedded_test_server/http_response.h"
49 #include "net/url_request/url_request_context.h"
50 #include "net/url_request/url_request_context_getter.h"
48 #include "testing/gmock/include/gmock/gmock.h" 51 #include "testing/gmock/include/gmock/gmock.h"
49 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
50 #include "ui/base/l10n/l10n_util.h" 53 #include "ui/base/l10n/l10n_util.h"
51 54
52 using ::testing::_; 55 using ::testing::_;
53 using ::testing::AtLeast; 56 using ::testing::AtLeast;
54 using ::testing::Invoke; 57 using ::testing::Invoke;
55 using ::testing::InvokeWithoutArgs; 58 using ::testing::InvokeWithoutArgs;
56 using ::testing::Return; 59 using ::testing::Return;
57 60
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 171 }
169 172
170 void InlineLoginUIBrowserTest::SetAllowedUsernamePattern( 173 void InlineLoginUIBrowserTest::SetAllowedUsernamePattern(
171 const std::string& pattern) { 174 const std::string& pattern) {
172 PrefService* local_state = g_browser_process->local_state(); 175 PrefService* local_state = g_browser_process->local_state();
173 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern); 176 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern);
174 } 177 }
175 178
176 #if defined(OS_LINUX) || defined(OS_WIN) 179 #if defined(OS_LINUX) || defined(OS_WIN)
177 // crbug.com/422868 180 // crbug.com/422868
178 #define MAYBE_DifferentStorageId DISABLED_DifferentStorageId 181 #define MAYBE_DifferentStorageId DifferentStorageId
179 #else 182 #else
180 #define MAYBE_DifferentStorageId DifferentStorageId 183 #define MAYBE_DifferentStorageId DifferentStorageId
181 #endif 184 #endif
185 void VerifyNetworkSessionsAreDifferent(content::StoragePartition* partition1,
186 content::StoragePartition* partition2) {
187 ASSERT_NE(partition1->GetURLRequestContext()
188 ->GetURLRequestContext()
189 ->http_transaction_factory()
190 ->GetSession(),
191 partition2->GetURLRequestContext()
192 ->GetURLRequestContext()
193 ->http_transaction_factory()
194 ->GetSession());
195 }
196
182 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) { 197 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) {
183 if (switches::IsEnableWebviewBasedSignin()) { 198 if (switches::IsEnableWebviewBasedSignin()) {
184 ContentInfo info = NavigateAndGetInfo( 199 ContentInfo info = NavigateAndGetInfo(
185 browser(), 200 browser(),
186 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 201 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false),
187 CURRENT_TAB); 202 CURRENT_TAB);
188 WaitUntilUIReady(browser()); 203 WaitUntilUIReady(browser());
189 204
190 // Make sure storage partition of embedded webview is different from 205 // Make sure storage partition of embedded webview is different from
191 // parent. 206 // parent.
192 std::set<content::WebContents*> set; 207 std::set<content::WebContents*> set;
193 GuestViewManager* manager = GuestViewManager::FromBrowserContext( 208 GuestViewManager* manager = GuestViewManager::FromBrowserContext(
194 info.contents->GetBrowserContext()); 209 info.contents->GetBrowserContext());
195 manager->ForEachGuest(info.contents, base::Bind(&AddToSet, &set)); 210 manager->ForEachGuest(info.contents, base::Bind(&AddToSet, &set));
196 ASSERT_EQ(1u, set.size()); 211 ASSERT_EQ(1u, set.size());
197 content::WebContents* webview_contents = *set.begin(); 212 content::WebContents* webview_contents = *set.begin();
198 content::RenderProcessHost* process = 213 content::RenderProcessHost* process =
199 webview_contents->GetRenderProcessHost(); 214 webview_contents->GetRenderProcessHost();
200 ASSERT_NE(info.pid, process->GetID()); 215 ASSERT_NE(info.pid, process->GetID());
201 ASSERT_NE(info.storage_partition, process->GetStoragePartition()); 216 ASSERT_NE(info.storage_partition, process->GetStoragePartition());
217 base::RunLoop run_loop;
218 content::BrowserThread::PostTaskAndReply(
219 content::BrowserThread::IO, FROM_HERE,
220 base::Bind(VerifyNetworkSessionsAreDifferent, info.storage_partition,
221 process->GetStoragePartition()),
222 run_loop.QuitClosure());
223 run_loop.Run();
202 } else { 224 } else {
203 GURL test_url = ui_test_utils::GetTestUrl( 225 GURL test_url = ui_test_utils::GetTestUrl(
204 base::FilePath(base::FilePath::kCurrentDirectory), 226 base::FilePath(base::FilePath::kCurrentDirectory),
205 base::FilePath(FILE_PATH_LITERAL("title1.html"))); 227 base::FilePath(FILE_PATH_LITERAL("title1.html")));
206 228
207 ContentInfo info1 = 229 ContentInfo info1 =
208 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); 230 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB);
209 ContentInfo info2 = NavigateAndGetInfo( 231 ContentInfo info2 = NavigateAndGetInfo(
210 browser(), 232 browser(),
211 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), 233 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false),
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 ->AddObserver(&observer); 489 ->AddObserver(&observer);
468 base::RunLoop run_loop; 490 base::RunLoop run_loop;
469 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) 491 EXPECT_CALL(observer, OnUntrustedLoginUIShown())
470 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 492 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
471 493
472 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); 494 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password");
473 run_loop.Run(); 495 run_loop.Run();
474 base::MessageLoop::current()->RunUntilIdle(); 496 base::MessageLoop::current()->RunUntilIdle();
475 } 497 }
476 #endif // OS_CHROMEOS 498 #endif // OS_CHROMEOS
OLDNEW
« chrome/browser/profiles/profile_impl_io_data.cc ('K') | « chrome/browser/profiles/profile_io_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698