mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
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 -->
This commit is contained in:
commit
ee54c89e3f
4 changed files with 23 additions and 11 deletions
|
@ -190,7 +190,7 @@ pub struct SendableFrameTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WebDriverData {
|
struct WebDriverData {
|
||||||
load_channel: Option<(PipelineId, Sender<webdriver_msg::LoadComplete>)>
|
load_channel: Option<(PipelineId, Sender<webdriver_msg::LoadStatus>)>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebDriverData {
|
impl WebDriverData {
|
||||||
|
@ -709,7 +709,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
let mut webdriver_reset = false;
|
let mut webdriver_reset = false;
|
||||||
if let Some((ref expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
|
if let Some((ref expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
|
||||||
if expected_pipeline_id == pipeline_id {
|
if expected_pipeline_id == pipeline_id {
|
||||||
reply_chan.send(webdriver_msg::LoadComplete).unwrap();
|
let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete);
|
||||||
webdriver_reset = true;
|
webdriver_reset = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::collections::HashMap;
|
||||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||||
use style::viewport::ViewportConstraints;
|
use style::viewport::ViewportConstraints;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use webdriver_msg::{WebDriverScriptCommand, LoadComplete};
|
use webdriver_msg::{WebDriverScriptCommand, LoadStatus};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ConstellationChan(pub Sender<Msg>);
|
pub struct ConstellationChan(pub Sender<Msg>);
|
||||||
|
@ -328,7 +328,7 @@ impl MozBrowserEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum WebDriverCommandMsg {
|
pub enum WebDriverCommandMsg {
|
||||||
LoadUrl(PipelineId, LoadData, Sender<LoadComplete>),
|
LoadUrl(PipelineId, LoadData, Sender<LoadStatus>),
|
||||||
ScriptCommand(PipelineId, WebDriverScriptCommand),
|
ScriptCommand(PipelineId, WebDriverScriptCommand),
|
||||||
TakeScreenshot(PipelineId, Sender<Option<png::Image>>)
|
TakeScreenshot(PipelineId, Sender<Option<png::Image>>)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,4 +53,7 @@ impl ToJson for WebDriverJSValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LoadComplete;
|
pub enum LoadStatus {
|
||||||
|
LoadComplete,
|
||||||
|
LoadTimeout
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ use msg::constellation_msg::{ConstellationChan, LoadData, FrameId, PipelineId, N
|
||||||
WebDriverCommandMsg};
|
WebDriverCommandMsg};
|
||||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use std::sync::mpsc::{channel, Receiver};
|
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 url::Url;
|
||||||
use webdriver::command::{WebDriverMessage, WebDriverCommand};
|
use webdriver::command::{WebDriverMessage, WebDriverCommand};
|
||||||
|
@ -42,7 +42,7 @@ use rustc_serialize::base64::{Config, ToBase64, CharacterSet, Newline};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use std::thread::sleep_ms;
|
use std::thread::{self, sleep_ms};
|
||||||
|
|
||||||
pub fn start_server(port: u16, constellation_chan: ConstellationChan) {
|
pub fn start_server(port: u16, constellation_chan: ConstellationChan) {
|
||||||
let handler = Handler::new(constellation_chan);
|
let handler = Handler::new(constellation_chan);
|
||||||
|
@ -172,13 +172,22 @@ impl Handler {
|
||||||
|
|
||||||
let load_data = LoadData::new(url);
|
let load_data = LoadData::new(url);
|
||||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
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();
|
const_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
||||||
|
|
||||||
//Wait to get a load event
|
let timeout = self.load_timeout;
|
||||||
reciever.recv().unwrap();
|
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> {
|
fn handle_go_back(&self) -> WebDriverResult<WebDriverResponse> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue