Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented webdriver SetWindowSize. #11179

Merged
merged 4 commits into from May 23, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Responding to review comments.

  • Loading branch information
asajeffrey committed May 20, 2016
commit 8797f6f3ec8bb49ad35d375fd8bb2fb62a3abc32
@@ -293,7 +293,7 @@ impl<'a> Iterator for FrameTreeIterator<'a> {

struct WebDriverData {
load_channel: Option<(PipelineId, IpcSender<webdriver_msg::LoadStatus>)>,
resize_channel: Option<IpcSender<Option<WindowSizeData>>>,
resize_channel: Option<IpcSender<WindowSizeData>>,
}

impl WebDriverData {
@@ -1713,7 +1713,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
}

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;
@@ -193,7 +193,7 @@ pub enum WebDriverCommandMsg {
Refresh(PipelineId, IpcSender<LoadStatus>),
ScriptCommand(PipelineId, WebDriverScriptCommand),
SendKeys(PipelineId, Vec<(Key, KeyModifiers, KeyState)>),
SetWindowSize(PipelineId, Size2D<u32>, IpcSender<Option<WindowSizeData>>),
SetWindowSize(PipelineId, Size2D<u32>, IpcSender<WindowSizeData>),
TakeScreenshot(PipelineId, IpcSender<Option<Image>>),
}

Some generated files are not rendered by default. Learn more.

@@ -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<WebDriverResponse> {

Some generated files are not rendered by default. Learn more.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.