diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs index 5e02839cea6..e1aff7e61c5 100644 --- a/tests/unit/net/http_loader.rs +++ b/tests/unit/net/http_loader.rs @@ -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"), - } }