mirror of
https://github.com/servo/servo.git
synced 2025-07-21 22:33:41 +01:00
Add a pref for a default homepage.
This commit is contained in:
parent
79e548905e
commit
8d9ab50a96
5 changed files with 46 additions and 15 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
15
tests/reftest.rs
vendored
15
tests/reftest.rs
vendored
|
@ -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") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue