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

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 11085039: WebSocket test server migration on browser_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retain std::string reference for GURL::Replacements Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
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 d87feeb16e70005e3d024dcaf742ccd1b534df19..f3ceffef2560503052cfaf41835d4578034152ce 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -47,6 +47,7 @@ using content::SSLStatus;
using content::WebContents;
const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
+const FilePath::CharType kWsRoot[] = FILE_PATH_LITERAL("net/data/websocket");
namespace {
@@ -83,8 +84,6 @@ class ProvisionalLoadWaiter : public content::WebContentsObserver {
} // namespace
class SSLUITest : public InProcessBrowserTest {
- typedef net::TestServer::SSLOptions SSLOptions;
-
public:
SSLUITest()
: https_server_(net::TestServer::TYPE_HTTPS,
@@ -95,7 +94,10 @@ class SSLUITest : public InProcessBrowserTest {
FilePath(kDocRoot)),
https_server_mismatched_(net::TestServer::TYPE_HTTPS,
SSLOptions(SSLOptions::CERT_MISMATCHED_NAME),
- FilePath(kDocRoot)) {}
+ FilePath(kDocRoot)),
+ wss_server_expired_(net::TestServer::TYPE_WSS,
+ SSLOptions(SSLOptions::CERT_EXPIRED),
+ FilePath(kWsRoot)) {}
virtual void SetUpCommandLine(CommandLine* command_line) {
// Browser will both run and display insecure content.
@@ -288,6 +290,10 @@ class SSLUITest : public InProcessBrowserTest {
net::TestServer https_server_;
net::TestServer https_server_expired_;
net::TestServer https_server_mismatched_;
+ net::TestServer wss_server_expired_;
+
+ protected:
+ typedef net::TestServer::SSLOptions SSLOptions;
private:
DISALLOW_COPY_AND_ASSIGN(SSLUITest);
@@ -542,7 +548,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) {
// response from UI thread.
IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
ASSERT_TRUE(test_server()->Start());
- ASSERT_TRUE(https_server_expired_.Start());
+ ASSERT_TRUE(wss_server_expired_.Start());
// Setup page title observer.
WebContents* tab = chrome::GetActiveWebContents(browser());
@@ -552,11 +558,11 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
// Create GURLs to test pages.
std::string masterUrlPath = StringPrintf("%s?%d",
test_server()->GetURL("files/ssl/wss_close.html").spec().c_str(),
- https_server_expired_.host_port_pair().port());
+ wss_server_expired_.host_port_pair().port());
GURL masterUrl(masterUrlPath);
std::string slaveUrlPath = StringPrintf("%s?%d",
test_server()->GetURL("files/ssl/wss_close_slave.html").spec().c_str(),
- https_server_expired_.host_port_pair().port());
+ wss_server_expired_.host_port_pair().port());
GURL slaveUrl(slaveUrlPath);
// Create tabs and visit pages which keep on creating wss connections.
@@ -584,15 +590,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
// share certificates policy with HTTPS correcly.
IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
ASSERT_TRUE(test_server()->Start());
- ASSERT_TRUE(https_server_expired_.Start());
-
- // Start pywebsocket with TLS.
- content::TestWebSocketServer wss_server;
- int port = wss_server.UseRandomPort();
- wss_server.UseTLS();
- FilePath wss_root_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir));
- ASSERT_TRUE(wss_server.Start(wss_root_dir));
+ ASSERT_TRUE(wss_server_expired_.Start());
// Setup page title observer.
WebContents* tab = chrome::GetActiveWebContents(browser());
@@ -600,11 +598,15 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Visit bad HTTPS page.
- std::string urlPath =
- StringPrintf("%s%d%s", "https://localhost:", port, "/ws.html");
- ui_test_utils::NavigateToURL(browser(), GURL(urlPath));
- CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
- false, true); // Interstitial showing
+ std::string scheme("https");
+ GURL::Replacements replacements;
+ replacements.SetSchemeStr(scheme);
+ ui_test_utils::NavigateToURL(
+ browser(),
+ wss_server_expired_.GetURL(
+ "connect_check.html").ReplaceComponents(replacements));
+ CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
+ true); // Interstitial showing
// Proceed anyway.
ProceedThroughInterstitial(tab);
@@ -1494,15 +1496,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockRunningInsecureContent) {
// interstitial page showing.
IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreCertErrors, TestWSS) {
ASSERT_TRUE(test_server()->Start());
- ASSERT_TRUE(https_server_expired_.Start());
-
- // Start pywebsocket with TLS.
- content::TestWebSocketServer wss_server;
- int port = wss_server.UseRandomPort();
- wss_server.UseTLS();
- FilePath wss_root_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir));
- ASSERT_TRUE(wss_server.Start(wss_root_dir));
+ ASSERT_TRUE(wss_server_expired_.Start());
// Setup page title observer.
WebContents* tab = chrome::GetActiveWebContents(browser());
@@ -1510,9 +1504,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreCertErrors, TestWSS) {
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Visit bad HTTPS page.
- std::string url_path =
- StringPrintf("%s%d%s", "https://localhost:", port, "/ws.html");
- ui_test_utils::NavigateToURL(browser(), GURL(url_path));
+ std::string scheme("https");
+ GURL::Replacements replacements;
+ replacements.SetSchemeStr(scheme);
+ ui_test_utils::NavigateToURL(
+ browser(),
+ wss_server_expired_.GetURL(
+ "connect_check.html").ReplaceComponents(replacements));
// We shouldn't have an interstitial page showing here.

Powered by Google App Engine
This is Rietveld 408576698