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

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

Issue 1528012: Notify all active login prompts when one login prompt is submitted. This allo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/login_prompt_mac.mm ('k') | chrome/browser/login_prompt_win.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/net/url_fixer_upper.h" 7 #include "chrome/browser/net/url_fixer_upper.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/automation/tab_proxy.h" 10 #include "chrome/test/automation/tab_proxy.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_TRUE(tab->GoForward()); // should bring us to 'c' 158 EXPECT_TRUE(tab->GoForward()); // should bring us to 'c'
159 EXPECT_FALSE(tab->NeedsAuth()); 159 EXPECT_FALSE(tab->NeedsAuth());
160 160
161 // Now test that cancelling works as expected. 161 // Now test that cancelling works as expected.
162 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"auth-basic"))); 162 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"auth-basic")));
163 EXPECT_TRUE(tab->NeedsAuth()); 163 EXPECT_TRUE(tab->NeedsAuth());
164 EXPECT_TRUE(tab->CancelAuth()); 164 EXPECT_TRUE(tab->CancelAuth());
165 EXPECT_FALSE(tab->NeedsAuth()); 165 EXPECT_FALSE(tab->NeedsAuth());
166 EXPECT_EQ(L"Denied: no auth", GetActiveTabTitle()); 166 EXPECT_EQ(L"Denied: no auth", GetActiveTabTitle());
167 } 167 }
168
169 // If multiple tabs are looking for the same auth, the user should only have to
170 // enter it once (http://crbug.com/8914).
171 TEST_F(LoginPromptTest, SupplyRedundantAuths) {
172 scoped_refptr<HTTPTestServer> server =
173 HTTPTestServer::CreateServer(kDocRoot, NULL);
174 ASSERT_TRUE(NULL != server.get());
175
176 scoped_refptr<TabProxy> basic_tab1(GetActiveTab());
177 ASSERT_TRUE(basic_tab1.get());
178 ASSERT_TRUE(
179 basic_tab1->NavigateToURL(server->TestServerPageW(L"auth-basic/1")));
180 EXPECT_TRUE(basic_tab1->NeedsAuth());
181
182 AppendTab(GURL(chrome::kAboutBlankURL));
183 scoped_refptr<TabProxy> basic_tab2(GetActiveTab());
184 ASSERT_TRUE(basic_tab2.get());
185 ASSERT_TRUE(
186 basic_tab2->NavigateToURL(server->TestServerPageW(L"auth-basic/2")));
187 EXPECT_TRUE(basic_tab2->NeedsAuth());
188
189 // Set the auth in only one of the tabs (but wait for the other to load).
190 int64 last_navigation_time;
191 ASSERT_TRUE(basic_tab2->GetLastNavigationTime(&last_navigation_time));
192 EXPECT_TRUE(basic_tab1->SetAuth(username_basic_, password_));
193 EXPECT_TRUE(basic_tab2->WaitForNavigation(last_navigation_time));
194
195 // Now both tabs have loaded.
196 wstring title1;
197 EXPECT_TRUE(basic_tab1->GetTabTitle(&title1));
198 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_), title1);
199 wstring title2;
200 EXPECT_TRUE(basic_tab2->GetTabTitle(&title2));
201 EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_), title2);
202 }
203
204 // If multiple tabs are looking for the same auth, and one is cancelled, the
205 // other should be cancelled as well.
206 TEST_F(LoginPromptTest, CancelRedundantAuths) {
207 scoped_refptr<HTTPTestServer> server =
208 HTTPTestServer::CreateServer(kDocRoot, NULL);
209 ASSERT_TRUE(NULL != server.get());
210
211 scoped_refptr<TabProxy> basic_tab1(GetActiveTab());
212 ASSERT_TRUE(basic_tab1.get());
213 ASSERT_TRUE(
214 basic_tab1->NavigateToURL(server->TestServerPageW(L"auth-basic/1")));
215 EXPECT_TRUE(basic_tab1->NeedsAuth());
216
217 AppendTab(GURL(chrome::kAboutBlankURL));
218 scoped_refptr<TabProxy> basic_tab2(GetActiveTab());
219 ASSERT_TRUE(basic_tab2.get());
220 ASSERT_TRUE(
221 basic_tab2->NavigateToURL(server->TestServerPageW(L"auth-basic/2")));
222 EXPECT_TRUE(basic_tab2->NeedsAuth());
223
224 // Cancel the auth in only one of the tabs (but wait for the other to load).
225 int64 last_navigation_time;
226 ASSERT_TRUE(basic_tab2->GetLastNavigationTime(&last_navigation_time));
227 EXPECT_TRUE(basic_tab1->CancelAuth());
228 EXPECT_TRUE(basic_tab2->WaitForNavigation(last_navigation_time));
229
230 // Now both tabs have been denied.
231 wstring title1;
232 EXPECT_TRUE(basic_tab1->GetTabTitle(&title1));
233 EXPECT_EQ(L"Denied: no auth", title1);
234 wstring title2;
235 EXPECT_TRUE(basic_tab2->GetTabTitle(&title2));
236 EXPECT_EQ(L"Denied: no auth", title2);
237 }
OLDNEW
« no previous file with comments | « chrome/browser/login_prompt_mac.mm ('k') | chrome/browser/login_prompt_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698