diff --git a/servo/components/servo/Cargo.lock b/servo/components/servo/Cargo.lock index 3a3e60e76293..acf5eb433771 100644 --- a/servo/components/servo/Cargo.lock +++ b/servo/components/servo/Cargo.lock @@ -18,6 +18,7 @@ dependencies = [ "time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webdriver_server 0.0.1", ] [[package]] @@ -966,6 +967,34 @@ dependencies = [ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "uuid" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver" +version = "0.0.1" +source = "git+https://github.com/jgraham/webdriver-rust.git#906806d51783b5caad89432bf8ce008f2f4968fc" +dependencies = [ + "hyper 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver_server" +version = "0.0.1" +dependencies = [ + "webdriver 0.0.1 (git+https://github.com/jgraham/webdriver-rust.git)", +] + [[package]] name = "winapi" version = "0.0.5" diff --git a/servo/components/servo/Cargo.toml b/servo/components/servo/Cargo.toml index 8a243e58b8f3..a72401d3ad59 100644 --- a/servo/components/servo/Cargo.toml +++ b/servo/components/servo/Cargo.toml @@ -72,6 +72,9 @@ path = "../gfx" [dependencies.devtools] path = "../devtools" +[dependencies.webdriver_server] +path = "../webdriver_server" + [dependencies.glutin_app] path = "../../ports/glutin" optional = true diff --git a/servo/components/servo/lib.rs b/servo/components/servo/lib.rs index 051e6190922a..7990de397e91 100644 --- a/servo/components/servo/lib.rs +++ b/servo/components/servo/lib.rs @@ -21,6 +21,7 @@ extern crate layout; extern crate gfx; extern crate libc; extern crate url; +extern crate webdriver_server; use compositing::CompositorEventListener; use compositing::windowing::WindowEvent; @@ -84,6 +85,10 @@ impl Browser { devtools::start_server(port) }); + if let Some(port) = opts.webdriver_port { + webdriver_server::start_server(port); + } + // Create a Servo instance. let resource_task = new_resource_task(opts.user_agent.clone()); diff --git a/servo/components/util/opts.rs b/servo/components/util/opts.rs index f445359407e9..41245e3c7cb5 100644 --- a/servo/components/util/opts.rs +++ b/servo/components/util/opts.rs @@ -108,6 +108,10 @@ pub struct Opts { /// remote Firefox devtools connections. pub devtools_port: Option, + /// `None` to disable WebDriver or `Some` with a port number to start a server to listen to + /// remote WebDriver commands. + pub webdriver_port: Option, + /// The initial requested size of the window. pub initial_window_size: TypedSize2D, @@ -199,6 +203,7 @@ pub fn default_opts() -> Opts { enable_text_antialiasing: false, trace_layout: false, devtools_port: None, + webdriver_port: None, initial_window_size: TypedSize2D(800, 600), user_agent: None, dump_flow_tree: false, @@ -232,6 +237,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { getopts::optflag("z", "headless", "Headless mode"), getopts::optflag("f", "hard-fail", "Exit on task failure instead of displaying about:failure"), getopts::optflagopt("", "devtools", "Start remote devtools server on port", "6000"), + getopts::optflagopt("", "webdriver", "Start remote WebDriver server on port", "7000"), getopts::optopt("", "resolution", "Set window resolution.", "800x600"), getopts::optopt("u", "user-agent", "Set custom user agent string", "NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m)"), getopts::optopt("Z", "debug", "A comma-separated string of debug options. Pass help to show available options.", ""), @@ -318,6 +324,10 @@ pub fn from_cmdline_args(args: &[String]) -> bool { port.parse().unwrap() }); + let webdriver_port = opt_match.opt_default("webdriver", "7000").map(|port| { + port.parse().unwrap() + }); + let initial_window_size = match opt_match.opt_str("resolution") { Some(res_string) => { let res: Vec = res_string.split('x').map(|r| r.parse().unwrap()).collect(); @@ -348,6 +358,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { profile_tasks: debug_options.contains(&"profile-tasks"), trace_layout: trace_layout, devtools_port: devtools_port, + webdriver_port: webdriver_port, initial_window_size: initial_window_size, user_agent: opt_match.opt_str("u"), show_debug_borders: debug_options.contains(&"show-compositor-borders"), diff --git a/servo/components/webdriver_server/Cargo.toml b/servo/components/webdriver_server/Cargo.toml new file mode 100644 index 000000000000..ec68305b8851 --- /dev/null +++ b/servo/components/webdriver_server/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "webdriver_server" +version = "0.0.1" +authors = ["The Servo Project Developers"] + +[lib] +name = "webdriver_server" +path = "lib.rs" + +[dependencies.webdriver] +git = "https://github.com/jgraham/webdriver-rust.git" \ No newline at end of file diff --git a/servo/components/webdriver_server/lib.rs b/servo/components/webdriver_server/lib.rs new file mode 100644 index 000000000000..5377106654a0 --- /dev/null +++ b/servo/components/webdriver_server/lib.rs @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#![crate_name = "webdriver_server"] +#![crate_type = "rlib"] + +#![feature(net)] + +extern crate webdriver; + +use webdriver::command::WebDriverMessage; +use webdriver::error::WebDriverResult; +use webdriver::response::WebDriverResponse; +use webdriver::server::{self, WebDriverHandler, Session}; + +use std::net::IpAddr; + +pub fn start_server(port: u16) { + server::start(IpAddr::new_v4(0, 0, 0, 0), port, Handler); +} + +struct Handler; + +impl WebDriverHandler for Handler { + fn handle_command(&mut self, _session: &Option, _msg: &WebDriverMessage) -> WebDriverResult { + Ok(WebDriverResponse::Void) + } + + fn delete_session(&mut self, _session: &Option) { + } +} diff --git a/servo/ports/cef/Cargo.lock b/servo/ports/cef/Cargo.lock index bd0019b3c6d0..e274f8ba6b49 100644 --- a/servo/ports/cef/Cargo.lock +++ b/servo/ports/cef/Cargo.lock @@ -864,6 +864,7 @@ dependencies = [ "time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webdriver_server 0.0.1", ] [[package]] @@ -992,6 +993,34 @@ dependencies = [ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "uuid" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver" +version = "0.0.1" +source = "git+https://github.com/jgraham/webdriver-rust.git#906806d51783b5caad89432bf8ce008f2f4968fc" +dependencies = [ + "hyper 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver_server" +version = "0.0.1" +dependencies = [ + "webdriver 0.0.1 (git+https://github.com/jgraham/webdriver-rust.git)", +] + [[package]] name = "winapi" version = "0.0.5" diff --git a/servo/ports/gonk/Cargo.lock b/servo/ports/gonk/Cargo.lock index 0efd325cc1e0..7f07df266849 100644 --- a/servo/ports/gonk/Cargo.lock +++ b/servo/ports/gonk/Cargo.lock @@ -788,6 +788,7 @@ dependencies = [ "time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webdriver_server 0.0.1", ] [[package]] @@ -908,6 +909,34 @@ dependencies = [ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "uuid" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver" +version = "0.0.1" +source = "git+https://github.com/jgraham/webdriver-rust.git#906806d51783b5caad89432bf8ce008f2f4968fc" +dependencies = [ + "hyper 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webdriver_server" +version = "0.0.1" +dependencies = [ + "webdriver 0.0.1 (git+https://github.com/jgraham/webdriver-rust.git)", +] + [[package]] name = "xlib" version = "0.1.0"