aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/util/opts.rs27
-rw-r--r--components/util/resource_files.rs15
-rw-r--r--ports/cef/core.rs1
-rw-r--r--resources/prefs.json3
-rw-r--r--tests/reftest.rs15
5 files changed, 46 insertions, 15 deletions
diff --git a/components/util/opts.rs b/components/util/opts.rs
index bdf8277adce..42dc8ec3ae6 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -10,6 +10,7 @@ use geometry::ScreenPx;
use getopts::Options;
use num_cpus;
use prefs::{self, PrefValue};
+use resource_files::set_resources_path;
use std::cmp;
use std::default::Default;
use std::env;
@@ -155,9 +156,6 @@ pub struct Opts {
/// Whether to show an error when display list geometry escapes flow overflow regions.
pub validate_display_list_geometry: bool,
- /// A specific path to find required resources (such as user-agent.css).
- pub resources_path: Option<String>,
-
/// Whether MIME sniffing should be used
pub sniff_mime_types: bool,
@@ -409,7 +407,6 @@ pub fn default_opts() -> Opts {
validate_display_list_geometry: false,
profile_tasks: false,
profile_script_events: false,
- resources_path: None,
sniff_mime_types: false,
disable_share_style_cache: false,
parallel_display_list_building: false,
@@ -460,6 +457,8 @@ pub fn from_cmdline_args(args: &[String]) {
Err(f) => args_fail(&f.to_string()),
};
+ set_resources_path(opt_match.opt_str("resources-path"));
+
if opt_match.opt_present("h") || opt_match.opt_present("help") {
print_usage(app_name, &opts);
process::exit(0);
@@ -480,12 +479,21 @@ pub fn from_cmdline_args(args: &[String]) {
}
let cwd = env::current_dir().unwrap();
- let url = if opt_match.free.is_empty() {
- print_usage(app_name, &opts);
- args_fail("servo asks that you provide a URL")
+ let homepage_pref = prefs::get_pref("shell.homepage");
+ let url_opt = if !opt_match.free.is_empty() {
+ Some(&opt_match.free[0][..])
} else {
- parse_url_or_filename(&cwd, &opt_match.free[0])
- .unwrap_or_else(|()| args_fail("URL parsing failed"))
+ homepage_pref.as_string()
+ };
+ let url = match url_opt {
+ Some(url_string) => {
+ parse_url_or_filename(&cwd, url_string)
+ .unwrap_or_else(|()| args_fail("URL parsing failed"))
+ },
+ None => {
+ print_usage(app_name, &opts);
+ args_fail("servo asks that you provide a URL")
+ }
};
let tile_size: usize = match opt_match.opt_str("s") {
@@ -602,7 +610,6 @@ pub fn from_cmdline_args(args: &[String]) {
dump_display_list_optimized: debug_options.dump_display_list_optimized,
relayout_event: debug_options.relayout_event,
validate_display_list_geometry: debug_options.validate_display_list_geometry,
- resources_path: opt_match.opt_str("resources-path"),
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
disable_share_style_cache: debug_options.disable_share_style_cache,
parallel_display_list_building: debug_options.parallel_display_list_building,
diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs
index 41a09511078..68d735697c7 100644
--- a/components/util/resource_files.rs
+++ b/components/util/resource_files.rs
@@ -5,6 +5,18 @@
use std::fs::File;
use std::io::{self, Read};
use std::path::PathBuf;
+use std::sync::{Arc, Mutex};
+
+lazy_static! {
+ static ref CMD_RESOURCE_DIR: Arc<Mutex<Option<String>>> = {
+ Arc::new(Mutex::new(None))
+ };
+}
+
+pub fn set_resources_path(path: Option<String>) {
+ let mut dir = CMD_RESOURCE_DIR.lock().unwrap();
+ *dir = path;
+}
#[cfg(target_os = "android")]
pub fn resources_dir_path() -> PathBuf {
@@ -13,11 +25,10 @@ pub fn resources_dir_path() -> PathBuf {
#[cfg(not(target_os = "android"))]
pub fn resources_dir_path() -> PathBuf {
- use opts;
use std::env;
use std::fs::PathExt;
- match opts::get().resources_path {
+ match *CMD_RESOURCE_DIR.lock().unwrap() {
Some(ref path) => PathBuf::from(path),
None => {
// FIXME: Find a way to not rely on the executable being
diff --git a/ports/cef/core.rs b/ports/cef/core.rs
index 5df87bd0c6f..6a2b86e54c2 100644
--- a/ports/cef/core.rs
+++ b/ports/cef/core.rs
@@ -74,7 +74,6 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
temp_opts.hard_fail = false;
temp_opts.enable_text_antialiasing = true;
temp_opts.enable_canvas_antialiasing = true;
- temp_opts.resources_path = None;
temp_opts.url = None;
opts::set_defaults(temp_opts);
diff --git a/resources/prefs.json b/resources/prefs.json
index 3f7ad3a9cbb..8a56d8752e3 100644
--- a/resources/prefs.json
+++ b/resources/prefs.json
@@ -9,5 +9,6 @@
"layout.flex-direction.enabled": false,
"layout.text-orientation.enabled": false,
"layout.viewport.enabled": false,
- "layout.writing-mode.enabled": false
+ "layout.writing-mode.enabled": false,
+ "shell.homepage": "http://doc.servo.org/servo/index.html"
}
diff --git a/tests/reftest.rs b/tests/reftest.rs
index a9430789f9e..b055f09580d 100644
--- a/tests/reftest.rs
+++ b/tests/reftest.rs
@@ -25,6 +25,7 @@ use std::io::{self, Read, Result};
use std::path::{Path, PathBuf};
use std::process;
use std::process::{Command, Stdio};
+use std::thread::sleep_ms;
use test::run_tests_console;
use test::{AutoColor, DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn, ShouldPanic};
use url::Url;
@@ -111,10 +112,22 @@ fn run(test_opts: TestOpts, all_tests: Vec<TestDescAndFn>,
// Verify that we're passing in valid servo arguments. Otherwise, servo
// will exit before we've run any tests, and it will appear to us as if
// all the tests are failing.
- let output = match Command::new(&servo_path()).args(&servo_args).output() {
+ let mut command = Command::new(&servo_path());
+ command
+ .args(&servo_args)
+ .arg("-z")
+ .arg("about:blank");
+
+ let mut child = match command.spawn() {
Ok(p) => p,
Err(e) => panic!("failed to execute process: {}", e),
};
+
+ // Wait for the shell to launch or to fail
+ sleep_ms(1000);
+ child.kill().unwrap();
+ let output = try!(child.wait_with_output());
+
let stderr = String::from_utf8(output.stderr).unwrap();
if stderr.contains("Unrecognized") {