aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Tolfsen <ato@mozilla.com>2017-01-26 18:53:46 +0000
committerAndreas Tolfsen <ato@mozilla.com>2017-01-26 19:44:18 +0000
commit90d1ee7602aabb41db1fee607bad16cb771d4cd9 (patch)
treea0b5d187e53daafc839b28e5522d0a10135b2843
parente87c275de02c2d96851f7e637d55cb7076f35224 (diff)
downloadservo-90d1ee7602aabb41db1fee607bad16cb771d4cd9.tar.gz
servo-90d1ee7602aabb41db1fee607bad16cb771d4cd9.zip
webdriver_server: allow script timeout to be optional
The script timeout duration may be set to null, indicating that an injected script should run indefinitely without getting interrupted. This change fixes the internal data structure, but does not address the parsing of the input arguments to handle_set_timeouts.
-rw-r--r--components/webdriver_server/lib.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs
index 514407020cb..0264197fb6c 100644
--- a/components/webdriver_server/lib.rs
+++ b/components/webdriver_server/lib.rs
@@ -101,8 +101,9 @@ struct WebDriverSession {
id: Uuid,
frame_id: Option<FrameId>,
- /// Time to wait for injected scripts to run before interrupting them.
- script_timeout: u32,
+ /// Time to wait for injected scripts to run before interrupting them. A [`None`] value
+ /// specifies that the script should run indefinitely.
+ script_timeout: Option<u32>,
/// Time to wait for a page to finish loading upon navigation.
load_timeout: u32,
@@ -118,7 +119,7 @@ impl WebDriverSession {
id: Uuid::new_v4(),
frame_id: None,
- script_timeout: 30_000,
+ script_timeout: Some(30_000),
load_timeout: 300_000,
implicit_wait_timeout: 0,
}
@@ -705,11 +706,10 @@ impl Handler {
.as_mut()
.ok_or(WebDriverError::new(ErrorStatus::SessionNotCreated, "")));
- // TODO(ato): Conversation is wrong. The script timeout can be null, and the numeric
- // values should be limited to u32 in the standard.
+ // TODO: this conversion is crazy, spec should limit these to u32 and check upstream
let value = parameters.ms as u32;
match &parameters.type_[..] {
- "script" => session.script_timeout = value,
+ "script" => session.script_timeout = Some(value),
"page load" => session.load_timeout = value,
"implicit" => session.implicit_wait_timeout = value,
x => {
@@ -745,10 +745,15 @@ impl Handler {
let func_body = &parameters.script;
let args_string = "window.webdriverCallback";
- let script = format!("setTimeout(webdriverTimeout, {}); (function(callback) {{ {} }})({})",
- session.script_timeout,
- func_body,
- args_string);
+ let script = match session.script_timeout {
+ Some(timeout) => {
+ format!("setTimeout(webdriverTimeout, {}); (function(callback) {{ {} }})({})",
+ timeout,
+ func_body,
+ args_string)
+ }
+ None => format!("(function(callback) {{ {} }})({})", func_body, args_string),
+ };
let (sender, receiver) = ipc::channel().unwrap();
let command = WebDriverScriptCommand::ExecuteAsyncScript(script, sender);