Chromium Code Reviews| Index: chrome/browser/ssl/ssl_browser_tests.cc |
| diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc |
| index 220ed12ec9dba438ec89d6416eafa89602a7bad8..a6f4783073b6e43f16e7eaee16aa0242b796d43a 100644 |
| --- a/chrome/browser/ssl/ssl_browser_tests.cc |
| +++ b/chrome/browser/ssl/ssl_browser_tests.cc |
| @@ -116,9 +116,10 @@ class SSLUITest : public InProcessBrowserTest { |
| void ProceedThroughInterstitial(TabContents* tab) { |
| InterstitialPage* interstitial_page = tab->interstitial_page(); |
| ASSERT_TRUE(interstitial_page); |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| interstitial_page->Proceed(); |
| // Wait for the navigation to be done. |
|
Paweł Hajdan Jr.
2011/07/25 18:06:13
nit: Nuke comments like this, I think it's redunda
Greg Billock
2011/08/02 18:11:33
Done.
|
| - ui_test_utils::WaitForNavigation(&(tab->controller())); |
| + observer.Wait(); |
| } |
| static bool GetFilePathWithHostAndPortReplacement( |
| @@ -404,8 +405,11 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestHTTPSExpiredCertAndGoForward) { |
| ASSERT_TRUE(entry2); |
| // Now go back so that a page is in the forward history. |
| - tab->controller().GoBack(); |
| - ui_test_utils::WaitForNavigation(&(tab->controller())); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + tab->controller().GoBack(); |
| + observer.Wait(); |
| + } |
| ASSERT_TRUE(tab->controller().CanGoForward()); |
| NavigationEntry* entry3 = tab->controller().GetActiveEntry(); |
| ASSERT_TRUE(entry1 == entry3); |
| @@ -417,8 +421,11 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestHTTPSExpiredCertAndGoForward) { |
| true); // Interstitial showing |
| // Simulate user clicking and holding on forward button. |
| - tab->controller().GoToOffset(1); |
| - ui_test_utils::WaitForNavigation(&(tab->controller())); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + tab->controller().GoToOffset(1); |
| + observer.Wait(); |
| + } |
| // We should be showing the second good page. |
| EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
| @@ -582,9 +589,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { |
| params.disposition = NEW_FOREGROUND_TAB; |
| params.tabstrip_index = 0; |
| params.source_contents = tab1; |
| + ui_test_utils::WindowedNotificationObserver observer(*browser()); |
| browser::Navigate(¶ms); |
| TabContentsWrapper* tab2 = params.target_contents; |
| - ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| + observer.Wait(); |
| // The new tab has insecure content. |
| CheckAuthenticatedState(tab2->tab_contents(), true); |
| @@ -619,9 +627,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { |
| browser::NavigateParams params(browser(), url, PageTransition::TYPED); |
| params.disposition = NEW_FOREGROUND_TAB; |
| params.source_contents = tab1; |
| + ui_test_utils::WindowedNotificationObserver observer(*browser()); |
| browser::Navigate(¶ms); |
| TabContentsWrapper* tab2 = params.target_contents; |
| - ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| + observer.Wait(); |
| // The new tab has insecure content. |
| CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); |
| @@ -792,9 +801,9 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { |
| // Let's add another tab to make sure the browser does not exit when we close |
| // the first tab. |
| GURL url = test_server()->GetURL("files/ssl/google.html"); |
| - TabContentsWrapper* tab2 = |
| - browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
| - ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| + ui_test_utils::WindowedNotificationObserver observer(*browser()); |
| + browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
| + observer.Wait(); |
| // Close the first tab. |
| browser()->CloseTabContents(tab1); |
| @@ -937,23 +946,29 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestGoodFrameNavigation) { |
| bool success = false; |
| // Now navigate inside the frame. |
| - EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| - tab->render_view_host(), std::wstring(), |
| - L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| - &success)); |
| - EXPECT_TRUE(success); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + tab->render_view_host(), std::wstring(), |
| + L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| + &success)); |
| + EXPECT_TRUE(success); |
| + observer.Wait(); |
| + } |
| // We should still be fine. |
| CheckAuthenticatedState(tab, false); |
| // Now let's hit a bad page. |
| - EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| - tab->render_view_host(), std::wstring(), |
| - L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| - &success)); |
| - EXPECT_TRUE(success); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + tab->render_view_host(), std::wstring(), |
| + L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| + &success)); |
| + EXPECT_TRUE(success); |
| + observer.Wait(); |
| + } |
| // The security style should still be secure. |
| CheckAuthenticatedState(tab, false); |
| @@ -969,24 +984,33 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestGoodFrameNavigation) { |
| EXPECT_FALSE(is_content_evil); |
| // Now go back, our state should still be OK. |
| - tab->controller().GoBack(); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + tab->controller().GoBack(); |
| + observer.Wait(); |
| + } |
| CheckAuthenticatedState(tab, false); |
| // Navigate to a page served over HTTP. |
| - EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| - tab->render_view_host(), std::wstring(), |
| - L"window.domAutomationController.send(clickLink('HTTPLink'));", |
| - &success)); |
| - EXPECT_TRUE(success); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + tab->render_view_host(), std::wstring(), |
| + L"window.domAutomationController.send(clickLink('HTTPLink'));", |
| + &success)); |
| + EXPECT_TRUE(success); |
| + observer.Wait(); |
| + } |
| // Our state should be insecure. |
| CheckAuthenticatedState(tab, true); |
| // Go back, our state should be unchanged. |
| - tab->controller().GoBack(); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + tab->controller().GoBack(); |
| + observer.Wait(); |
| + } |
| CheckAuthenticatedState(tab, true); |
| } |
| @@ -1013,12 +1037,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { |
| // Navigate to a good frame. |
| bool success = false; |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| tab->render_view_host(), std::wstring(), |
| L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| &success)); |
| EXPECT_TRUE(success); |
|
Paweł Hajdan Jr.
2011/07/25 18:06:13
I think this should be an ASSERT to avoid hangs. A
Greg Billock
2011/08/02 18:11:33
OK, I think I got them all.
|
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + observer.Wait(); |
| // We should still be authentication broken. |
| CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
| @@ -1045,24 +1070,31 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { |
| CheckUnauthenticatedState(tab); |
| // Now navigate inside the frame to a secure HTTPS frame. |
| - bool success = false; |
| - EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| - tab->render_view_host(), std::wstring(), |
| - L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| - &success)); |
| - EXPECT_TRUE(success); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + bool success = false; |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + tab->render_view_host(), std::wstring(), |
| + L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| + &success)); |
| + EXPECT_TRUE(success); |
| + observer.Wait(); |
| + } |
| // We should still be unauthenticated. |
| CheckUnauthenticatedState(tab); |
| // Now navigate to a bad HTTPS frame. |
| - EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| - tab->render_view_host(), std::wstring(), |
| - L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| - &success)); |
| - EXPECT_TRUE(success); |
| - ui_test_utils::WaitForNavigation(&tab->controller()); |
| + { |
| + bool success = false; |
| + ui_test_utils::WindowedNotificationObserver observer(tab->controller()); |
| + EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + tab->render_view_host(), std::wstring(), |
| + L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| + &success)); |
| + EXPECT_TRUE(success); |
| + observer.Wait(); |
| + } |
| // State should not have changed. |
| CheckUnauthenticatedState(tab); |