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

Side by Side Diff: chrome/browser/ui/login/login_prompt_uitest.cc

Issue 8305004: Fix HTTP auth multi-profile handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/login/login_prompt_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/net/url_fixer_upper.h" 9 #include "chrome/browser/net/url_fixer_upper.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 wstring title; 129 wstring title;
130 EXPECT_TRUE(basic_tab->GetTabTitle(&title)); 130 EXPECT_TRUE(basic_tab->GetTabTitle(&title));
131 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_), 131 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_),
132 WideToUTF16Hack(title)); 132 WideToUTF16Hack(title));
133 133
134 EXPECT_TRUE(digest_tab->GetTabTitle(&title)); 134 EXPECT_TRUE(digest_tab->GetTabTitle(&title));
135 EXPECT_EQ(ExpectedTitleFromAuth(username_digest_, password_), 135 EXPECT_EQ(ExpectedTitleFromAuth(username_digest_, password_),
136 WideToUTF16Hack(title)); 136 WideToUTF16Hack(title));
137 } 137 }
138
139 // If multiple tabs are looking for the same auth, the user should only have to
140 // enter it once.
141 TEST_F(LoginPromptTest, SupplyRedundantAuths) {
142 ASSERT_TRUE(test_server_.Start());
143
144 scoped_refptr<TabProxy> basic_tab1(GetActiveTab());
145 ASSERT_TRUE(basic_tab1.get());
146 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED,
147 basic_tab1->NavigateToURL(test_server_.GetURL("auth-basic/1")));
148 EXPECT_TRUE(basic_tab1->NeedsAuth());
149
150 AppendTab(GURL(chrome::kAboutBlankURL));
151 scoped_refptr<TabProxy> basic_tab2(GetActiveTab());
152 ASSERT_TRUE(basic_tab2.get());
153 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED,
154 basic_tab2->NavigateToURL(test_server_.GetURL("auth-basic/2")));
155 EXPECT_TRUE(basic_tab2->NeedsAuth());
156
157 // Set the auth in only one of the tabs (but wait for the other to load).
158 int64 last_navigation_time;
159 ASSERT_TRUE(basic_tab2->GetLastNavigationTime(&last_navigation_time));
160 EXPECT_TRUE(basic_tab1->SetAuth(UTF16ToWideHack(username_basic_),
161 UTF16ToWideHack(password_)));
162 EXPECT_TRUE(basic_tab2->WaitForNavigation(last_navigation_time));
163
164 // Now both tabs have loaded.
165 wstring title1;
166 EXPECT_TRUE(basic_tab1->GetTabTitle(&title1));
167 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_),
168 WideToUTF16Hack(title1));
169 wstring title2;
170 EXPECT_TRUE(basic_tab2->GetTabTitle(&title2));
171 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_),
172 WideToUTF16Hack(title2));
173 }
174
175 // If multiple tabs are looking for the same auth, and one is cancelled, the
176 // other should be cancelled as well.
177 TEST_F(LoginPromptTest, CancelRedundantAuths) {
178 ASSERT_TRUE(test_server_.Start());
179
180 scoped_refptr<TabProxy> basic_tab1(GetActiveTab());
181 ASSERT_TRUE(basic_tab1.get());
182 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED,
183 basic_tab1->NavigateToURL(test_server_.GetURL("auth-basic/1")));
184 EXPECT_TRUE(basic_tab1->NeedsAuth());
185
186 AppendTab(GURL(chrome::kAboutBlankURL));
187 scoped_refptr<TabProxy> basic_tab2(GetActiveTab());
188 ASSERT_TRUE(basic_tab2.get());
189 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED,
190 basic_tab2->NavigateToURL(test_server_.GetURL("auth-basic/2")));
191 EXPECT_TRUE(basic_tab2->NeedsAuth());
192
193 // Cancel the auth in only one of the tabs (but wait for the other to load).
194 int64 last_navigation_time;
195 ASSERT_TRUE(basic_tab2->GetLastNavigationTime(&last_navigation_time));
196 EXPECT_TRUE(basic_tab1->CancelAuth());
197 EXPECT_TRUE(basic_tab2->WaitForNavigation(last_navigation_time));
198
199 // Now both tabs have been denied.
200 wstring title1;
201 EXPECT_TRUE(basic_tab1->GetTabTitle(&title1));
202 EXPECT_EQ(L"Denied: no auth", title1);
203 wstring title2;
204 EXPECT_TRUE(basic_tab2->GetTabTitle(&title2));
205 EXPECT_EQ(L"Denied: no auth", title2);
206 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/login/login_prompt_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698