Add support for switching frames with the webdriver API.

This moves webdriver_traits into msg to avoid a circular dependency.
This commit is contained in:
James Graham 2015-05-11 14:47:10 +01:00
parent c724444ccb
commit 49f1b13ad9
20 changed files with 273 additions and 122 deletions

View file

@ -13,9 +13,6 @@ path = "../style"
[dependencies.util]
path = "../util"
[dependencies.webdriver_traits]
path = "../webdriver_traits"
[dependencies.azure]
git = "https://github.com/servo/rust-azure"
@ -38,3 +35,4 @@ git = "https://github.com/servo/rust-png"
url = "0.2.16"
bitflags = "*"
hyper = "0.4"
rustc-serialize = "0.3.4"

View file

@ -18,8 +18,8 @@ use util::geometry::{PagePx, ViewportPx};
use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender, Receiver};
use style::viewport::ViewportConstraints;
use webdriver_traits::{WebDriverScriptCommand, LoadComplete};
use url::Url;
use webdriver_msg::{WebDriverScriptCommand, LoadComplete};
#[derive(Clone)]
pub struct ConstellationChan(pub Sender<Msg>);
@ -230,8 +230,12 @@ pub enum Msg {
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId),
/// Request that the constellation send the current root pipeline id over a provided channel
GetRootPipeline(Sender<Option<PipelineId>>),
/// 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>, Sender<Option<PipelineId>>),
/// Request that the constellation send the FrameId corresponding to the document
/// with the provided parent pipeline id and subpage id
GetFrame(PipelineId, SubpageId, Sender<Option<FrameId>>),
/// Notifies the constellation that this frame has received focus.
Focus(PipelineId),
/// Requests that the constellation retrieve the current contents of the clipboard

View file

@ -8,10 +8,10 @@ extern crate geom;
extern crate hyper;
extern crate layers;
extern crate png;
extern crate rustc_serialize;
extern crate util;
extern crate url;
extern crate style;
extern crate webdriver_traits;
#[cfg(target_os="macos")]
extern crate core_foundation;
@ -20,3 +20,4 @@ extern crate io_surface;
pub mod compositor_msg;
pub mod constellation_msg;
pub mod webdriver_msg;

View file

@ -0,0 +1,56 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use rustc_serialize::json::{Json, ToJson};
use constellation_msg::{PipelineId, SubpageId};
use std::sync::mpsc::Sender;
pub enum WebDriverScriptCommand {
ExecuteScript(String, Sender<WebDriverJSResult>),
ExecuteAsyncScript(String, Sender<WebDriverJSResult>),
FindElementCSS(String, Sender<Result<Option<String>, ()>>),
FindElementsCSS(String, Sender<Result<Vec<String>, ()>>),
GetActiveElement(Sender<Option<String>>),
GetElementTagName(String, Sender<Result<String, ()>>),
GetElementText(String, Sender<Result<String, ()>>),
GetFrameId(WebDriverFrameId, Sender<Result<Option<(PipelineId, SubpageId)>, ()>>),
GetTitle(Sender<String>)
}
pub enum WebDriverJSValue {
Undefined,
Null,
Boolean(bool),
Number(f64),
String(String),
// TODO: Object and WebElement
}
pub enum WebDriverJSError {
Timeout,
UnknownType
}
pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>;
pub enum WebDriverFrameId {
Short(u16),
Element(String),
Parent
}
impl ToJson for WebDriverJSValue {
fn to_json(&self) -> Json {
match *self {
WebDriverJSValue::Undefined => Json::Null,
WebDriverJSValue::Null => Json::Null,
WebDriverJSValue::Boolean(ref x) => x.to_json(),
WebDriverJSValue::Number(ref x) => x.to_json(),
WebDriverJSValue::String(ref x) => x.to_json()
}
}
}
pub struct LoadComplete;