diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 17:45:05 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 17:45:05 +0000 |
commit | ea7da3ced5cc74eb581d0d7f87f21320b4fae920 (patch) | |
tree | 70e347d6b4148cc15dc74e74b44406b7d9fe09be | |
parent | 303ba0ba0280b7bc5da957083b75a1f5142ee2bd (diff) | |
download | chromium_src-ea7da3ced5cc74eb581d0d7f87f21320b4fae920.zip chromium_src-ea7da3ced5cc74eb581d0d7f87f21320b4fae920.tar.gz chromium_src-ea7da3ced5cc74eb581d0d7f87f21320b4fae920.tar.bz2 |
Check if the test server started successfully before using it.
Prevents a crash in unit tests.
http://crbug.com/9644
Review URL: http://codereview.chromium.org/117002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16621 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ssl/ssl_uitest.cc | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/chrome/browser/ssl/ssl_uitest.cc b/chrome/browser/ssl/ssl_uitest.cc index 02d5d23..33af008 100644 --- a/chrome/browser/ssl/ssl_uitest.cc +++ b/chrome/browser/ssl/ssl_uitest.cc @@ -41,16 +41,31 @@ class SSLUITest : public UITest { EXPECT_TRUE(browser_proxy->AppendTab(url)); } + // Before using returned value you should check that the assertion below + // didn't fail. To do so, use HasFailure(). scoped_refptr<HTTPTestServer> PlainServer() { - return HTTPTestServer::CreateServer(kDocRoot, NULL); + scoped_refptr<HTTPTestServer> server( + HTTPTestServer::CreateServer(kDocRoot, NULL)); + EXPECT_TRUE(server.get()); + return server; } + // Before using returned value you should check that the assertion below + // didn't fail. To do so, use HasFailure(). scoped_refptr<HTTPSTestServer> GoodCertServer() { - return HTTPSTestServer::CreateGoodServer(kDocRoot); + scoped_refptr<HTTPSTestServer> server( + HTTPSTestServer::CreateGoodServer(kDocRoot)); + EXPECT_TRUE(server.get()); + return server; } + // Before using returned value you should check that the assertion below + // didn't fail. To do so, use HasFailure(). scoped_refptr<HTTPSTestServer> BadCertServer() { - return HTTPSTestServer::CreateExpiredServer(kDocRoot); + scoped_refptr<HTTPSTestServer> server( + HTTPSTestServer::CreateExpiredServer(kDocRoot)); + EXPECT_TRUE(server.get()); + return server; } protected: @@ -62,6 +77,8 @@ class SSLUITest : public UITest { // Visits a regular page over http. TEST_F(SSLUITest, TestHTTP) { scoped_refptr<HTTPTestServer> server = PlainServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), server->TestServerPageW(L"files/ssl/google.html")); @@ -85,6 +102,8 @@ TEST_F(SSLUITest, TestHTTP) { TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab( @@ -105,6 +124,8 @@ TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { // Visits a page over OK https: TEST_F(SSLUITest, TestOKHTTPS) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), https_server->TestServerPageW(L"files/ssl/google.html")); @@ -126,6 +147,8 @@ TEST_F(SSLUITest, TestOKHTTPS) { // Visits a page with https error and proceed: TEST_F(SSLUITest, TestHTTPSExpiredCertAndProceed) { scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), bad_https_server->TestServerPageW(L"files/ssl/google.html")); @@ -161,6 +184,8 @@ TEST_F(SSLUITest, TestHTTPSExpiredCertAndDontProceed) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); // First navigate to an OK page. @@ -221,6 +246,8 @@ TEST_F(SSLUITest, TestHTTPSExpiredCertAndDontProceed) { TEST_F(SSLUITest, TestMixedContents) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; // Load a page with mixed-content, the default behavior is to show the mixed // content. @@ -248,6 +275,8 @@ TEST_F(SSLUITest, TestMixedContents) { TEST_F(SSLUITest, TestMixedContentsFilterAll) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; // Now select the block mixed-content pref and reload the page. scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); @@ -314,6 +343,8 @@ TEST_F(SSLUITest, TestMixedContentsFilterAll) { TEST_F(SSLUITest, TestMixedContentsRandomizeHash) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab( @@ -340,6 +371,8 @@ TEST_F(SSLUITest, TestMixedContentsRandomizeHash) { TEST_F(SSLUITest, TestUnsafeContents) { scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), @@ -390,6 +423,8 @@ TEST_F(SSLUITest, TestUnsafeContents) { TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), https_server->TestServerPageW( @@ -430,6 +465,8 @@ TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) { TEST_F(SSLUITest, TestMixedContentsTwoTabs) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab1(GetActiveTabProxy()); NavigateTab( @@ -481,6 +518,8 @@ TEST_F(SSLUITest, TestMixedContentsTwoTabs) { TEST_F(SSLUITest, TestCachedMixedContents) { scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); scoped_refptr<HTTPTestServer> http_server = PlainServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), http_server->TestServerPageW( @@ -588,6 +627,8 @@ TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) { // Test that navigating to a #ref does not change a bad security state. TEST_F(SSLUITest, TestRefNavigation) { scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab( tab.get(), @@ -633,6 +674,8 @@ TEST_F(SSLUITest, TestRefNavigation) { TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), @@ -658,6 +701,8 @@ TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) { scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); GURL url1 = bad_https_server->TestServerPageW(L"server-redirect?"); @@ -691,6 +736,8 @@ TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) { TEST_F(SSLUITest, TestRedirectGoodToBadHTTPS) { scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); GURL url1 = good_https_server->TestServerPageW(L"server-redirect?"); @@ -720,6 +767,8 @@ TEST_F(SSLUITest, TestRedirectHTTPToHTTPS) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; // HTTP redirects to good HTTPS. scoped_ptr<TabProxy> tab(GetActiveTabProxy()); @@ -762,6 +811,8 @@ TEST_F(SSLUITest, TestRedirectHTTPToHTTPS) { TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); GURL https_url = https_server->TestServerPageW(L"server-redirect?"); @@ -819,6 +870,8 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), @@ -914,6 +967,8 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { TEST_F(SSLUITest, TestBadFrameNavigation) { scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), @@ -957,6 +1012,8 @@ TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { scoped_refptr<HTTPTestServer> http_server = PlainServer(); scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); + if (HasFailure()) + return; scoped_ptr<TabProxy> tab(GetActiveTabProxy()); NavigateTab(tab.get(), |