mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Split test_content_blocked for readability.
This commit is contained in:
parent
3da075ca73
commit
b4178c7eaf
1 changed files with 24 additions and 14 deletions
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue