Skip to content

Commit

Permalink
Merge pull request #51 from martiansideofthemoon/bulbasaur
Browse files Browse the repository at this point in the history
Adding a new command line argument e10s profile
  • Loading branch information
jgraham committed Mar 10, 2016
2 parents 4a8a835 + 7aac94f commit 5073da8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
14 changes: 10 additions & 4 deletions src/main.rs
Expand Up @@ -37,16 +37,19 @@ struct Options {
webdriver_host: String,
webdriver_port: u16,
marionette_port: u16,
connect_existing: bool
connect_existing: bool,
e10s: bool
}


fn parse_args() -> Options {
let mut opts = Options {
binary: "".to_owned(),
webdriver_host: "127.0.0.1".to_owned(),
webdriver_port: 4444u16,
marionette_port: 2828u16,
connect_existing: false
connect_existing: false,
e10s: false
};

{
Expand All @@ -67,14 +70,16 @@ fn parse_args() -> Options {
parser.refer(&mut opts.connect_existing)
.add_option(&["--connect-existing"], StoreTrue,
"Connect to an existing firefox process");
parser.refer(&mut opts.e10s)
.add_option(&["--e10s"], StoreTrue,
"Load Firefox with an e10s profile");
parser.parse_args_or_exit();
}

if opts.binary == "" && !opts.connect_existing {
println!("Must supply a binary path or --connect-existing\n");
exit(1)
}

opts
}

Expand All @@ -99,7 +104,8 @@ fn main() {
};

let settings = MarionetteSettings::new(opts.marionette_port,
launcher);
launcher,
opts.e10s);

//TODO: what if binary isn't a valid path?
start(addr, MarionetteHandler::new(settings), extension_routes());
Expand Down
31 changes: 24 additions & 7 deletions src/marionette.rs
Expand Up @@ -152,7 +152,16 @@ impl ToMarionette for GeckoContextParameters {
}
}

pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 50] = [
pub static E10S_PREFERENCES: [(&'static str, PrefValue); 1] = [
("browser.tabs.remote.autostart", PrefValue::PrefBool(true)),
];

pub static NON_E10S_PREFERENCES: [(&'static str, PrefValue); 2] = [
("browser.tabs.remote.autostart", PrefValue::PrefBool(false)),
("browser.tabs.remote.autostart.2", PrefValue::PrefBool(false))
];

pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 48] = [
("app.update.auto", PrefValue::PrefBool(false)),
("app.update.enabled", PrefValue::PrefBool(false)),
("browser.displayedE10SPrompt.1", PrefValue::PrefInt(5)),
Expand All @@ -170,8 +179,6 @@ pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 50] = [
("browser.sessionstore.resume_from_crash", PrefValue::PrefBool(false)),
("browser.shell.checkDefaultBrowser", PrefValue::PrefBool(false)),
("browser.startup.page", PrefValue::PrefInt(0)),
("browser.tabs.remote.autostart.1", PrefValue::PrefBool(false)),
("browser.tabs.remote.autostart.2", PrefValue::PrefBool(false)),
("browser.tabs.warnOnClose", PrefValue::PrefBool(false)),
("browser.tabs.warnOnOpen", PrefValue::PrefBool(false)),
("browser.warnOnQuit", PrefValue::PrefBool(false)),
Expand Down Expand Up @@ -213,14 +220,16 @@ pub enum BrowserLauncher {

pub struct MarionetteSettings {
port: u16,
launcher: BrowserLauncher
launcher: BrowserLauncher,
e10s: bool
}

impl MarionetteSettings {
pub fn new(port: u16, launcher: BrowserLauncher) -> MarionetteSettings {
pub fn new(port: u16, launcher: BrowserLauncher, e10s: bool) -> MarionetteSettings {
MarionetteSettings {
port: port,
launcher: launcher
launcher: launcher,
e10s: e10s
}
}
}
Expand All @@ -230,6 +239,7 @@ pub struct MarionetteHandler {
launcher: BrowserLauncher,
browser: Option<FirefoxRunner>,
port: u16,
e10s: bool,
}

impl MarionetteHandler {
Expand All @@ -238,7 +248,8 @@ impl MarionetteHandler {
connection: Mutex::new(None),
launcher: settings.launcher,
browser: None,
port: settings.port
port: settings.port,
e10s: settings.e10s
}
}

Expand All @@ -254,11 +265,17 @@ impl MarionetteHandler {
}

fn start_browser(&mut self) -> IoResult<()> {

match self.launcher {
BrowserLauncher::BinaryLauncher(ref binary) => {
let mut runner = try!(FirefoxRunner::new(&binary, None));
runner.profile.preferences.insert("marionette.defaultPrefs.port", PrefValue::PrefInt(self.port as isize));
runner.profile.preferences.insert("startup.homepage_welcome_url", PrefValue::PrefString("about:blank".to_string()));
if self.e10s {
runner.profile.preferences.insert_vec(&E10S_PREFERENCES);
} else {
runner.profile.preferences.insert_vec(&NON_E10S_PREFERENCES);
}
runner.profile.preferences.insert_vec(&FIREFOX_PREFERENCES);

try!(runner.start());
Expand Down

0 comments on commit 5073da8

Please sign in to comment.