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 <algorithm> | 5 #include <algorithm> |
6 #include <list> | 6 #include <list> |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 // Test that the login interstitial isn't proceeding itself or any other | 1426 // Test that the login interstitial isn't proceeding itself or any other |
1427 // interstitial. If this test becomes flaky, it's likely that the logic that | 1427 // interstitial. If this test becomes flaky, it's likely that the logic that |
1428 // prevents the tested scenario from happening got broken, rather than the test | 1428 // prevents the tested scenario from happening got broken, rather than the test |
1429 // itself. | 1429 // itself. |
1430 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | 1430 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, |
1431 ShouldNotProceedExistingInterstitial) { | 1431 ShouldNotProceedExistingInterstitial) { |
1432 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 1432 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
1433 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 1433 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
1434 ASSERT_TRUE(https_server.Start()); | 1434 ASSERT_TRUE(https_server.Start()); |
1435 | 1435 |
1436 const char* kTestPage = "files/login/load_iframe_from_b.html"; | 1436 const char* kTestPage = "/login/load_iframe_from_b.html"; |
1437 | 1437 |
1438 host_resolver()->AddRule("www.b.com", "127.0.0.1"); | 1438 host_resolver()->AddRule("www.b.com", "127.0.0.1"); |
1439 ASSERT_TRUE(test_server()->Start()); | 1439 ASSERT_TRUE(embedded_test_server()->Start()); |
1440 | 1440 |
1441 content::WebContents* contents = | 1441 content::WebContents* contents = |
1442 browser()->tab_strip_model()->GetActiveWebContents(); | 1442 browser()->tab_strip_model()->GetActiveWebContents(); |
1443 NavigationController* controller = &contents->GetController(); | 1443 NavigationController* controller = &contents->GetController(); |
1444 LoginPromptBrowserTestObserver observer; | 1444 LoginPromptBrowserTestObserver observer; |
1445 observer.Register(content::Source<NavigationController>(controller)); | 1445 observer.Register(content::Source<NavigationController>(controller)); |
1446 | 1446 |
1447 // Load a page that has a cross-domain iframe authentication. This should | 1447 // Load a page that has a cross-domain iframe authentication. This should |
1448 // trigger a login prompt but no login interstitial. | 1448 // trigger a login prompt but no login interstitial. |
1449 GURL test_page = test_server()->GetURL(kTestPage); | 1449 GURL test_page = embedded_test_server()->GetURL(kTestPage); |
1450 GURL broken_ssl_page = https_server.GetURL("/"); | 1450 GURL broken_ssl_page = https_server.GetURL("/"); |
1451 ASSERT_EQ("127.0.0.1", test_page.host()); | 1451 ASSERT_EQ("127.0.0.1", test_page.host()); |
1452 WindowedAuthNeededObserver auth_needed_waiter(controller); | 1452 WindowedAuthNeededObserver auth_needed_waiter(controller); |
1453 browser()->OpenURL(OpenURLParams(test_page, Referrer(), CURRENT_TAB, | 1453 browser()->OpenURL(OpenURLParams(test_page, Referrer(), CURRENT_TAB, |
1454 ui::PAGE_TRANSITION_TYPED, false)); | 1454 ui::PAGE_TRANSITION_TYPED, false)); |
1455 auth_needed_waiter.Wait(); | 1455 auth_needed_waiter.Wait(); |
1456 ASSERT_EQ(1u, observer.handlers().size()); | 1456 ASSERT_EQ(1u, observer.handlers().size()); |
1457 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 1457 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
1458 | 1458 |
1459 // Redirect to a broken SSL page. This redirect should not accidentally | 1459 // Redirect to a broken SSL page. This redirect should not accidentally |
1460 // proceed through the SSL interstitial. | 1460 // proceed through the SSL interstitial. |
1461 WindowedAuthCancelledObserver auth_cancelled_waiter(controller); | 1461 WindowedAuthCancelledObserver auth_cancelled_waiter(controller); |
1462 EXPECT_TRUE(content::ExecuteScript( | 1462 EXPECT_TRUE(content::ExecuteScript( |
1463 browser()->tab_strip_model()->GetActiveWebContents(), | 1463 browser()->tab_strip_model()->GetActiveWebContents(), |
1464 std::string("window.location = '") + broken_ssl_page.spec() + "'")); | 1464 std::string("window.location = '") + broken_ssl_page.spec() + "'")); |
1465 content::WaitForInterstitialAttach(contents); | 1465 content::WaitForInterstitialAttach(contents); |
1466 auth_cancelled_waiter.Wait(); | 1466 auth_cancelled_waiter.Wait(); |
1467 | 1467 |
1468 // If the interstitial was accidentally clicked through, this wait may time | 1468 // If the interstitial was accidentally clicked through, this wait may time |
1469 // out. | 1469 // out. |
1470 EXPECT_TRUE( | 1470 EXPECT_TRUE( |
1471 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); | 1471 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); |
1472 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1472 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
1473 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() | 1473 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() |
1474 ->GetDelegateForTesting() | 1474 ->GetDelegateForTesting() |
1475 ->GetTypeForTesting()); | 1475 ->GetTypeForTesting()); |
1476 } | 1476 } |
1477 | 1477 |
1478 } // namespace | 1478 } // namespace |
OLD | NEW |