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

When webdriver is getting a pipeline id, it should wait for the pipeline document to be ready #11140

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

When webdriver is getting a pipeline id, it should wait for the pipel…

…ine document to be ready.
  • Loading branch information
asajeffrey committed May 11, 2016
commit 00a8efe9fd223fc2a0fd24443655b7a6efd61d92
@@ -1390,14 +1390,17 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
}

fn handle_get_pipeline(&mut self, frame_id: Option<FrameId>,
resp_chan: IpcSender<Option<PipelineId>>) {
resp_chan: IpcSender<Option<(PipelineId, bool)>>) {
let current_pipeline_id = frame_id.or(self.root_frame_id)
.and_then(|frame_id| self.frames.get(&frame_id))
.map(|frame| frame.current);
let pipeline_id = self.pending_frames.iter().rev()
let current_pipeline_id_loaded = current_pipeline_id
.map(|id| (id, true));
let pipeline_id_loaded = self.pending_frames.iter().rev()
.find(|x| x.old_pipeline_id == current_pipeline_id)
.map(|x| x.new_pipeline_id).or(current_pipeline_id);
if let Err(e) = resp_chan.send(pipeline_id) {
.map(|x| (x.new_pipeline_id, x.document_ready))
.or(current_pipeline_id_loaded);
if let Err(e) = resp_chan.send(pipeline_id_loaded) {
warn!("Failed get_pipeline response ({}).", e);
}
}
@@ -88,8 +88,9 @@ pub enum CompositorMsg {
/// with the provided pipeline id
GetFrame(PipelineId, IpcSender<Option<FrameId>>),
/// Request that the constellation send the current pipeline id for the provided frame
/// id, or for the root frame if this is None, over a provided channel
GetPipeline(Option<FrameId>, IpcSender<Option<PipelineId>>),
/// id, or for the root frame if this is None, over a provided channel.
/// Also returns a boolean saying whether the document has finished loading or not.
GetPipeline(Option<FrameId>, IpcSender<Option<(PipelineId, bool)>>),
/// Requests that the constellation inform the compositor of the title of the pipeline
/// immediately.
GetPipelineTitle(PipelineId),
@@ -223,32 +223,31 @@ impl Handler {
}
}

fn root_pipeline(&self) -> WebDriverResult<PipelineId> {
fn pipeline(&self, frame_id: Option<FrameId>) -> WebDriverResult<PipelineId> {
let interval = 20;
let iterations = 30_000 / interval;
let (sender, receiver) = ipc::channel().unwrap();

for _ in 0..iterations {
if let Some(x) = self.pipeline(None) {
return Ok(x)
};

let msg = ConstellationMsg::GetPipeline(frame_id, sender.clone());
self.constellation_chan.send(msg).unwrap();
// Wait until the document is ready before returning the pipeline id.
if let Some((x, true)) = receiver.recv().unwrap() {
return Ok(x);
}
thread::sleep(Duration::from_millis(interval));
};
}

Err(WebDriverError::new(ErrorStatus::Timeout,
"Failed to get root window handle"))
"Failed to get window handle"))
}

fn root_pipeline(&self) -> WebDriverResult<PipelineId> {
self.pipeline(None)
}

fn frame_pipeline(&self) -> WebDriverResult<PipelineId> {
if let Some(ref session) = self.session {
match self.pipeline(session.frame_id) {
Some(x) => Ok(x),
None => Err(WebDriverError::new(ErrorStatus::NoSuchFrame,
"Frame got closed"))
}
} else {
panic!("Command tried to access session but session is None");
}
self.pipeline(self.session.as_ref().and_then(|session| session.frame_id))
}

fn session(&self) -> WebDriverResult<&WebDriverSession> {
@@ -270,14 +269,6 @@ impl Handler {
}
}

fn pipeline(&self, frame_id: Option<FrameId>) -> Option<PipelineId> {
let (sender, receiver) = ipc::channel().unwrap();
self.constellation_chan.send(ConstellationMsg::GetPipeline(frame_id, sender)).unwrap();


receiver.recv().unwrap()
}

fn handle_new_session(&mut self) -> WebDriverResult<WebDriverResponse> {
if self.session.is_none() {
let session = WebDriverSession::new();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.