diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 02:37:22 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 02:37:22 +0000 |
commit | deb27ae20cd7d59fba58ad530a72b2dbf8a099ee (patch) | |
tree | 7c751a2197b767521e89849abd2cb35e874238d0 /net | |
parent | ce7c39483b5e113ec862a231580684f35268c227 (diff) | |
download | chromium_src-deb27ae20cd7d59fba58ad530a72b2dbf8a099ee.zip chromium_src-deb27ae20cd7d59fba58ad530a72b2dbf8a099ee.tar.gz chromium_src-deb27ae20cd7d59fba58ad530a72b2dbf8a099ee.tar.bz2 |
Scrape search definitions from forms that have onsubmit handlers. The scraping is done after submit events are handled by the page DOM so doing this is safe.
Adds test infrastructure for determining that scraping occurs on submit:
- allow testserver to be configured to serve pages from / on the server
- provide a ui test util that navigates and waits for N subsequent redirections/navigations before returning control to the test to handle automated submission
Eric, please review the test server changes.
Scott, please look over everything else.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=13444
Review URL: http://codereview.chromium.org/62145
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/ssl_client_socket_unittest.cc | 6 | ||||
-rw-r--r-- | net/base/ssl_test_util.cc | 8 | ||||
-rw-r--r-- | net/base/ssl_test_util.h | 5 | ||||
-rw-r--r-- | net/tools/testserver/testserver.py | 7 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.h | 27 |
5 files changed, 38 insertions, 15 deletions
diff --git a/net/base/ssl_client_socket_unittest.cc b/net/base/ssl_client_socket_unittest.cc index 7c7b170..2399466 100644 --- a/net/base/ssl_client_socket_unittest.cc +++ b/net/base/ssl_client_socket_unittest.cc @@ -27,21 +27,21 @@ class SSLClientSocketTest : public PlatformTest { void StartOKServer() { bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, server_.kHostName, server_.kOKHTTPSPort, - FilePath(), server_.GetOKCertPath()); + FilePath(), server_.GetOKCertPath(), std::wstring()); ASSERT_TRUE(success); } void StartMismatchedServer() { bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, server_.kMismatchedHostName, server_.kOKHTTPSPort, - FilePath(), server_.GetOKCertPath()); + FilePath(), server_.GetOKCertPath(), std::wstring()); ASSERT_TRUE(success); } void StartExpiredServer() { bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, server_.kHostName, server_.kBadHTTPSPort, - FilePath(), server_.GetExpiredCertPath()); + FilePath(), server_.GetExpiredCertPath(), std::wstring()); ASSERT_TRUE(success); } diff --git a/net/base/ssl_test_util.cc b/net/base/ssl_test_util.cc index 71edb6a..a3fe3b9 100644 --- a/net/base/ssl_test_util.cc +++ b/net/base/ssl_test_util.cc @@ -152,7 +152,8 @@ void TestServerLauncher::SetPythonPath() { bool TestServerLauncher::Start(Protocol protocol, const std::string& host_name, int port, const FilePath& document_root, - const FilePath& cert_path) { + const FilePath& cert_path, + const std::wstring& file_root_url) { if (!cert_path.value().empty()) { if (!LoadTestRootCert()) return false; @@ -198,6 +199,11 @@ bool TestServerLauncher::Start(Protocol protocol, command_line.append(cert_path.ToWStringHack()); command_line.append(L"\""); } + if (!file_root_url.empty()) { + command_line.append(L" --file-root-url=\""); + command_line.append(file_root_url); + command_line.append(L"\""); + } if (!base::LaunchApp(command_line, false, true, &process_handle_)) { LOG(ERROR) << "Failed to launch " << command_line; diff --git a/net/base/ssl_test_util.h b/net/base/ssl_test_util.h index b75453b..54449ee 100644 --- a/net/base/ssl_test_util.h +++ b/net/base/ssl_test_util.h @@ -39,12 +39,15 @@ class TestServerLauncher { // Start src/net/tools/testserver/testserver.py and // ask it to serve the given protocol. // If protocol is HTTP, and cert_path is not empty, serves HTTPS. + // file_root_url specifies the root url on the server that documents will be + // served out of. This is /files/ by default. // Returns true on success, false if files not found or root cert // not trusted. bool Start(Protocol protocol, const std::string& host_name, int port, const FilePath& document_root, - const FilePath& cert_path); + const FilePath& cert_path, + const std::wstring& file_root_url); // Stop the server started by Start(). bool Stop(); diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py index 5784059..9ab77a8 100644 --- a/net/tools/testserver/testserver.py +++ b/net/tools/testserver/testserver.py @@ -565,13 +565,15 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler): """This handler sends the contents of the requested file. Wow, it's like a real webserver!""" - prefix='/files/' + prefix = self.server.file_root_url if not self.path.startswith(prefix): return False file = self.path[len(prefix):] entries = file.split('/'); path = os.path.join(self.server.data_dir, *entries) + if os.path.isdir(path): + path = os.path.join(path, 'index.html') if not os.path.isfile(path): print "File not found " + file + " full path:" + path @@ -1047,6 +1049,7 @@ def main(options, args): print 'HTTP server started on port %d...' % port server.data_dir = MakeDataDir() + server.file_root_url = options.file_root_url MakeDumpDir(server.data_dir) # means FTP Server @@ -1102,6 +1105,8 @@ if __name__ == '__main__': help='Specify that https should be used, specify ' 'the path to the cert containing the private key ' 'the server should use') + option_parser.add_option('', '--file-root-url', default='/files/', + help='Specify a root URL for files served.') options, args = option_parser.parse_args() sys.exit(main(options, args)) diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 88b83a6..e661153 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -260,20 +260,22 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> { bool Start(net::TestServerLauncher::Protocol protocol, const std::string& host_name, int port, const FilePath& document_root, - const FilePath& cert_path) { + const FilePath& cert_path, + const std::wstring& file_root_url) { std::string blank; return Start(protocol, host_name, port, document_root, cert_path, - blank, blank); + file_root_url, blank, blank); } bool Start(net::TestServerLauncher::Protocol protocol, const std::string& host_name, int port, const FilePath& document_root, const FilePath& cert_path, + const std::wstring& file_root_url, const std::string& url_user, const std::string& url_password) { if (!launcher_.Start(protocol, - host_name, port, document_root, cert_path)) + host_name, port, document_root, cert_path, file_root_url)) return false; std::string scheme; @@ -338,13 +340,20 @@ class HTTPTestServer : public BaseTestServer { static scoped_refptr<HTTPTestServer> CreateServer( const std::wstring& document_root, MessageLoop* loop) { + return CreateServerWithFileRootURL(document_root, std::wstring(), loop); + } + + static scoped_refptr<HTTPTestServer> CreateServerWithFileRootURL( + const std::wstring& document_root, + const std::wstring& file_root_url, + MessageLoop* loop) { scoped_refptr<HTTPTestServer> test_server = new HTTPTestServer(); test_server->loop_ = loop; FilePath no_cert; FilePath docroot = FilePath::FromWStringHack(document_root); if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, kDefaultHostName, kHTTPDefaultPort, - docroot, no_cert)) { + docroot, no_cert, file_root_url)) { return NULL; } return test_server; @@ -438,7 +447,7 @@ class HTTPSTestServer : public HTTPTestServer { if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, net::TestServerLauncher::kHostName, net::TestServerLauncher::kOKHTTPSPort, - docroot, certpath)) { + docroot, certpath, std::wstring())) { return NULL; } return test_server; @@ -454,7 +463,7 @@ class HTTPSTestServer : public HTTPTestServer { if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, net::TestServerLauncher::kMismatchedHostName, net::TestServerLauncher::kOKHTTPSPort, - docroot, certpath)) { + docroot, certpath, std::wstring())) { return NULL; } return test_server; @@ -469,7 +478,7 @@ class HTTPSTestServer : public HTTPTestServer { if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, net::TestServerLauncher::kHostName, net::TestServerLauncher::kBadHTTPSPort, - docroot, certpath)) { + docroot, certpath, std::wstring())) { return NULL; } return test_server; @@ -484,7 +493,7 @@ class HTTPSTestServer : public HTTPTestServer { FilePath docroot = FilePath::FromWStringHack(document_root); FilePath certpath = FilePath::FromWStringHack(cert_path); if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, - host_name, port, docroot, certpath)) { + host_name, port, docroot, certpath, std::wstring())) { return NULL; } return test_server; @@ -517,7 +526,7 @@ class FTPTestServer : public BaseTestServer { FilePath docroot = FilePath::FromWStringHack(document_root); FilePath no_cert; if (!test_server->Start(net::TestServerLauncher::ProtoFTP, - kDefaultHostName, kFTPDefaultPort, docroot, no_cert, + kDefaultHostName, kFTPDefaultPort, docroot, no_cert, std::wstring(), url_user, url_password)) { return NULL; } |