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 and remove most unit tests for the legacy fetch stack. #14315

Merged
merged 14 commits into from Nov 24, 2016

Split test_content_blocked for readability.

  • Loading branch information
Ms2ger committed Nov 23, 2016
commit b4178c7eaf327f30b076afb702362a08cd35f913
@@ -1501,12 +1501,33 @@ fn test_content_blocked() {
}

let blocked_url = ServoUrl::parse("http://mozilla.com").unwrap();
let url_without_cookies = ServoUrl::parse("http://mozilla2.com").unwrap();
let mut http_state = HttpState::new();

let blocked_content_list = "[{ \"trigger\": { \"url-filter\": \"https?://mozilla.com\" }, \
\"action\": { \"type\": \"block\" } },\
{ \"trigger\": { \"url-filter\": \"https?://mozilla2.com\" }, \
\"action\": { \"type\": \"block\" } }]";
http_state.blocked_content = Arc::new(parse_list(blocked_content_list).ok());
assert!(http_state.blocked_content.is_some());

let ui_provider = TestProvider::new();

let load_data = LoadData::new(LoadContext::Browsing, blocked_url, &HttpTest);

let response = load(
&load_data, &ui_provider, &http_state,
None, &Factory,
DEFAULT_USER_AGENT.into(), &CancellationListener::new(None), None);
match response {
Err(LoadError { error: LoadErrorType::ContentBlocked, .. }) => {},
_ => panic!("request should have been blocked"),
}
}

#[test]
fn test_cookies_blocked() {
let url_without_cookies = ServoUrl::parse("http://mozilla2.com").unwrap();
let mut http_state = HttpState::new();

let blocked_content_list = "[{ \"trigger\": { \"url-filter\": \"https?://mozilla2.com\" }, \
\"action\": { \"type\": \"block-cookies\" } }]";
http_state.blocked_content = Arc::new(parse_list(blocked_content_list).ok());
assert!(http_state.blocked_content.is_some());
@@ -1535,15 +1556,4 @@ fn test_content_blocked() {
Ok(_) => {},
_ => panic!("request should have succeeded without cookies"),
}

let load_data = LoadData::new(LoadContext::Browsing, blocked_url, &HttpTest);

let response = load(
&load_data, &ui_provider, &http_state,
None, &Factory,
DEFAULT_USER_AGENT.into(), &CancellationListener::new(None), None);
match response {
Err(LoadError { error: LoadErrorType::ContentBlocked, .. }) => {},
_ => panic!("request should have been blocked"),
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.