mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Rustfmt has changed its default style :/
This commit is contained in:
parent
82fc6d9f49
commit
be69f9c3e6
207 changed files with 1200 additions and 1339 deletions
|
@ -260,25 +260,19 @@ fn test_cors_preflight_fetch() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.get(header::REFERER)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.contains("a.html")
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.get(header::REFERER)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.contains("a.html"));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -324,16 +318,12 @@ fn test_cors_preflight_cache_fetch() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -393,16 +383,12 @@ fn test_cors_preflight_fetch_network_error() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -461,11 +447,9 @@ fn test_fetch_response_is_basic_filtered() {
|
|||
|
||||
let headers = fetch_response.headers;
|
||||
assert!(!headers.contains_key(header::SET_COOKIE));
|
||||
assert!(
|
||||
headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none()
|
||||
);
|
||||
assert!(headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -535,11 +519,9 @@ fn test_fetch_response_is_cors_filtered() {
|
|||
|
||||
assert!(!headers.contains_key(header::ACCESS_CONTROL_ALLOW_ORIGIN));
|
||||
assert!(!headers.contains_key(header::SET_COOKIE));
|
||||
assert!(
|
||||
headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none()
|
||||
);
|
||||
assert!(headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -102,14 +102,12 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
Some(500000u64),
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
Some(500000u64),
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let mut list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
@ -180,14 +178,12 @@ fn test_push_entry_to_hsts_list_should_not_create_duplicate_entry() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let mut list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
@ -286,14 +282,12 @@ fn test_hsts_list_with_exact_domain_entry_is_is_host_secure() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
|
||||
let hsts_list = HstsList {
|
||||
|
@ -322,14 +316,12 @@ fn test_hsts_list_with_subdomain_when_include_subdomains_is_false_is_not_is_host
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let hsts_list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cookie_rs::Cookie as CookiePair;
|
||||
use crate::fetch;
|
||||
use crate::fetch_with_context;
|
||||
use crate::make_server;
|
||||
use crate::new_fetch_context;
|
||||
use cookie_rs::Cookie as CookiePair;
|
||||
use crossbeam_channel::{unbounded, Receiver};
|
||||
use devtools_traits::HttpRequest as DevtoolsHttpRequest;
|
||||
use devtools_traits::HttpResponse as DevtoolsHttpResponse;
|
||||
|
@ -144,15 +144,13 @@ fn test_check_default_headers_loaded_in_every_request() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
// Testing for method.POST
|
||||
let mut post_headers = headers.clone();
|
||||
|
@ -174,15 +172,13 @@ fn test_check_default_headers_loaded_in_every_request() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
@ -208,15 +204,13 @@ fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
@ -245,15 +239,13 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = unbounded();
|
||||
let response = fetch(&mut request, Some(devtools_chan));
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
|
||||
|
@ -346,15 +338,13 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = unbounded();
|
||||
let response = fetch(&mut request, Some(devtools_chan));
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
|
||||
|
@ -592,15 +582,13 @@ fn test_load_doesnt_add_host_to_sts_list_when_url_is_http_even_if_sts_headers_ar
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
assert_eq!(
|
||||
context
|
||||
.state
|
||||
|
@ -641,15 +629,13 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(
|
||||
&context.state.cookie_jar,
|
||||
|
@ -696,15 +682,13 @@ fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_re
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -745,15 +729,13 @@ fn test_load_sends_cookie_if_nonhttp() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -785,15 +767,13 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(
|
||||
&context.state.cookie_jar,
|
||||
|
@ -801,11 +781,9 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
|||
Some("mozillaIs=theBest"),
|
||||
);
|
||||
let mut cookie_jar = context.state.cookie_jar.write().unwrap();
|
||||
assert!(
|
||||
cookie_jar
|
||||
.cookies_for_url(&url, CookieSource::NonHTTP)
|
||||
.is_none()
|
||||
);
|
||||
assert!(cookie_jar
|
||||
.cookies_for_url(&url, CookieSource::NonHTTP)
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -837,15 +815,13 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(&context.state.cookie_jar, url.as_str(), None);
|
||||
}
|
||||
|
@ -876,15 +852,13 @@ fn test_load_sets_content_length_to_length_of_request_body() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -918,15 +892,13 @@ fn test_load_uses_explicit_accept_from_headers_in_load_data() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -957,15 +929,13 @@ fn test_load_sets_default_accept_to_html_xhtml_xml_and_then_anything_else() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -999,15 +969,13 @@ fn test_load_uses_explicit_accept_encoding_from_load_data_headers() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1038,15 +1006,13 @@ fn test_load_sets_default_accept_encoding_to_gzip_and_deflate() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1374,15 +1340,13 @@ fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1439,15 +1403,13 @@ fn test_origin_set() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let origin_url = ServoUrl::parse("http://example.com").unwrap();
|
||||
origin =
|
||||
|
@ -1464,15 +1426,13 @@ fn test_origin_set() {
|
|||
|
||||
*origin_header_clone.lock().unwrap() = Some(origin.clone());
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
// Test Origin header is not set on method Head
|
||||
let mut request = Request::from_init(RequestInit {
|
||||
|
@ -1485,15 +1445,13 @@ fn test_origin_set() {
|
|||
|
||||
*origin_header_clone.lock().unwrap() = None;
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue