diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 0dc96a4e8de..5a75d43df3e 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -293,7 +293,7 @@ impl<'a> Iterator for FrameTreeIterator<'a> { struct WebDriverData { load_channel: Option<(PipelineId, IpcSender)>, - resize_channel: Option>>, + resize_channel: Option>, } impl WebDriverData { @@ -1713,7 +1713,7 @@ impl Constellation } if let Some(resize_channel) = self.webdriver.resize_channel.take() { - let _ = resize_channel.send(Some(new_size)); + let _ = resize_channel.send(new_size); } self.window_size = new_size; diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index d938cd63cb4..543e4277f23 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -193,7 +193,7 @@ pub enum WebDriverCommandMsg { Refresh(PipelineId, IpcSender), ScriptCommand(PipelineId, WebDriverScriptCommand), SendKeys(PipelineId, Vec<(Key, KeyModifiers, KeyState)>), - SetWindowSize(PipelineId, Size2D, IpcSender>), + SetWindowSize(PipelineId, Size2D, IpcSender), TakeScreenshot(PipelineId, IpcSender>), } diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 660731f9a76..f8dad025011 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -2476,6 +2476,7 @@ name = "webdriver_server" version = "0.0.1" dependencies = [ "compositing 0.0.1", + "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)", diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 1f3de6a0db4..92c339fb7d5 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -223,7 +223,7 @@ impl Handler { constellation_chan: constellation_chan, script_timeout: 30_000, load_timeout: 300_000, - resize_timeout: 30_000, + resize_timeout: 500, implicit_wait_timeout: 0 } } @@ -379,19 +379,19 @@ impl Handler { self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap(); let timeout = self.resize_timeout; + let constellation_chan = self.constellation_chan.clone(); thread::spawn(move || { + // On timeout, we send a GetWindowSize message to the constellation, + // which will give the current window size. thread::sleep(Duration::from_millis(timeout as u64)); - let _ = sender.send(None); + let cmd_msg = WebDriverCommandMsg::GetWindowSize(pipeline_id, sender); + constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap(); }); - match receiver.recv().unwrap() { - Some(window_size) => { - let vp = window_size.visible_viewport; - let window_size_response = WindowSizeResponse::new(vp.width.get() as u64, vp.height.get() as u64); - Ok(WebDriverResponse::WindowSize(window_size_response)) - }, - None => Err(WebDriverError::new(ErrorStatus::Timeout, "Resize timed out")), - } + let window_size = receiver.recv().unwrap(); + let vp = window_size.visible_viewport; + let window_size_response = WindowSizeResponse::new(vp.width.get() as u64, vp.height.get() as u64); + Ok(WebDriverResponse::WindowSize(window_size_response)) } fn handle_is_enabled(&self, element: &WebElement) -> WebDriverResult { diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 096037b1913..e5c6fbc6366 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -2337,6 +2337,7 @@ name = "webdriver_server" version = "0.0.1" dependencies = [ "compositing 0.0.1", + "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",