Auto merge of #10672 - frewsxcv:net-network, r=KiChjang

Improvements to network preferences, HTTP redirection limiting.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10672)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-19 04:06:25 +05:30
commit 80662f1e4e
7 changed files with 20 additions and 13 deletions

View file

@ -28,6 +28,7 @@ use std::io::{self, Write, Read, Cursor};
use std::sync::mpsc::Receiver;
use std::sync::{Arc, mpsc, RwLock};
use url::Url;
use util::prefs;
const DEFAULT_USER_AGENT: &'static str = "Test-agent";
@ -1103,13 +1104,20 @@ fn test_load_errors_when_there_is_too_many_redirects() {
let http_state = HttpState::new();
let ui_provider = TestProvider::new();
let redirect_limit = 13.;
prefs::set_pref("network.http.redirection-limit",
prefs::PrefValue::Number(redirect_limit));
match load(load_data, &ui_provider, &http_state, None, &Factory,
DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) {
Err(LoadError::MaxRedirects(url)) => {
Err(LoadError::MaxRedirects(url, num_redirects)) => {
assert_eq!(num_redirects, redirect_limit as u32);
assert_eq!(url.domain().unwrap(), "mozilla.com")
},
_ => panic!("expected max redirects to fail")
}
prefs::reset_pref("network.http.redirection-limit");
}
#[test]

View file

@ -8,7 +8,7 @@ use util::prefs::{PrefValue, extend_prefs, read_prefs_from_file, get_pref, set_p
fn test_create_pref() {
let json_str = "{\
\"layout.writing-mode.enabled\": true,\
\"net.mime.sniff\": false,\
\"network.mime.sniff\": false,\
\"shell.homepage\": \"http://servo.org\"\
}";

View file

@ -1,3 +1,3 @@
[mime_sniffing_font_context.html]
type: testharness
prefs: [net.mime.sniff:true]
prefs: [network.mime.sniff:true]