Add script execution support via WebDriver

This commit is contained in:
James Graham 2015-04-23 12:58:41 +01:00
parent 1b08211a5e
commit c2fc6e311a
19 changed files with 223 additions and 18 deletions

View file

@ -31,8 +31,8 @@ path = "../net_traits"
[dependencies.util]
path = "../util"
[dependencies.webdriver_server]
path = "../webdriver_server"
[dependencies.webdriver_traits]
path = "../webdriver_traits"
[dependencies.devtools_traits]
path = "../devtools_traits"

View file

@ -39,6 +39,7 @@ use util::geometry::PagePx;
use util::opts;
use util::task::spawn_named;
use clipboard::ClipboardContext;
use webdriver_traits::WebDriverScriptCommand;
/// Maintains the pipelines and navigation context and grants permission to composite.
pub struct Constellation<LTF, STF> {
@ -410,6 +411,12 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
};
sender.send(result).unwrap();
}
ConstellationMsg::WebDriverCommandMsg(pipeline_id,
command) => {
debug!("constellation got webdriver command message");
self.handle_webdriver_command_msg(pipeline_id,
command);
}
}
true
}
@ -753,6 +760,17 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.focus_parent_pipeline(pipeline_id);
}
fn handle_webdriver_command_msg(&mut self,
pipeline_id: PipelineId,
msg: WebDriverScriptCommand) {
// Find the script channel for the given parent pipeline,
// and pass the event to that script task.
let pipeline = self.pipeline(pipeline_id);
let control_msg = ConstellationControlMsg::WebDriverCommandMsg(pipeline_id, msg);
let ScriptControlChan(ref script_channel) = pipeline.script_chan;
script_channel.send(control_msg).unwrap();
}
fn add_or_replace_pipeline_in_frame_tree(&mut self, frame_change: FrameChange) {
// If the currently focused pipeline is the one being changed (or a child

View file

@ -27,7 +27,7 @@ extern crate net_traits;
#[macro_use]
extern crate util;
extern crate gleam;
extern crate webdriver_server;
extern crate webdriver_traits;
extern crate clipboard;
extern crate libc;