mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Implement port-based blocking
This commit is contained in:
parent
71b68ea0de
commit
a56a7baa9a
4 changed files with 113 additions and 0 deletions
|
@ -23,6 +23,7 @@ use hyper::status::StatusCode;
|
|||
use hyper::uri::RequestUri;
|
||||
use msg::constellation_msg::TEST_PIPELINE_ID;
|
||||
use net::fetch::cors_cache::CorsCache;
|
||||
use net_traits::NetworkError;
|
||||
use net_traits::ReferrerPolicy;
|
||||
use net_traits::request::{Origin, RedirectMode, Referrer, Request, RequestMode};
|
||||
use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
|
||||
|
@ -59,6 +60,18 @@ fn test_fetch_response_is_not_network_error() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fetch_on_bad_port_is_network_error() {
|
||||
let url = ServoUrl::parse("http://www.example.org:6667").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(request, None);
|
||||
assert!(fetch_response.is_network_error());
|
||||
let fetch_error = fetch_response.get_network_error().unwrap();
|
||||
assert!(fetch_error == &NetworkError::Internal("Request attempted on bad port".into()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fetch_response_body_matches_const_message() {
|
||||
static MESSAGE: &'static [u8] = b"Hello World!";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue