mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #19318 - jdm:webdriver, r=jgraham
Make wdspec tests runnable This makes it possible to run tests in tests/wpt/web-platform-tests/webdriver/tests and focus on investigating why they fail. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix (partially) #15274. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19318) <!-- Reviewable:end -->
This commit is contained in:
commit
dc35457b4a
10 changed files with 62 additions and 106 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -527,6 +527,14 @@ dependencies = [
|
||||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cookie"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
|
@ -3618,16 +3626,17 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webdriver"
|
name = "webdriver"
|
||||||
version = "0.22.0"
|
version = "0.32.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3650,7 +3659,7 @@ dependencies = [
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webdriver 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3882,6 +3891,7 @@ dependencies = [
|
||||||
"checksum color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
|
"checksum color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
|
||||||
"checksum compiletest_rs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "617b23d0ed4f57b3bcff6b5fe0a78f0010f1efb636298317665a960b6dbc0533"
|
"checksum compiletest_rs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "617b23d0ed4f57b3bcff6b5fe0a78f0010f1efb636298317665a960b6dbc0533"
|
||||||
"checksum cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30b3493e12a550c2f96be785088d1da8d93189e7237c8a8d0d871bc9070334c3"
|
"checksum cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30b3493e12a550c2f96be785088d1da8d93189e7237c8a8d0d871bc9070334c3"
|
||||||
|
"checksum cookie 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "477eb650753e319be2ae77ec368a58c638f9f0c4d941c39bad95e950fb1d1d0d"
|
||||||
"checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7"
|
"checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7"
|
||||||
"checksum core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9fb3d6cb663e6fd7cf1c63f9b144ee2b1e4a78595a0451dd34bff85b9a3387"
|
"checksum core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9fb3d6cb663e6fd7cf1c63f9b144ee2b1e4a78595a0451dd34bff85b9a3387"
|
||||||
"checksum core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd47addfc77b7e574d24e5434f95bb64a863769dfd4f1d451ca4ff5530ba01a"
|
"checksum core-graphics 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd47addfc77b7e574d24e5434f95bb64a863769dfd4f1d451ca4ff5530ba01a"
|
||||||
|
@ -4123,7 +4133,7 @@ dependencies = [
|
||||||
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
||||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
|
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
|
||||||
"checksum webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d548aabf87411b1b4ba91fd07eacd8b238135c7131a452b8a9f6386209167e18"
|
"checksum webdriver 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b982fb5fe268cc124931035ca0c4b65d39e6d9c9fed319186b7d17493bf98984"
|
||||||
"checksum webrender 0.53.2 (git+https://github.com/servo/webrender)" = "<none>"
|
"checksum webrender 0.53.2 (git+https://github.com/servo/webrender)" = "<none>"
|
||||||
"checksum webrender_api 0.53.2 (git+https://github.com/servo/webrender)" = "<none>"
|
"checksum webrender_api 0.53.2 (git+https://github.com/servo/webrender)" = "<none>"
|
||||||
"checksum which 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4be6cfa54dab45266e98b5d7be2f8ce959ddd49abd141a05d52dce4b07f803bb"
|
"checksum which 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4be6cfa54dab45266e98b5d7be2f8ce959ddd49abd141a05d52dce4b07f803bb"
|
||||||
|
|
|
@ -26,4 +26,4 @@ servo_config = {path = "../config"}
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
url = "1.2"
|
url = "1.2"
|
||||||
uuid = {version = "0.5", features = ["v4"]}
|
uuid = {version = "0.5", features = ["v4"]}
|
||||||
webdriver = "0.22"
|
webdriver = "0.32"
|
||||||
|
|
|
@ -168,11 +168,11 @@ fn key_from_char(key_string: &char) -> Option<(Key, bool)> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn keycodes_to_keys(key_codes: &[char]) -> Result<Vec<(Key, KeyModifiers, KeyState)>, String> {
|
pub fn keycodes_to_keys(key_codes: &str) -> Result<Vec<(Key, KeyModifiers, KeyState)>, String> {
|
||||||
let mut rv = vec![];
|
let mut rv = vec![];
|
||||||
|
|
||||||
for char_code in key_codes.iter() {
|
for char_code in key_codes.chars() {
|
||||||
let (key, with_shift) = key_from_char(char_code).ok_or(format!("Unsupported character code {}", char_code))?;
|
let (key, with_shift) = key_from_char(&char_code).ok_or(format!("Unsupported character code {}", char_code))?;
|
||||||
let modifiers = if with_shift {
|
let modifiers = if with_shift {
|
||||||
KeyModifiers::SHIFT
|
KeyModifiers::SHIFT
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -52,13 +52,13 @@ use webdriver::command::{AddCookieParameters, GetParameters, JavascriptCommandPa
|
||||||
use webdriver::command::{LocatorParameters, Parameters};
|
use webdriver::command::{LocatorParameters, Parameters};
|
||||||
use webdriver::command::{SendKeysParameters, SwitchToFrameParameters, TimeoutsParameters};
|
use webdriver::command::{SendKeysParameters, SwitchToFrameParameters, TimeoutsParameters};
|
||||||
use webdriver::command::{WebDriverCommand, WebDriverExtensionCommand, WebDriverMessage};
|
use webdriver::command::{WebDriverCommand, WebDriverExtensionCommand, WebDriverMessage};
|
||||||
use webdriver::command::WindowSizeParameters;
|
use webdriver::command::WindowRectParameters;
|
||||||
use webdriver::common::{Date, LocatorStrategy, Nullable, WebElement};
|
use webdriver::common::{Date, LocatorStrategy, Nullable, WebElement};
|
||||||
use webdriver::error::{ErrorStatus, WebDriverError, WebDriverResult};
|
use webdriver::error::{ErrorStatus, WebDriverError, WebDriverResult};
|
||||||
use webdriver::httpapi::WebDriverExtensionRoute;
|
use webdriver::httpapi::WebDriverExtensionRoute;
|
||||||
use webdriver::response::{Cookie, CookieResponse};
|
use webdriver::response::{Cookie, CookieResponse, CookiesResponse};
|
||||||
use webdriver::response::{ElementRectResponse, NewSessionResponse, ValueResponse};
|
use webdriver::response::{ElementRectResponse, NewSessionResponse, ValueResponse};
|
||||||
use webdriver::response::{WebDriverResponse, WindowSizeResponse};
|
use webdriver::response::{WebDriverResponse, WindowRectResponse};
|
||||||
use webdriver::server::{self, Session, WebDriverHandler};
|
use webdriver::server::{self, Session, WebDriverHandler};
|
||||||
|
|
||||||
fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
|
fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
|
||||||
|
@ -402,13 +402,23 @@ impl Handler {
|
||||||
|
|
||||||
let window_size = receiver.recv().unwrap();
|
let window_size = receiver.recv().unwrap();
|
||||||
let vp = window_size.initial_viewport;
|
let vp = window_size.initial_viewport;
|
||||||
let window_size_response = WindowSizeResponse::new(vp.width as u64, vp.height as u64);
|
let window_size_response = WindowRectResponse {
|
||||||
Ok(WebDriverResponse::WindowSize(window_size_response))
|
x: 0, y: 0, width: vp.width as i32, height: vp.height as i32
|
||||||
|
};
|
||||||
|
Ok(WebDriverResponse::WindowRect(window_size_response))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_set_window_size(&self, params: &WindowSizeParameters) -> WebDriverResult<WebDriverResponse> {
|
fn handle_set_window_size(&self, params: &WindowRectParameters) -> WebDriverResult<WebDriverResponse> {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
let size = Size2D::new(params.width as u32, params.height as u32);
|
let width = match params.width {
|
||||||
|
Nullable::Value(v) => v,
|
||||||
|
Nullable::Null => 0,
|
||||||
|
};
|
||||||
|
let height = match params.height {
|
||||||
|
Nullable::Value(v) => v,
|
||||||
|
Nullable::Null => 0,
|
||||||
|
};
|
||||||
|
let size = Size2D::new(width as u32, height as u32);
|
||||||
let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id;
|
let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id;
|
||||||
let cmd_msg = WebDriverCommandMsg::SetWindowSize(top_level_browsing_context_id, size, sender.clone());
|
let cmd_msg = WebDriverCommandMsg::SetWindowSize(top_level_browsing_context_id, size, sender.clone());
|
||||||
|
|
||||||
|
@ -426,8 +436,10 @@ impl Handler {
|
||||||
|
|
||||||
let window_size = receiver.recv().unwrap();
|
let window_size = receiver.recv().unwrap();
|
||||||
let vp = window_size.initial_viewport;
|
let vp = window_size.initial_viewport;
|
||||||
let window_size_response = WindowSizeResponse::new(vp.width as u64, vp.height as u64);
|
let window_size_response = WindowRectResponse {
|
||||||
Ok(WebDriverResponse::WindowSize(window_size_response))
|
x: 0, y: 0, width: vp.width as i32, height: vp.height as i32
|
||||||
|
};
|
||||||
|
Ok(WebDriverResponse::WindowRect(window_size_response))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_is_enabled(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
fn handle_is_enabled(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
||||||
|
@ -588,8 +600,10 @@ impl Handler {
|
||||||
self.browsing_context_script_command(cmd)?;
|
self.browsing_context_script_command(cmd)?;
|
||||||
match receiver.recv().unwrap() {
|
match receiver.recv().unwrap() {
|
||||||
Ok(rect) => {
|
Ok(rect) => {
|
||||||
let response = ElementRectResponse::new(rect.origin.x, rect.origin.y,
|
let response = ElementRectResponse {
|
||||||
rect.size.width, rect.size.height);
|
x: rect.origin.x, y: rect.origin.y,
|
||||||
|
width: rect.size.width, height: rect.size.height
|
||||||
|
};
|
||||||
Ok(WebDriverResponse::ElementRect(response))
|
Ok(WebDriverResponse::ElementRect(response))
|
||||||
},
|
},
|
||||||
Err(_) => Err(WebDriverError::new(ErrorStatus::StaleElementReference,
|
Err(_) => Err(WebDriverError::new(ErrorStatus::StaleElementReference,
|
||||||
|
@ -657,7 +671,7 @@ impl Handler {
|
||||||
let response = cookies.into_iter().map(|cookie| {
|
let response = cookies.into_iter().map(|cookie| {
|
||||||
cookie_msg_to_cookie(cookie.into_inner())
|
cookie_msg_to_cookie(cookie.into_inner())
|
||||||
}).collect::<Vec<Cookie>>();
|
}).collect::<Vec<Cookie>>();
|
||||||
Ok(WebDriverResponse::Cookie(CookieResponse::new(response)))
|
Ok(WebDriverResponse::Cookies(CookiesResponse { value: response }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_get_cookie(&self, name: &str) -> WebDriverResult<WebDriverResponse> {
|
fn handle_get_cookie(&self, name: &str) -> WebDriverResult<WebDriverResponse> {
|
||||||
|
@ -667,8 +681,8 @@ impl Handler {
|
||||||
let cookies = receiver.recv().unwrap();
|
let cookies = receiver.recv().unwrap();
|
||||||
let response = cookies.into_iter().map(|cookie| {
|
let response = cookies.into_iter().map(|cookie| {
|
||||||
cookie_msg_to_cookie(cookie.into_inner())
|
cookie_msg_to_cookie(cookie.into_inner())
|
||||||
}).collect::<Vec<Cookie>>();
|
}).next().unwrap();
|
||||||
Ok(WebDriverResponse::Cookie(CookieResponse::new(response)))
|
Ok(WebDriverResponse::Cookie(CookieResponse { value: response }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_add_cookie(&self, params: &AddCookieParameters) -> WebDriverResult<WebDriverResponse> {
|
fn handle_add_cookie(&self, params: &AddCookieParameters) -> WebDriverResult<WebDriverResponse> {
|
||||||
|
@ -779,7 +793,7 @@ impl Handler {
|
||||||
receiver.recv().unwrap().or_else(|_| Err(WebDriverError::new(
|
receiver.recv().unwrap().or_else(|_| Err(WebDriverError::new(
|
||||||
ErrorStatus::StaleElementReference, "Element not found or not focusable")))?;
|
ErrorStatus::StaleElementReference, "Element not found or not focusable")))?;
|
||||||
|
|
||||||
let keys = keycodes_to_keys(&keys.value).or_else(|_|
|
let keys = keycodes_to_keys(&keys.text).or_else(|_|
|
||||||
Err(WebDriverError::new(ErrorStatus::UnsupportedOperation, "Failed to convert keycodes")))?;
|
Err(WebDriverError::new(ErrorStatus::UnsupportedOperation, "Failed to convert keycodes")))?;
|
||||||
|
|
||||||
// TODO: there's a race condition caused by the focus command and the
|
// TODO: there's a race condition caused by the focus command and the
|
||||||
|
@ -880,8 +894,8 @@ impl WebDriverHandler<ServoExtensionRoute> for Handler {
|
||||||
WebDriverCommand::AddCookie(ref parameters) => self.handle_add_cookie(parameters),
|
WebDriverCommand::AddCookie(ref parameters) => self.handle_add_cookie(parameters),
|
||||||
WebDriverCommand::Get(ref parameters) => self.handle_get(parameters),
|
WebDriverCommand::Get(ref parameters) => self.handle_get(parameters),
|
||||||
WebDriverCommand::GetCurrentUrl => self.handle_current_url(),
|
WebDriverCommand::GetCurrentUrl => self.handle_current_url(),
|
||||||
WebDriverCommand::GetWindowSize => self.handle_window_size(),
|
WebDriverCommand::GetWindowRect => self.handle_window_size(),
|
||||||
WebDriverCommand::SetWindowSize(ref size) => self.handle_set_window_size(size),
|
WebDriverCommand::SetWindowRect(ref size) => self.handle_set_window_size(size),
|
||||||
WebDriverCommand::IsEnabled(ref element) => self.handle_is_enabled(element),
|
WebDriverCommand::IsEnabled(ref element) => self.handle_is_enabled(element),
|
||||||
WebDriverCommand::IsSelected(ref element) => self.handle_is_selected(element),
|
WebDriverCommand::IsSelected(ref element) => self.handle_is_selected(element),
|
||||||
WebDriverCommand::GoBack => self.handle_go_back(),
|
WebDriverCommand::GoBack => self.handle_go_back(),
|
||||||
|
|
|
@ -32,7 +32,7 @@ style_tests = {path = "../../tests/unit/style"}
|
||||||
default = ["unstable", "default-except-unstable"]
|
default = ["unstable", "default-except-unstable"]
|
||||||
default-except-unstable = ["webdriver", "max_log_level"]
|
default-except-unstable = ["webdriver", "max_log_level"]
|
||||||
max_log_level = ["log/release_max_level_info"]
|
max_log_level = ["log/release_max_level_info"]
|
||||||
webdriver = ["libservo/webdriver_server"]
|
webdriver = ["libservo/webdriver"]
|
||||||
energy-profiling = ["libservo/energy-profiling"]
|
energy-profiling = ["libservo/energy-profiling"]
|
||||||
debugmozjs = ["libservo/debugmozjs"]
|
debugmozjs = ["libservo/debugmozjs"]
|
||||||
googlevr = ["libservo/googlevr"]
|
googlevr = ["libservo/googlevr"]
|
||||||
|
|
|
@ -35,6 +35,7 @@ num = []
|
||||||
# Ignored packages with duplicated versions
|
# Ignored packages with duplicated versions
|
||||||
packages = [
|
packages = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
"cookie",
|
||||||
"mime",
|
"mime",
|
||||||
"semver",
|
"semver",
|
||||||
"toml",
|
"toml",
|
||||||
|
|
|
@ -35,7 +35,7 @@ def run_tests(paths=None, **kwargs):
|
||||||
use_mach_logging = False
|
use_mach_logging = False
|
||||||
if len(kwargs["test_list"]) == 1:
|
if len(kwargs["test_list"]) == 1:
|
||||||
file_ext = os.path.splitext(kwargs["test_list"][0])[1].lower()
|
file_ext = os.path.splitext(kwargs["test_list"][0])[1].lower()
|
||||||
if file_ext in [".htm", ".html", ".js", ".xhtml", ".xht"]:
|
if file_ext in [".htm", ".html", ".js", ".xhtml", ".xht", ".py"]:
|
||||||
use_mach_logging = True
|
use_mach_logging = True
|
||||||
|
|
||||||
if use_mach_logging:
|
if use_mach_logging:
|
||||||
|
@ -65,6 +65,7 @@ def set_defaults(paths, kwargs):
|
||||||
bin_path = servo_path("target", bin_dir, bin_name)
|
bin_path = servo_path("target", bin_dir, bin_name)
|
||||||
|
|
||||||
kwargs["binary"] = bin_path
|
kwargs["binary"] = bin_path
|
||||||
|
kwargs["webdriver_binary"] = bin_path
|
||||||
|
|
||||||
if kwargs["processes"] is None:
|
if kwargs["processes"] is None:
|
||||||
kwargs["processes"] = multiprocessing.cpu_count()
|
kwargs["processes"] = multiprocessing.cpu_count()
|
||||||
|
|
|
@ -42,6 +42,8 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
|
||||||
rv = base_executor_kwargs(test_type, server_config,
|
rv = base_executor_kwargs(test_type, server_config,
|
||||||
cache_manager, **kwargs)
|
cache_manager, **kwargs)
|
||||||
rv["pause_after_test"] = kwargs["pause_after_test"]
|
rv["pause_after_test"] = kwargs["pause_after_test"]
|
||||||
|
if test_type == "wdspec":
|
||||||
|
rv["capabilities"] = {}
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from .base import (ExecutorException,
|
||||||
RefTestImplementation,
|
RefTestImplementation,
|
||||||
testharness_result_converter,
|
testharness_result_converter,
|
||||||
reftest_result_converter,
|
reftest_result_converter,
|
||||||
WdspecExecutor)
|
WdspecExecutor, WebDriverProtocol)
|
||||||
from .process import ProcessTestExecutor
|
from .process import ProcessTestExecutor
|
||||||
from ..browsers.base import browser_command
|
from ..browsers.base import browser_command
|
||||||
from ..wpttest import WdspecResult, WdspecSubtestResult
|
from ..wpttest import WdspecResult, WdspecSubtestResult
|
||||||
|
@ -286,82 +286,9 @@ class ServoRefTestExecutor(ProcessTestExecutor):
|
||||||
line,
|
line,
|
||||||
" ".join(self.command))
|
" ".join(self.command))
|
||||||
|
|
||||||
class ServoWdspecProtocol(Protocol):
|
|
||||||
def __init__(self, executor, browser):
|
|
||||||
self.do_delayed_imports()
|
|
||||||
Protocol.__init__(self, executor, browser)
|
|
||||||
self.session = None
|
|
||||||
self.server = None
|
|
||||||
|
|
||||||
def setup(self, runner):
|
|
||||||
try:
|
|
||||||
self.server = ServoDriverServer(self.logger, binary=self.browser.binary, binary_args=self.browser.binary_args)
|
|
||||||
self.server.start(block=False)
|
|
||||||
self.logger.info(
|
|
||||||
"WebDriver HTTP server listening at %s" % self.server.url)
|
|
||||||
|
|
||||||
self.logger.info(
|
|
||||||
"Establishing new WebDriver session with %s" % self.server.url)
|
|
||||||
self.session = webdriver.Session(
|
|
||||||
self.server.host, self.server.port, self.server.base_path)
|
|
||||||
except Exception:
|
|
||||||
self.logger.error(traceback.format_exc())
|
|
||||||
self.executor.runner.send_message("init_failed")
|
|
||||||
else:
|
|
||||||
self.executor.runner.send_message("init_succeeded")
|
|
||||||
|
|
||||||
def teardown(self):
|
|
||||||
if self.server is not None:
|
|
||||||
try:
|
|
||||||
if self.session.session_id is not None:
|
|
||||||
self.session.end()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
if self.server.is_alive:
|
|
||||||
self.server.stop()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_alive(self):
|
|
||||||
conn = httplib.HTTPConnection(self.server.host, self.server.port)
|
|
||||||
conn.request("HEAD", self.server.base_path + "invalid")
|
|
||||||
res = conn.getresponse()
|
|
||||||
return res.status == 404
|
|
||||||
|
|
||||||
def do_delayed_imports(self):
|
|
||||||
global pytestrunner, webdriver
|
|
||||||
from . import pytestrunner
|
|
||||||
import webdriver
|
|
||||||
|
|
||||||
|
class ServoDriverProtocol(WebDriverProtocol):
|
||||||
|
server_cls = ServoDriverServer
|
||||||
|
|
||||||
class ServoWdspecExecutor(WdspecExecutor):
|
class ServoWdspecExecutor(WdspecExecutor):
|
||||||
def __init__(self, browser, server_config,
|
protocol_cls = ServoDriverProtocol
|
||||||
timeout_multiplier=1, close_after_done=True, debug_info=None,
|
|
||||||
**kwargs):
|
|
||||||
WdspecExecutor.__init__(self, browser, server_config,
|
|
||||||
timeout_multiplier=timeout_multiplier,
|
|
||||||
debug_info=debug_info)
|
|
||||||
self.protocol = ServoWdspecProtocol(self, browser)
|
|
||||||
|
|
||||||
def is_alive(self):
|
|
||||||
return self.protocol.is_alive
|
|
||||||
|
|
||||||
def on_environment_change(self, new_environment):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def do_test(self, test):
|
|
||||||
timeout = test.timeout * self.timeout_multiplier + extra_timeout
|
|
||||||
|
|
||||||
success, data = WdspecRun(self.do_wdspec,
|
|
||||||
self.protocol.session,
|
|
||||||
test.path,
|
|
||||||
timeout).run()
|
|
||||||
|
|
||||||
if success:
|
|
||||||
return self.convert_result(test, data)
|
|
||||||
|
|
||||||
return (test.result_cls(*data), [])
|
|
||||||
|
|
||||||
def do_wdspec(self, session, path, timeout):
|
|
||||||
harness_result = ("OK", None)
|
|
||||||
subtest_results = pytestrunner.run(path, session, timeout=timeout)
|
|
||||||
return (harness_result, subtest_results)
|
|
||||||
|
|
|
@ -195,10 +195,11 @@ class GeckoDriverServer(WebDriverServer):
|
||||||
|
|
||||||
|
|
||||||
class ServoDriverServer(WebDriverServer):
|
class ServoDriverServer(WebDriverServer):
|
||||||
def __init__(self, logger, binary="servo", binary_args=None, host="127.0.0.1", port=None):
|
def __init__(self, logger, binary="servo", binary_args=None, host="127.0.0.1",
|
||||||
|
port=None, args=None):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["RUST_BACKTRACE"] = "1"
|
env["RUST_BACKTRACE"] = "1"
|
||||||
WebDriverServer.__init__(self, logger, binary, host=host, port=port, env=env)
|
WebDriverServer.__init__(self, logger, binary, host=host, port=port, env=env, args=args)
|
||||||
self.binary_args = binary_args
|
self.binary_args = binary_args
|
||||||
|
|
||||||
def make_command(self):
|
def make_command(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue