mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Upgrade to rust-url 1.0 and hyper 0.9
This commit is contained in:
parent
305c283602
commit
7932ab6ac2
76 changed files with 524 additions and 888 deletions
|
@ -31,8 +31,8 @@ git = "https://github.com/servo/ipc-channel"
|
|||
|
||||
[dependencies]
|
||||
cookie = "0.2"
|
||||
hyper = "0.8"
|
||||
url = {version = "0.5.7", features = ["heap_size"]}
|
||||
hyper = "0.9"
|
||||
url = {version = "1.0.0", features = ["heap_size"]}
|
||||
time = "0.1"
|
||||
flate2 = "0.2.0"
|
||||
unicase = "1.0"
|
||||
|
|
|
@ -7,40 +7,40 @@ use url::Url;
|
|||
|
||||
#[test]
|
||||
fn test_relative() {
|
||||
let url = Url::parse("chrome://../something").unwrap();
|
||||
let url = Url::parse("chrome:/../something").unwrap();
|
||||
assert!(resolve_chrome_url(&url).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_2() {
|
||||
let url = Url::parse("chrome://subdir/../something").unwrap();
|
||||
let url = Url::parse("chrome:/subdir/../something").unwrap();
|
||||
assert!(resolve_chrome_url(&url).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn test_absolute() {
|
||||
let url = Url::parse("chrome:///etc/passwd").unwrap();
|
||||
let url = Url::parse("chrome:/etc/passwd").unwrap();
|
||||
assert!(resolve_chrome_url(&url).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn test_absolute_2() {
|
||||
let url = Url::parse("chrome://C:\\Windows").unwrap();
|
||||
let url = Url::parse("chrome:/C:\\Windows").unwrap();
|
||||
assert!(resolve_chrome_url(&url).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn test_absolute_3() {
|
||||
let url = Url::parse("chrome://\\\\server/C$").unwrap();
|
||||
let url = Url::parse("chrome:/\\\\server/C$").unwrap();
|
||||
assert!(resolve_chrome_url(&url).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_valid() {
|
||||
let url = Url::parse("chrome://badcert.jpg").unwrap();
|
||||
let url = Url::parse("chrome:/badcert.jpg").unwrap();
|
||||
let resolved = resolve_chrome_url(&url).unwrap();
|
||||
assert_eq!(resolved.scheme, "file");
|
||||
assert_eq!(resolved.scheme(), "file");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::sync::mpsc::{Sender, channel};
|
|||
use std::sync::{Arc, Mutex};
|
||||
use time::{self, Duration};
|
||||
use unicase::UniCase;
|
||||
use url::{Origin as UrlOrigin, OpaqueOrigin, Url};
|
||||
use url::{Origin as UrlOrigin, Url};
|
||||
|
||||
// TODO write a struct that impls Handler for storing test values
|
||||
|
||||
|
@ -156,7 +156,7 @@ fn test_cors_preflight_fetch() {
|
|||
};
|
||||
let (mut server, url) = make_server(handler);
|
||||
|
||||
let origin = Origin::Origin(UrlOrigin::UID(OpaqueOrigin::new()));
|
||||
let origin = Origin::Origin(UrlOrigin::new_opaque());
|
||||
let mut request = Request::new(url, Some(origin), false);
|
||||
request.referer = Referer::NoReferer;
|
||||
request.use_cors_preflight = true;
|
||||
|
@ -192,7 +192,7 @@ fn test_cors_preflight_fetch_network_error() {
|
|||
};
|
||||
let (mut server, url) = make_server(handler);
|
||||
|
||||
let origin = Origin::Origin(UrlOrigin::UID(OpaqueOrigin::new()));
|
||||
let origin = Origin::Origin(UrlOrigin::new_opaque());
|
||||
let mut request = Request::new(url, Some(origin), false);
|
||||
*request.method.borrow_mut() = Method::Extension("CHICKEN".to_owned());
|
||||
request.referer = Referer::NoReferer;
|
||||
|
@ -269,7 +269,7 @@ fn test_fetch_response_is_cors_filtered() {
|
|||
let (mut server, url) = make_server(handler);
|
||||
|
||||
// an origin mis-match will stop it from defaulting to a basic filtered response
|
||||
let origin = Origin::Origin(UrlOrigin::UID(OpaqueOrigin::new()));
|
||||
let origin = Origin::Origin(UrlOrigin::new_opaque());
|
||||
let mut request = Request::new(url, Some(origin), false);
|
||||
request.referer = Referer::NoReferer;
|
||||
request.mode = RequestMode::CORSMode;
|
||||
|
@ -304,7 +304,7 @@ fn test_fetch_response_is_opaque_filtered() {
|
|||
let (mut server, url) = make_server(handler);
|
||||
|
||||
// an origin mis-match will fall through to an Opaque filtered response
|
||||
let origin = Origin::Origin(UrlOrigin::UID(OpaqueOrigin::new()));
|
||||
let origin = Origin::Origin(UrlOrigin::new_opaque());
|
||||
let mut request = Request::new(url, Some(origin), false);
|
||||
request.referer = Referer::NoReferer;
|
||||
let wrapped_request = Rc::new(request);
|
||||
|
@ -340,7 +340,7 @@ fn test_fetch_response_is_opaque_redirect_filtered() {
|
|||
RequestUri::AbsolutePath(url) =>
|
||||
url.split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
RequestUri::AbsoluteUri(url) =>
|
||||
url.path().unwrap().last().unwrap().split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
url.path_segments().unwrap().next_back().unwrap().parse::<u32>().unwrap_or(0),
|
||||
_ => panic!()
|
||||
};
|
||||
|
||||
|
@ -420,7 +420,7 @@ fn setup_server_and_fetch(message: &'static [u8], redirect_cap: u32) -> Response
|
|||
RequestUri::AbsolutePath(url) =>
|
||||
url.split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
RequestUri::AbsoluteUri(url) =>
|
||||
url.path().unwrap().last().unwrap().split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
url.path_segments().unwrap().next_back().unwrap().parse::<u32>().unwrap_or(0),
|
||||
_ => panic!()
|
||||
};
|
||||
|
||||
|
@ -493,7 +493,7 @@ fn test_fetch_redirect_updates_method_runner(tx: Sender<bool>, status_code: Stat
|
|||
RequestUri::AbsolutePath(url) =>
|
||||
url.split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
RequestUri::AbsoluteUri(url) =>
|
||||
url.path().unwrap().last().unwrap().split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
url.path_segments().unwrap().next_back().unwrap().parse::<u32>().unwrap_or(0),
|
||||
_ => panic!()
|
||||
};
|
||||
|
||||
|
@ -631,7 +631,7 @@ fn test_opaque_filtered_fetch_async_returns_complete_response() {
|
|||
let (mut server, url) = make_server(handler);
|
||||
|
||||
// an origin mis-match will fall through to an Opaque filtered response
|
||||
let origin = Origin::Origin(UrlOrigin::UID(OpaqueOrigin::new()));
|
||||
let origin = Origin::Origin(UrlOrigin::new_opaque());
|
||||
let mut request = Request::new(url, Some(origin), false);
|
||||
request.referer = Referer::NoReferer;
|
||||
|
||||
|
@ -658,7 +658,7 @@ fn test_opaque_redirect_filtered_fetch_async_returns_complete_response() {
|
|||
RequestUri::AbsolutePath(url) =>
|
||||
url.split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
RequestUri::AbsoluteUri(url) =>
|
||||
url.path().unwrap().last().unwrap().split("/").collect::<String>().parse::<u32>().unwrap_or(0),
|
||||
url.path_segments().unwrap().last().unwrap().parse::<u32>().unwrap_or(0),
|
||||
_ => panic!()
|
||||
};
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ fn test_secure_url_does_not_affect_non_http_schemas() {
|
|||
let url = Url::parse("file://mozilla.org").unwrap();
|
||||
let secure = secure_url(&url);
|
||||
|
||||
assert_eq!(&secure.scheme, "file");
|
||||
assert_eq!(secure.scheme(), "file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -275,5 +275,5 @@ fn test_secure_url_forces_an_http_host_in_list_to_https() {
|
|||
let url = Url::parse("http://mozilla.org").unwrap();
|
||||
let secure = secure_url(&url);
|
||||
|
||||
assert_eq!(&secure.scheme, "https");
|
||||
assert_eq!(secure.scheme(), "https");
|
||||
}
|
||||
|
|
|
@ -1091,7 +1091,7 @@ fn test_load_errors_when_there_is_too_many_redirects() {
|
|||
|
||||
fn create(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
Ok(MockRequest::new(ResponseType::Redirect(format!("{}/1", url.serialize()))))
|
||||
Ok(MockRequest::new(ResponseType::Redirect(format!("{}/1", url))))
|
||||
} else {
|
||||
panic!("unexpected host {:?}", url)
|
||||
}
|
||||
|
@ -1334,13 +1334,13 @@ fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() {
|
|||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method, headers: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.path().unwrap()[0] == "initial" {
|
||||
if url.path_segments().unwrap().next().unwrap() == "initial" {
|
||||
let mut initial_answer_headers = Headers::new();
|
||||
initial_answer_headers.set_raw("set-cookie", vec![b"mozillaIs=theBest; path=/;".to_vec()]);
|
||||
Ok(MockRequest::new(
|
||||
ResponseType::RedirectWithHeaders("http://mozilla.org/subsequent/".to_owned(),
|
||||
initial_answer_headers)))
|
||||
} else if url.path().unwrap()[0] == "subsequent" {
|
||||
} else if url.path_segments().unwrap().next().unwrap() == "subsequent" {
|
||||
let mut expected_subsequent_headers = Headers::new();
|
||||
expected_subsequent_headers.set_raw("Cookie", vec![b"mozillaIs=theBest".to_vec()]);
|
||||
assert_headers_included(&expected_subsequent_headers, &headers);
|
||||
|
|
|
@ -8,9 +8,14 @@ use net_traits::hosts::{parse_hostsfile, host_replacement};
|
|||
use net_traits::{ControlMsg, LoadData, LoadConsumer, LoadContext, NetworkError, ProgressMsg};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::HashMap;
|
||||
use std::net::IpAddr;
|
||||
use std::sync::mpsc::channel;
|
||||
use url::Url;
|
||||
|
||||
fn ip(s: &str) -> IpAddr {
|
||||
s.parse().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exit() {
|
||||
let resource_thread = new_resource_thread("".to_owned(), None);
|
||||
|
@ -37,8 +42,8 @@ fn test_parse_hostsfile() {
|
|||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com\n127.0.0.2 servo.test.server";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.2".to_owned(), *hosts_table.get(&"servo.test.server".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -46,7 +51,7 @@ fn test_parse_malformed_hostsfile() {
|
|||
let mock_hosts_file_content = "malformed file\n127.0.0.1 foo.bar.com\nservo.test.server 127.0.0.1";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(1, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -54,7 +59,7 @@ fn test_parse_hostsfile_with_line_comment() {
|
|||
let mock_hosts_file_content = "# this is a line comment\n127.0.0.1 foo.bar.com\n# anothercomment";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(1, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -62,8 +67,8 @@ fn test_parse_hostsfile_with_end_of_line_comment() {
|
|||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com # line ending comment\n127.0.0.2 servo.test.server #comment";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.2".to_owned(), *hosts_table.get(&"servo.test.server".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -71,8 +76,8 @@ fn test_parse_hostsfile_with_2_hostnames_for_1_address() {
|
|||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com baz.bar.com";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"baz.bar.com".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("baz.bar.com").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -80,10 +85,10 @@ fn test_parse_hostsfile_with_4_hostnames_for_1_address() {
|
|||
let mock_hosts_file_content = "127.0.0.1 moz.foo.com moz.bar.com moz.baz.com moz.moz.com";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(4, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"moz.foo.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"moz.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"moz.baz.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"moz.moz.com".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("moz.foo.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("moz.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("moz.baz.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("moz.moz.com").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -91,8 +96,8 @@ fn test_parse_hostsfile_with_tabs_instead_spaces() {
|
|||
let mock_hosts_file_content = "127.0.0.1\tfoo.bar.com\n127.0.0.2\tservo.test.server";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.2".to_owned(), *hosts_table.get(&"servo.test.server".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -145,25 +150,25 @@ fn test_parse_hostsfile_with_end_of_line_whitespace()
|
|||
127.0.0.2 servo.test.server ";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(3, hosts_table.len());
|
||||
assert_eq!("127.0.0.1".to_owned(), *hosts_table.get(&"foo.bar.com".to_owned()).unwrap());
|
||||
assert_eq!("2001:db8:0:0:0:ff00:42:8329".to_owned(), *hosts_table.get(&"moz.foo.com".to_owned()).unwrap());
|
||||
assert_eq!("127.0.0.2".to_owned(), *hosts_table.get(&"servo.test.server".to_owned()).unwrap());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("2001:db8:0:0:0:ff00:42:8329"), *hosts_table.get("moz.foo.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_replace_hosts() {
|
||||
let mut host_table = HashMap::new();
|
||||
host_table.insert("foo.bar.com".to_owned(), "127.0.0.1".to_owned());
|
||||
host_table.insert("servo.test.server".to_owned(), "127.0.0.2".to_owned());
|
||||
host_table.insert("foo.bar.com".to_owned(), ip("127.0.0.1"));
|
||||
host_table.insert("servo.test.server".to_owned(), ip("127.0.0.2"));
|
||||
|
||||
let url = Url::parse("http://foo.bar.com:8000/foo").unwrap();
|
||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.1");
|
||||
assert_eq!(host_replacement(&host_table, &url).host_str().unwrap(), "127.0.0.1");
|
||||
|
||||
let url = Url::parse("http://servo.test.server").unwrap();
|
||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.2");
|
||||
assert_eq!(host_replacement(&host_table, &url).host_str().unwrap(), "127.0.0.2");
|
||||
|
||||
let url = Url::parse("http://a.foo.bar.com").unwrap();
|
||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "a.foo.bar.com");
|
||||
assert_eq!(host_replacement(&host_table, &url).host_str().unwrap(), "a.foo.bar.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -21,4 +21,4 @@ path = "../../../components/script"
|
|||
path = "../../../components/util"
|
||||
|
||||
[dependencies]
|
||||
url = {version = "0.5.8", features = ["heap_size"]}
|
||||
url = {version = "1.0.0", features = ["heap_size"]}
|
||||
|
|
|
@ -29,4 +29,4 @@ cssparser = {version = "0.5.4", features = ["heap_size"]}
|
|||
euclid = {version = "0.6.4", features = ["plugins"]}
|
||||
selectors = {version = "0.5", features = ["heap_size"]}
|
||||
string_cache = {version = "0.2.12", features = ["heap_size"]}
|
||||
url = {version = "0.5.7", features = ["heap_size"]}
|
||||
url = {version = "1.0.0", features = ["heap_size"]}
|
||||
|
|
|
@ -17,11 +17,11 @@ fn test_argument_parsing() {
|
|||
assert!(parse_url_or_filename(fake_cwd, "http://example.net:invalid").is_err());
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "http://example.net").unwrap();
|
||||
assert_eq!(url.scheme, "http");
|
||||
assert_eq!(url.scheme(), "http");
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "file:///foo/bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["foo", "bar.html"]);
|
||||
assert_eq!(url.scheme(), "file");
|
||||
assert_eq!(url.path_segments().unwrap().collect::<Vec<_>>(), ["foo", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -30,8 +30,8 @@ fn test_file_path_parsing() {
|
|||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["fake", "cwd", "bar.html"]);
|
||||
assert_eq!(url.scheme(), "file");
|
||||
assert_eq!(url.path_segments().unwrap().collect::<Vec<_>>(), ["fake", "cwd", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -40,8 +40,8 @@ fn test_file_path_parsing() {
|
|||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["C:", "fake", "cwd", "bar.html"]);
|
||||
assert_eq!(url.scheme(), "file");
|
||||
assert_eq!(url.path_segments().unwrap().collect::<Vec<_>>(), ["C:", "fake", "cwd", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -53,16 +53,17 @@ fn test_argument_parsing_special() {
|
|||
// '?' and '#' have a special meaning in URLs...
|
||||
let url = parse_url_or_filename(fake_cwd, "file:///foo/bar?baz#buzz.html").unwrap();
|
||||
assert_eq!(&*url.to_file_path().unwrap(), Path::new("/foo/bar"));
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["foo", "bar"]);
|
||||
assert_eq!(url.query.unwrap(), "baz");
|
||||
assert_eq!(url.fragment.unwrap(), "buzz.html");
|
||||
assert_eq!(url.scheme(), "file");
|
||||
assert_eq!(url.path_segments().unwrap().collect::<Vec<_>>(), ["foo", "bar"]);
|
||||
assert_eq!(url.query(), Some("baz"));
|
||||
assert_eq!(url.fragment(), Some("buzz.html"));
|
||||
|
||||
// but not in file names.
|
||||
let url = parse_url_or_filename(fake_cwd, "./bar?baz#buzz.html").unwrap();
|
||||
assert_eq!(&*url.to_file_path().unwrap(), Path::new("/fake/cwd/bar?baz#buzz.html"));
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["fake", "cwd", "bar%3Fbaz%23buzz.html"]);
|
||||
assert!(url.query.is_none());
|
||||
assert!(url.fragment.is_none());
|
||||
assert_eq!(url.scheme(), "file");
|
||||
assert_eq!(url.path_segments().unwrap().collect::<Vec<_>>(),
|
||||
["fake", "cwd", "bar%3Fbaz%23buzz.html"]);
|
||||
assert_eq!(url.query(), None);
|
||||
assert_eq!(url.fragment(), None);
|
||||
}
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
[url-constructor.html]
|
||||
type: testharness
|
||||
[Parsing: <#β> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://www.google.com/foo?bar=baz# »> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:test# »> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://你好你好> against <http://other.com/>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <foo://> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <foo://///////> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <foo://///////bar.com/> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <foo:////://///> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <file:/example.com/> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -63,99 +39,9 @@
|
|||
[Parsing: <file:test> against <file:///tmp/mock/path>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <httpa://foo:80/> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <file:/example.com/> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#> against <test:test>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#x> against <mailto:x@x.com>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#x> against <data:,>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#x> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#> against <test:test?test>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <i> against <sc:/pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <i> against <sc://ho/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <i> against <sc:///pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <../i> against <sc:/pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <../i> against <sc://ho/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <../i> against <sc:///pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: </i> against <sc:/pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: </i> against <sc://ho/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: </i> against <sc:///pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <?i> against <sc:/pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <?i> against <sc://ho/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <?i> against <sc:///pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#i> against <sc:sd>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#i> against <sc:sd/sd>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#i> against <sc:/pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#i> against <sc://ho/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <#i> against <sc:///pa/pa>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <about:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <data:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <javascript:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <mailto:/../> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <sc://ñ.test/> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://&a:foo(b\]c@d:2/> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://::@c@d:2> against <http://example.org/foo/bar>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <//server/file> against <file:///tmp/mock/path>]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -186,15 +72,6 @@
|
|||
[Parsing: <file:a> against <http://www.example.com/test>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://example.com/foo/%2e%2> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <http://www/foo%2Ehtml> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
[Parsing: <h\tt\nt\rp://h\to\ns\rt:9\t0\n0\r0/p\ta\nt\rh?q\tu\ne\rry#f\tr\na\rg> against <about:blank>]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[018.html]
|
||||
type: testharness
|
||||
[WebSockets: NULL char in url]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue