Make new test use local resources only.

This commit is contained in:
Josh Matthews 2016-03-09 12:33:33 -05:00
parent 16096f1a9c
commit d888ed368d
12 changed files with 121 additions and 15 deletions

View file

@ -0,0 +1,46 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use net::chrome_loader::resolve_chrome_url;
use url::Url;
#[test]
fn test_relative() {
let url = Url::parse("chrome://../something").unwrap();
assert!(resolve_chrome_url(&url).is_err());
}
#[test]
fn test_relative_2() {
let url = Url::parse("chrome://subdir/../something").unwrap();
assert!(resolve_chrome_url(&url).is_err());
}
#[test]
#[cfg(not(target_os = "windows"))]
fn test_absolute() {
let url = Url::parse("chrome:///etc/passwd").unwrap();
assert!(resolve_chrome_url(&url).is_err());
}
#[test]
#[cfg(target_os = "windows")]
fn test_absolute_2() {
let url = Url::parse("chrome://C:\\Windows").unwrap();
assert!(resolve_chrome_url(&url).is_err());
}
#[test]
#[cfg(target_os = "windows")]
fn test_absolute_3() {
let url = Url::parse("chrome://\\\\server/C$").unwrap();
assert!(resolve_chrome_url(&url).is_err());
}
#[test]
fn test_valid() {
let url = Url::parse("chrome://badcert.jpg").unwrap();
let resolved = resolve_chrome_url(&url).unwrap();
assert_eq!(resolved.scheme, "file");
}

View file

@ -23,7 +23,7 @@ use net::hsts::HstsEntry;
use net::http_loader::LoadErrorType;
use net::http_loader::{load, LoadError, HttpRequestFactory, HttpRequest, HttpResponse, UIProvider, HttpState};
use net::resource_thread::{AuthCacheEntry, CancellationListener};
use net_traits::{LoadData, CookieSource, LoadContext, NetworkError, IncludeSubdomains};
use net_traits::{LoadData, CookieSource, LoadContext, IncludeSubdomains};
use std::borrow::Cow;
use std::io::{self, Write, Read, Cursor};
use std::sync::mpsc::Receiver;

View file

@ -18,6 +18,7 @@ extern crate unicase;
extern crate url;
extern crate util;
#[cfg(test)] mod chrome_loader;
#[cfg(test)] mod cookie;
#[cfg(test)] mod data_loader;
#[cfg(test)] mod file_loader;