aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-06-17 10:16:27 -0600
committerbors-servo <metajack+bors@gmail.com>2015-06-17 10:16:27 -0600
commitee54c89e3f801dcd90a494c65ff8cfd975a6be6f (patch)
treea7b7155e02ca6d7c1c852cd01ba025f13fd68191 /components
parentee22ae263515c2804b739ead4c02bc7333c3965c (diff)
parent22c06307b8a55ae3ce7393d9770918f74ac5e0d8 (diff)
downloadservo-ee54c89e3f801dcd90a494c65ff8cfd975a6be6f.tar.gz
servo-ee54c89e3f801dcd90a494c65ff8cfd975a6be6f.zip
Auto merge of #6401 - jgraham:load_timeout, r=metajack
<!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6401) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/compositing/constellation.rs4
-rw-r--r--components/msg/constellation_msg.rs4
-rw-r--r--components/msg/webdriver_msg.rs5
-rw-r--r--components/webdriver_server/lib.rs21
4 files changed, 23 insertions, 11 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index cbca7b48a06..13dbb11037f 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -190,7 +190,7 @@ pub struct SendableFrameTree {
}
struct WebDriverData {
- load_channel: Option<(PipelineId, Sender<webdriver_msg::LoadComplete>)>
+ load_channel: Option<(PipelineId, Sender<webdriver_msg::LoadStatus>)>
}
impl WebDriverData {
@@ -709,7 +709,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut webdriver_reset = false;
if let Some((ref expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
if expected_pipeline_id == pipeline_id {
- reply_chan.send(webdriver_msg::LoadComplete).unwrap();
+ let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete);
webdriver_reset = true;
}
}
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index c8d5bf0ceb2..16a68dc7532 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -19,7 +19,7 @@ use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender, Receiver};
use style::viewport::ViewportConstraints;
use url::Url;
-use webdriver_msg::{WebDriverScriptCommand, LoadComplete};
+use webdriver_msg::{WebDriverScriptCommand, LoadStatus};
#[derive(Clone)]
pub struct ConstellationChan(pub Sender<Msg>);
@@ -328,7 +328,7 @@ impl MozBrowserEvent {
}
pub enum WebDriverCommandMsg {
- LoadUrl(PipelineId, LoadData, Sender<LoadComplete>),
+ LoadUrl(PipelineId, LoadData, Sender<LoadStatus>),
ScriptCommand(PipelineId, WebDriverScriptCommand),
TakeScreenshot(PipelineId, Sender<Option<png::Image>>)
}
diff --git a/components/msg/webdriver_msg.rs b/components/msg/webdriver_msg.rs
index 7921bb0a156..bc57f58fa28 100644
--- a/components/msg/webdriver_msg.rs
+++ b/components/msg/webdriver_msg.rs
@@ -53,4 +53,7 @@ impl ToJson for WebDriverJSValue {
}
}
-pub struct LoadComplete;
+pub enum LoadStatus {
+ LoadComplete,
+ LoadTimeout
+}
diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs
index 234d1764ab2..c13ff457ca1 100644
--- a/components/webdriver_server/lib.rs
+++ b/components/webdriver_server/lib.rs
@@ -22,7 +22,7 @@ use msg::constellation_msg::{ConstellationChan, LoadData, FrameId, PipelineId, N
WebDriverCommandMsg};
use msg::constellation_msg::Msg as ConstellationMsg;
use std::sync::mpsc::{channel, Receiver};
-use msg::webdriver_msg::{WebDriverFrameId, WebDriverScriptCommand, WebDriverJSError, WebDriverJSResult};
+use msg::webdriver_msg::{WebDriverFrameId, WebDriverScriptCommand, WebDriverJSError, WebDriverJSResult, LoadStatus};
use url::Url;
use webdriver::command::{WebDriverMessage, WebDriverCommand};
@@ -42,7 +42,7 @@ use rustc_serialize::base64::{Config, ToBase64, CharacterSet, Newline};
use std::collections::BTreeMap;
use std::net::SocketAddr;
-use std::thread::sleep_ms;
+use std::thread::{self, sleep_ms};
pub fn start_server(port: u16, constellation_chan: ConstellationChan) {
let handler = Handler::new(constellation_chan);
@@ -172,13 +172,22 @@ impl Handler {
let load_data = LoadData::new(url);
let ConstellationChan(ref const_chan) = self.constellation_chan;
- let cmd_msg = WebDriverCommandMsg::LoadUrl(pipeline_id, load_data, sender);
+ let cmd_msg = WebDriverCommandMsg::LoadUrl(pipeline_id, load_data, sender.clone());
const_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
- //Wait to get a load event
- reciever.recv().unwrap();
+ let timeout = self.load_timeout;
+ let timeout_chan = sender.clone();
+ thread::spawn(move || {
+ sleep_ms(timeout);
+ let _ = timeout_chan.send(LoadStatus::LoadTimeout);
+ });
- Ok(WebDriverResponse::Void)
+ //Wait to get a load event
+ match reciever.recv().unwrap() {
+ LoadStatus::LoadComplete => Ok(WebDriverResponse::Void),
+ LoadStatus::LoadTimeout => Err(WebDriverError::new(ErrorStatus::Timeout,
+ "Load timed out"))
+ }
}
fn handle_go_back(&self) -> WebDriverResult<WebDriverResponse> {