Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the data_loader test with fetch. #14042

Merged
merged 6 commits into from Nov 3, 2016

Move the test_fetch_data test.

There is no longer any point in keeping it apart from the other data URL tests.
  • Loading branch information
Ms2ger committed Nov 3, 2016
commit bb9b0b3467a773041430dcf11edf1fdec7385a73
@@ -77,6 +77,15 @@ fn plain_ct() {
Some(b"hello"));
}

#[test]
fn plain_html() {
assert_parse(
"data:text/html,<p>Servo</p>",
Some(ContentType(Mime(TopLevel::Text, SubLevel::Html, vec!()))),
None,
Some(b"<p>Servo</p>"));
}

#[test]
fn plain_charset() {
assert_parse(
@@ -103,31 +103,6 @@ fn test_fetch_aboutblank() {
assert!(*fetch_response.body.lock().unwrap() == ResponseBody::Done(vec![]));
}

#[test]
fn test_fetch_data() {
let url = Url::parse("data:text/html,<p>Servo</p>").unwrap();
let origin = Origin::Origin(url.origin());
let request = Request::new(url, Some(origin), false, None);
let expected_resp_body = "<p>Servo</p>".to_owned();
let fetch_response = fetch_sync(request, None);

assert!(!fetch_response.is_network_error());
assert_eq!(fetch_response.headers.len(), 1);
let content_type: &ContentType = fetch_response.headers.get().unwrap();
assert!(**content_type == Mime(TopLevel::Text, SubLevel::Html, vec![]));
let resp_body = fetch_response.body.lock().unwrap();

match *resp_body {
ResponseBody::Done(ref val) => {
assert_eq!(val, &expected_resp_body.into_bytes());
}
ResponseBody::Receiving(_) => {
panic!();
},
ResponseBody::Empty => panic!(),
}
}

#[test]
fn test_fetch_blob() {
use ipc_channel::ipc;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.