mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #14315 - servo:fetch-unit-http, r=Manishearth
Rewrite and remove most unit tests for the legacy fetch stack. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14315) <!-- Reviewable:end -->
This commit is contained in:
commit
5bfe1de10a
4 changed files with 192 additions and 1145 deletions
|
@ -76,6 +76,5 @@ pub mod fetch {
|
||||||
/// A module for re-exports of items used in unit tests.
|
/// A module for re-exports of items used in unit tests.
|
||||||
pub mod test {
|
pub mod test {
|
||||||
pub use chrome_loader::resolve_chrome_url;
|
pub use chrome_loader::resolve_chrome_url;
|
||||||
pub use http_loader::{HttpRequest, HttpRequestFactory, HttpResponse, HttpState};
|
pub use http_loader::HttpState;
|
||||||
pub use http_loader::{LoadError, LoadErrorType, UIProvider, load};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,26 @@ fn test_fetch_file() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fetch_ftp() {
|
||||||
|
let url = ServoUrl::parse("ftp://not-supported").unwrap();
|
||||||
|
let origin = Origin::Origin(url.origin());
|
||||||
|
let request = Request::new(url, Some(origin), false, None);
|
||||||
|
*request.referrer.borrow_mut() = Referrer::NoReferrer;
|
||||||
|
let fetch_response = fetch_sync(request, None);
|
||||||
|
assert!(fetch_response.is_network_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fetch_bogus_scheme() {
|
||||||
|
let url = ServoUrl::parse("bogus://whatever").unwrap();
|
||||||
|
let origin = Origin::Origin(url.origin());
|
||||||
|
let request = Request::new(url, Some(origin), false, None);
|
||||||
|
*request.referrer.borrow_mut() = Referrer::NoReferrer;
|
||||||
|
let fetch_response = fetch_sync(request, None);
|
||||||
|
assert!(fetch_response.is_network_error());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cors_preflight_fetch() {
|
fn test_cors_preflight_fetch() {
|
||||||
static ACK: &'static [u8] = b"ACK";
|
static ACK: &'static [u8] = b"ACK";
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,26 +43,6 @@ fn test_exit() {
|
||||||
receiver.recv().unwrap();
|
receiver.recv().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_bad_scheme() {
|
|
||||||
let (tx, _rx) = ipc::channel().unwrap();
|
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
|
||||||
let (resource_thread, _) = new_core_resource_thread(
|
|
||||||
"".into(), None, ProfilerChan(tx), None);
|
|
||||||
let (start_chan, start) = ipc::channel().unwrap();
|
|
||||||
let url = ServoUrl::parse("bogus://whatever").unwrap();
|
|
||||||
resource_thread.send(CoreResourceMsg::Load(LoadData::new(LoadContext::Browsing, url, &ResourceTest),
|
|
||||||
|
|
||||||
LoadConsumer::Channel(start_chan), None)).unwrap();
|
|
||||||
let response = start.recv().unwrap();
|
|
||||||
match response.progress_port.recv().unwrap() {
|
|
||||||
ProgressMsg::Done(result) => { assert!(result.is_err()) }
|
|
||||||
_ => panic!("bleh")
|
|
||||||
}
|
|
||||||
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
|
|
||||||
receiver.recv().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_hostsfile() {
|
fn test_parse_hostsfile() {
|
||||||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com\n127.0.0.2 servo.test.server";
|
let mock_hosts_file_content = "127.0.0.1 foo.bar.com\n127.0.0.2 servo.test.server";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue