Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove unused content blocker code.
I don't know what it is for, so I believe it would be better to remove it
entirely until and unless we start using it.
  • Loading branch information
Ms2ger committed Mar 7, 2017
1 parent e3cc2dd commit 5a61d8b
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 118 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions components/net/Cargo.toml
Expand Up @@ -11,15 +11,13 @@ path = "lib.rs"

[dependencies]
brotli = "1.0.6"
content-blocker = "0.2.3"
cookie = "0.2.5"
devtools_traits = {path = "../devtools_traits"}
flate2 = "0.2.0"
hyper = "0.9.9"
hyper_serde = "0.5"
immeta = "0.3.1"
ipc-channel = "0.7"
lazy_static = "0.2"
log = "0.3.5"
matches = "0.1"
mime = "0.2.1"
Expand Down
31 changes: 0 additions & 31 deletions components/net/content_blocker.rs

This file was deleted.

3 changes: 0 additions & 3 deletions components/net/http_loader.rs
Expand Up @@ -4,7 +4,6 @@

use brotli::Decompressor;
use connector::{Connector, create_http_connector};
use content_blocker_parser::RuleList;
use cookie;
use cookie_storage::CookieStorage;
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest};
Expand Down Expand Up @@ -70,7 +69,6 @@ pub struct HttpState {
pub hsts_list: Arc<RwLock<HstsList>>,
pub cookie_jar: Arc<RwLock<CookieStorage>>,
pub auth_cache: Arc<RwLock<AuthCache>>,
pub blocked_content: Arc<Option<RuleList>>,
pub connector_pool: Arc<Pool<Connector>>,
}

Expand All @@ -80,7 +78,6 @@ impl HttpState {
hsts_list: Arc::new(RwLock::new(HstsList::new())),
cookie_jar: Arc::new(RwLock::new(CookieStorage::new(150))),
auth_cache: Arc::new(RwLock::new(AuthCache::new())),
blocked_content: Arc::new(None),
connector_pool: create_http_connector(certificate_path),
}
}
Expand Down
3 changes: 0 additions & 3 deletions components/net/lib.rs
Expand Up @@ -7,15 +7,13 @@
#![feature(mpsc_select)]

extern crate brotli;
extern crate content_blocker as content_blocker_parser;
extern crate cookie as cookie_rs;
extern crate devtools_traits;
extern crate flate2;
extern crate hyper;
extern crate hyper_serde;
extern crate immeta;
extern crate ipc_channel;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
#[macro_use] #[no_link] extern crate matches;
#[macro_use]
Expand Down Expand Up @@ -46,7 +44,6 @@ extern crate websocket;
mod blob_loader;
mod chrome_loader;
mod connector;
mod content_blocker;
pub mod cookie;
pub mod cookie_storage;
mod data_loader;
Expand Down
2 changes: 0 additions & 2 deletions components/net/resource_thread.rs
Expand Up @@ -4,7 +4,6 @@

//! A thread that takes a URL and streams back the binary data.
use connector::{Connector, create_http_connector};
use content_blocker::BLOCKED_CONTENT_RULES;
use cookie;
use cookie_rs;
use cookie_storage::CookieStorage;
Expand Down Expand Up @@ -324,7 +323,6 @@ impl CoreResourceManager {
hsts_list: group.hsts_list.clone(),
cookie_jar: group.cookie_jar.clone(),
auth_cache: group.auth_cache.clone(),
blocked_content: BLOCKED_CONTENT_RULES.clone(),
// FIXME(#15694): use group.connector.clone() instead.
connector_pool: create_http_connector("certs"),
};
Expand Down
75 changes: 0 additions & 75 deletions tests/unit/net/http_loader.rs
Expand Up @@ -1118,78 +1118,3 @@ fn test_auth_ui_needs_www_auth() {

assert_eq!(response.status.unwrap(), StatusCode::Unauthorized);
}

#[test]
fn test_content_blocked() {
let handler = move |_: HyperRequest, response: HyperResponse| {
response.send(b"Yay!").unwrap();
};
let (mut server, url) = make_server(handler);

let url_filter = url.as_str().replace("http://", "https?://");
let blocked_content_list = format!("[{{ \
\"trigger\": {{ \"url-filter\": \"{}\" }}, \
\"action\": {{ \"type\": \"block\" }} \
}}]", url_filter);

let mut context = new_fetch_context(None);
context.state.blocked_content = Arc::new(Some(parse_list(&blocked_content_list).unwrap()));

let request = Request::from_init(RequestInit {
url: url.clone(),
method: Method::Get,
body: None,
destination: Destination::Document,
origin: url.clone(),
.. RequestInit::default()
});

let response = fetch_with_context(request, &context);

let _ = server.close();

// TODO(#14307): this should fail.
assert!(response.status.unwrap().is_success());
}

#[test]
fn test_cookies_blocked() {
let handler = move |request: HyperRequest, response: HyperResponse| {
assert_eq!(request.headers.get::<CookieHeader>(), None);
response.send(b"hi").unwrap();
};
let (mut server, url) = make_server(handler);

let url_filter = url.as_str().replace("http://", "https?://");
let blocked_content_list = format!("[{{ \
\"trigger\": {{ \"url-filter\": \"{}\" }}, \
\"action\": {{ \"type\": \"block-cookies\" }} \
}}]", url_filter);

let mut context = new_fetch_context(None);
context.state.blocked_content = Arc::new(Some(parse_list(&blocked_content_list).unwrap()));
{
let mut cookie_jar = context.state.cookie_jar.write().unwrap();
let cookie = Cookie::new_wrapped(
CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned()),
&url,
CookieSource::HTTP
).unwrap();
cookie_jar.push(cookie, &url, CookieSource::HTTP);
}

let request = Request::from_init(RequestInit {
url: url.clone(),
method: Method::Get,
body: None,
destination: Destination::Document,
origin: url.clone(),
.. RequestInit::default()
});

let response = fetch_with_context(request, &context);

let _ = server.close();

assert!(response.status.unwrap().is_success());
}

0 comments on commit 5a61d8b

Please sign in to comment.