Index: chrome/browser/login_prompt_uitest.cc |
=================================================================== |
--- chrome/browser/login_prompt_uitest.cc (revision 42470) |
+++ chrome/browser/login_prompt_uitest.cc (working copy) |
@@ -173,3 +173,67 @@ |
EXPECT_FALSE(tab->NeedsAuth()); |
EXPECT_EQ(L"Denied: no auth", GetActiveTabTitle()); |
} |
+ |
+// If multiple tabs are looking for the same auth, the user should only have to |
+// enter it once (http://crbug.com/8914). |
+TEST_F(LoginPromptTest, SupplyRedundantAuths) { |
+ scoped_refptr<HTTPTestServer> server = |
+ HTTPTestServer::CreateServer(kDocRoot, NULL); |
+ ASSERT_TRUE(NULL != server.get()); |
+ |
+ scoped_refptr<TabProxy> basic_tab1(GetActiveTab()); |
+ ASSERT_TRUE(basic_tab1.get()); |
+ NavigateTab(basic_tab1.get(), server->TestServerPageW(L"auth-basic/1")); |
+ |
+ AppendTab(GURL(chrome::kAboutBlankURL)); |
+ scoped_refptr<TabProxy> basic_tab2(GetActiveTab()); |
+ ASSERT_TRUE(basic_tab2.get()); |
+ NavigateTab(basic_tab2.get(), server->TestServerPageW(L"auth-basic/2")); |
+ |
+ // Both tabs start out needing auth. |
+ EXPECT_TRUE(basic_tab1->NeedsAuth()); |
+ EXPECT_TRUE(basic_tab2->NeedsAuth()); |
+ |
+ // Set the auth in only one of the tabs. |
+ EXPECT_TRUE(basic_tab2->SetAuth(username_basic_, password_)); |
+ |
+ // Now both tabs have loaded. |
+ wstring title1; |
+ EXPECT_TRUE(basic_tab1->GetTabTitle(&title1)); |
+ EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_), title1); |
+ wstring title2; |
+ EXPECT_TRUE(basic_tab2->GetTabTitle(&title2)); |
+ EXPECT_EQ(ExpectedTitleFromAuth(username_basic_, password_), title2); |
+} |
+ |
+// If multiple tabs are looking for the same auth, and one is cancelled, the |
+// other should be cancelled as well. |
+TEST_F(LoginPromptTest, CancelRedundantAuths) { |
+ scoped_refptr<HTTPTestServer> server = |
+ HTTPTestServer::CreateServer(kDocRoot, NULL); |
+ ASSERT_TRUE(NULL != server.get()); |
+ |
+ scoped_refptr<TabProxy> basic_tab1(GetActiveTab()); |
+ ASSERT_TRUE(basic_tab1.get()); |
+ NavigateTab(basic_tab1.get(), server->TestServerPageW(L"auth-basic/1")); |
+ |
+ AppendTab(GURL(chrome::kAboutBlankURL)); |
+ scoped_refptr<TabProxy> basic_tab2(GetActiveTab()); |
+ ASSERT_TRUE(basic_tab2.get()); |
+ NavigateTab(basic_tab2.get(), server->TestServerPageW(L"auth-basic/2")); |
+ |
+ // Both tabs start out needing auth. |
+ EXPECT_TRUE(basic_tab1->NeedsAuth()); |
+ EXPECT_TRUE(basic_tab2->NeedsAuth()); |
+ |
+ // Cancel the auth in only one of the tabs. |
+ EXPECT_TRUE(basic_tab2->CancelAuth()); |
+ |
+ // Now both tabs have been denied. |
+ wstring title1; |
+ EXPECT_TRUE(basic_tab1->GetTabTitle(&title1)); |
+ EXPECT_EQ(L"Denied: no auth", title1); |
+ wstring title2; |
+ EXPECT_TRUE(basic_tab2->GetTabTitle(&title2)); |
+ EXPECT_EQ(L"Denied: no auth", title2); |
+} |