mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Remove the url! plugin.
In rust-url 1.0 the `Url` struct is going to have private fields, and there is no way to to create an aribitrary one without going through the parser. The plugin never had a clear demonstrated performance benefit, it was made mostly because it was possible and relatively easy at the time.
This commit is contained in:
parent
87d5424d4d
commit
6889f37d9e
27 changed files with 84 additions and 296 deletions
|
@ -868,7 +868,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
parent_info,
|
parent_info,
|
||||||
window_size,
|
window_size,
|
||||||
None,
|
None,
|
||||||
LoadData::new(url!("about:failure")));
|
LoadData::new(Url::parse("about:failure").unwrap()));
|
||||||
|
|
||||||
self.push_pending_frame(new_pipeline_id, Some(pipeline_id));
|
self.push_pending_frame(new_pipeline_id, Some(pipeline_id));
|
||||||
|
|
||||||
|
@ -951,7 +951,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
// If no url is specified, reload.
|
// If no url is specified, reload.
|
||||||
let new_url = load_info.url.clone()
|
let new_url = load_info.url.clone()
|
||||||
.or_else(|| old_pipeline.map(|old_pipeline| old_pipeline.url.clone()))
|
.or_else(|| old_pipeline.map(|old_pipeline| old_pipeline.url.clone()))
|
||||||
.unwrap_or_else(|| url!("about:blank"));
|
.unwrap_or_else(|| Url::parse("about:blank").unwrap());
|
||||||
|
|
||||||
// Compare the pipeline's url to the new url. If the origin is the same,
|
// Compare the pipeline's url to the new url. If the origin is the same,
|
||||||
// then reuse the script thread in creating the new pipeline
|
// then reuse the script thread in creating the new pipeline
|
||||||
|
|
|
@ -16,7 +16,6 @@ optional = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tenacious = "0.1.2"
|
tenacious = "0.1.2"
|
||||||
url = {version = "0.5.7", features = ["heap_size"]}
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -28,8 +28,6 @@ extern crate syntax;
|
||||||
extern crate syntax_ext;
|
extern crate syntax_ext;
|
||||||
extern crate tenacious;
|
extern crate tenacious;
|
||||||
|
|
||||||
extern crate url;
|
|
||||||
|
|
||||||
use rustc_plugin::Registry;
|
use rustc_plugin::Registry;
|
||||||
use syntax::ext::base::*;
|
use syntax::ext::base::*;
|
||||||
use syntax::feature_gate::AttributeType::Whitelisted;
|
use syntax::feature_gate::AttributeType::Whitelisted;
|
||||||
|
@ -41,8 +39,6 @@ pub mod jstraceable;
|
||||||
pub mod lints;
|
pub mod lints;
|
||||||
/// Autogenerates implementations of Reflectable on DOM structs
|
/// Autogenerates implementations of Reflectable on DOM structs
|
||||||
pub mod reflector;
|
pub mod reflector;
|
||||||
/// The `url!` plugin.
|
|
||||||
mod url_plugin;
|
|
||||||
/// Utilities for writing plugins
|
/// Utilities for writing plugins
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
@ -51,7 +47,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
|
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
|
||||||
reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
|
reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
|
||||||
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
|
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
|
||||||
reg.register_macro("url", url_plugin::expand_url);
|
|
||||||
reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
|
reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
|
||||||
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
|
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
|
||||||
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
|
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
/* 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 std::error::Error;
|
|
||||||
use syntax;
|
|
||||||
use syntax::ast::{Expr, ExprKind, LitKind, TokenTree};
|
|
||||||
use syntax::codemap::Span;
|
|
||||||
use syntax::ext::base::{ExtCtxt, MacResult, MacEager, DummyResult};
|
|
||||||
use syntax::ext::build::AstBuilder;
|
|
||||||
use syntax::fold::Folder;
|
|
||||||
use syntax::parse;
|
|
||||||
use syntax::parse::token::InternedString;
|
|
||||||
use url::{Url, Host, RelativeSchemeData, SchemeData};
|
|
||||||
|
|
||||||
pub fn expand_url(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
|
|
||||||
-> Box<MacResult + 'static> {
|
|
||||||
let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_vec());
|
|
||||||
let query_expr = cx.expander().fold_expr(parser.parse_expr().unwrap());
|
|
||||||
|
|
||||||
// Ensure a str literal was passed to the macro
|
|
||||||
let query = match parse_str_lit(&query_expr) {
|
|
||||||
Some(query) => query,
|
|
||||||
None => {
|
|
||||||
cx.span_err(query_expr.span, "'url!' expected string literal");
|
|
||||||
return DummyResult::any(sp)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parse the str literal
|
|
||||||
let Url { scheme, scheme_data, query, fragment } = match Url::parse(&query) {
|
|
||||||
Ok(url) => url,
|
|
||||||
Err(error) => {
|
|
||||||
cx.span_err(query_expr.span, error.description());
|
|
||||||
return DummyResult::any(sp)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let scheme_data_expr = cx.expr_scheme_data(sp, scheme_data);
|
|
||||||
let query_expr = cx.expr_option_string(sp, query);
|
|
||||||
let fragment_expr = cx.expr_option_string(sp, fragment);
|
|
||||||
|
|
||||||
let url_expr = quote_expr!(cx, {
|
|
||||||
::url::Url {
|
|
||||||
scheme: $scheme.to_owned(),
|
|
||||||
scheme_data: $scheme_data_expr,
|
|
||||||
query: $query_expr,
|
|
||||||
fragment: $fragment_expr,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
MacEager::expr(url_expr)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_str_lit(e: &Expr) -> Option<InternedString> {
|
|
||||||
if let ExprKind::Lit(ref lit) = e.node {
|
|
||||||
if let LitKind::Str(ref s, _) = lit.node {
|
|
||||||
return Some(s.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
trait ExtCtxtHelpers {
|
|
||||||
fn expr_scheme_data(&self, sp: Span, scheme_data: SchemeData) -> syntax::ptr::P<Expr>;
|
|
||||||
fn expr_option_string(&self, sp: Span, string: Option<String>) -> syntax::ptr::P<Expr>;
|
|
||||||
fn expr_option_u16(&self, sp: Span, unsigned: Option<u16>) -> syntax::ptr::P<Expr>;
|
|
||||||
fn expr_host(&self, sp: Span, host: Host) -> syntax::ptr::P<Expr>;
|
|
||||||
fn expr_slice_u16(&self, sp: Span, unsigned: &[u16]) -> syntax::ptr::P<Expr>;
|
|
||||||
fn expr_vec_string(&self, sp: Span, strings: Vec<String>) -> syntax::ptr::P<Expr>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ExtCtxtHelpers for ExtCtxt<'a> {
|
|
||||||
fn expr_scheme_data(&self, sp: Span, scheme_data: SchemeData) -> syntax::ptr::P<Expr> {
|
|
||||||
match scheme_data {
|
|
||||||
SchemeData::Relative(
|
|
||||||
RelativeSchemeData { username, password, host, port, default_port, path }) =>
|
|
||||||
{
|
|
||||||
let password_expr = self.expr_option_string(sp, password);
|
|
||||||
let host_expr = self.expr_host(sp, host);
|
|
||||||
let port_expr = self.expr_option_u16(sp, port);
|
|
||||||
let default_port_expr = self.expr_option_u16(sp, default_port);
|
|
||||||
let path_expr = self.expr_vec_string(sp, path);
|
|
||||||
|
|
||||||
quote_expr!(self,
|
|
||||||
::url::SchemeData::Relative(
|
|
||||||
::url::RelativeSchemeData {
|
|
||||||
username: $username.to_owned(),
|
|
||||||
password: $password_expr,
|
|
||||||
host: $host_expr,
|
|
||||||
port: $port_expr,
|
|
||||||
default_port: $default_port_expr,
|
|
||||||
path: $path_expr.to_owned(),
|
|
||||||
}
|
|
||||||
))
|
|
||||||
},
|
|
||||||
SchemeData::NonRelative(ref scheme_data) => {
|
|
||||||
quote_expr!(self, ::url::SchemeData::NonRelative($scheme_data.to_owned()))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expr_option_string(&self, sp: Span, string: Option<String>) -> syntax::ptr::P<Expr> {
|
|
||||||
match string {
|
|
||||||
Some(string) => quote_expr!(self, Some($string.to_owned())),
|
|
||||||
None => self.expr_none(sp),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expr_option_u16(&self, sp: Span, unsigned: Option<u16>) -> syntax::ptr::P<Expr> {
|
|
||||||
match unsigned {
|
|
||||||
Some(unsigned) => quote_expr!(self, Some($unsigned)),
|
|
||||||
None => self.expr_none(sp),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expr_host(&self, _sp: Span, host: Host) -> syntax::ptr::P<Expr> {
|
|
||||||
match host {
|
|
||||||
Host::Domain(domain) => quote_expr!(self, ::url::Host::Domain(String::from($domain))),
|
|
||||||
Host::Ipv6(address) => {
|
|
||||||
let [a, b, c, d, e, f, g, h] = address.segments();
|
|
||||||
quote_expr!(self,
|
|
||||||
::url::Host::Ipv6(::std::net::Ipv6Addr::new(
|
|
||||||
$a, $b, $c, $d, $e, $f, $g, $h
|
|
||||||
)))
|
|
||||||
},
|
|
||||||
Host::Ipv4(address) => {
|
|
||||||
let [a, b, c, d] = address.octets();
|
|
||||||
quote_expr!(self,
|
|
||||||
::url::Host::Ipv4(::std::net::Ipv4Addr::new(
|
|
||||||
$a, $b, $c, $d
|
|
||||||
)))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expr_slice_u16(&self, sp: Span, unsigned: &[u16]) -> syntax::ptr::P<Expr> {
|
|
||||||
let unsigned = unsigned.iter().map(|p| quote_expr!(self, $p)).collect();
|
|
||||||
self.expr_vec_slice(sp, unsigned)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expr_vec_string(&self, sp: Span, strings: Vec<String>) -> syntax::ptr::P<Expr> {
|
|
||||||
let strings = strings.iter().map(|p| quote_expr!(self, $p.to_owned())).collect();
|
|
||||||
self.expr_vec(sp, strings)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1603,7 +1603,7 @@ impl Document {
|
||||||
source: DocumentSource,
|
source: DocumentSource,
|
||||||
doc_loader: DocumentLoader)
|
doc_loader: DocumentLoader)
|
||||||
-> Document {
|
-> Document {
|
||||||
let url = url.unwrap_or_else(|| url!("about:blank"));
|
let url = url.unwrap_or_else(|| Url::parse("about:blank").unwrap());
|
||||||
|
|
||||||
let (ready_state, domcontentloaded_dispatched) = if source == DocumentSource::FromParser {
|
let (ready_state, domcontentloaded_dispatched) = if source == DocumentSource::FromParser {
|
||||||
(DocumentReadyState::Loading, false)
|
(DocumentReadyState::Loading, false)
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl HTMLIFrameElement {
|
||||||
pub fn process_the_iframe_attributes(&self) {
|
pub fn process_the_iframe_attributes(&self) {
|
||||||
let url = match self.get_url() {
|
let url = match self.get_url() {
|
||||||
Some(url) => url.clone(),
|
Some(url) => url.clone(),
|
||||||
None => url!("about:blank"),
|
None => Url::parse("about:blank").unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.navigate_or_reload_child_browsing_context(Some(url));
|
self.navigate_or_reload_child_browsing_context(Some(url));
|
||||||
|
|
|
@ -1880,7 +1880,7 @@ impl ScriptThread {
|
||||||
};
|
};
|
||||||
|
|
||||||
if load_data.url.scheme == "javascript" {
|
if load_data.url.scheme == "javascript" {
|
||||||
load_data.url = url!("about:blank");
|
load_data.url = Url::parse("about:blank").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
resource_thread.send(ControlMsg::Load(NetLoadData {
|
resource_thread.send(ControlMsg::Load(NetLoadData {
|
||||||
|
|
10
components/servo/Cargo.lock
generated
10
components/servo/Cargo.lock
generated
|
@ -32,7 +32,6 @@ dependencies = [
|
||||||
"net_traits_tests 0.0.1",
|
"net_traits_tests 0.0.1",
|
||||||
"offscreen_gl_context 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugin_compiletest 0.0.1",
|
"plugin_compiletest 0.0.1",
|
||||||
"plugin_tests 0.0.1",
|
|
||||||
"profile 0.0.1",
|
"profile 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script 0.0.1",
|
"script 0.0.1",
|
||||||
|
@ -1526,20 +1525,11 @@ dependencies = [
|
||||||
"script 0.0.1",
|
"script 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plugin_tests"
|
|
||||||
version = "0.0.1"
|
|
||||||
dependencies = [
|
|
||||||
"plugins 0.0.1",
|
|
||||||
"url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "plugins"
|
name = "plugins"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -33,9 +33,6 @@ path = "../../tests/unit/net"
|
||||||
[dev-dependencies.net_traits_tests]
|
[dev-dependencies.net_traits_tests]
|
||||||
path = "../../tests/unit/net_traits"
|
path = "../../tests/unit/net_traits"
|
||||||
|
|
||||||
[dev-dependencies.plugin_tests]
|
|
||||||
path = "../../tests/unit/plugin"
|
|
||||||
|
|
||||||
[dev-dependencies.script_tests]
|
[dev-dependencies.script_tests]
|
||||||
path = "../../tests/unit/script"
|
path = "../../tests/unit/script"
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ fn parse_one_src(context: &ParserContext, input: &mut Parser) -> Result<Source,
|
||||||
}
|
}
|
||||||
let url = try!(input.expect_url());
|
let url = try!(input.expect_url());
|
||||||
let url = context.base_url.join(&url).unwrap_or_else(
|
let url = context.base_url.join(&url).unwrap_or_else(
|
||||||
|_error| url!("about:invalid"));
|
|_error| Url::parse("about:invalid").unwrap());
|
||||||
|
|
||||||
// Parsing optional format()
|
// Parsing optional format()
|
||||||
let format_hints = if input.try(|input| input.expect_function_matching("format")).is_ok() {
|
let format_hints = if input.try(|input| input.expect_function_matching("format")).is_ok() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl<'a> ParserContext<'a> {
|
||||||
impl<'a> ParserContext<'a> {
|
impl<'a> ParserContext<'a> {
|
||||||
pub fn parse_url(&self, input: &str) -> Url {
|
pub fn parse_url(&self, input: &str) -> Url {
|
||||||
self.base_url.join(input)
|
self.base_url.join(input)
|
||||||
.unwrap_or_else(|_| url!("about:invalid"))
|
.unwrap_or_else(|_| Url::parse("about:invalid").unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ lazy_static! {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
Stylesheet::from_bytes(
|
Stylesheet::from_bytes(
|
||||||
&res,
|
&res,
|
||||||
url!("chrome:///quirks-mode.css"),
|
Url::parse("chrome:///quirks-mode.css").unwrap(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
|
|
|
@ -463,7 +463,7 @@ const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;
|
||||||
pub fn default_opts() -> Opts {
|
pub fn default_opts() -> Opts {
|
||||||
Opts {
|
Opts {
|
||||||
is_running_problem_test: false,
|
is_running_problem_test: false,
|
||||||
url: Some(url!("about:blank")),
|
url: Some(Url::parse("about:blank").unwrap()),
|
||||||
paint_threads: 1,
|
paint_threads: 1,
|
||||||
gpu_painting: false,
|
gpu_painting: false,
|
||||||
tile_size: 512,
|
tile_size: 512,
|
||||||
|
|
1
ports/cef/Cargo.lock
generated
1
ports/cef/Cargo.lock
generated
|
@ -1408,7 +1408,6 @@ name = "plugins"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
1
ports/geckolib/Cargo.lock
generated
1
ports/geckolib/Cargo.lock
generated
|
@ -273,7 +273,6 @@ name = "plugins"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
1
ports/gonk/Cargo.lock
generated
1
ports/gonk/Cargo.lock
generated
|
@ -1390,7 +1390,6 @@ name = "plugins"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tenacious 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern crate cookie as cookie_rs;
|
||||||
use net::cookie::Cookie;
|
use net::cookie::Cookie;
|
||||||
use net::cookie_storage::CookieStorage;
|
use net::cookie_storage::CookieStorage;
|
||||||
use net_traits::CookieSource;
|
use net_traits::CookieSource;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_domain_match() {
|
fn test_domain_match() {
|
||||||
|
@ -56,9 +57,9 @@ fn test_default_path() {
|
||||||
fn fn_cookie_constructor() {
|
fn fn_cookie_constructor() {
|
||||||
use net_traits::CookieSource;
|
use net_traits::CookieSource;
|
||||||
|
|
||||||
let url = &url!("http://example.com/foo");
|
let url = &Url::parse("http://example.com/foo").unwrap();
|
||||||
|
|
||||||
let gov_url = &url!("http://gov.ac/foo");
|
let gov_url = &Url::parse("http://gov.ac/foo").unwrap();
|
||||||
// cookie name/value test
|
// cookie name/value test
|
||||||
assert!(cookie_rs::Cookie::parse(" baz ").is_err());
|
assert!(cookie_rs::Cookie::parse(" baz ").is_err());
|
||||||
assert!(cookie_rs::Cookie::parse(" = bar ").is_err());
|
assert!(cookie_rs::Cookie::parse(" = bar ").is_err());
|
||||||
|
@ -94,7 +95,7 @@ fn fn_cookie_constructor() {
|
||||||
assert!(&cookie.cookie.domain.as_ref().unwrap()[..] == "example.com");
|
assert!(&cookie.cookie.domain.as_ref().unwrap()[..] == "example.com");
|
||||||
assert!(cookie.host_only);
|
assert!(cookie.host_only);
|
||||||
|
|
||||||
let u = &url!("http://example.com/foobar");
|
let u = &Url::parse("http://example.com/foobar").unwrap();
|
||||||
let cookie = cookie_rs::Cookie::parse("foobar=value;path=/").unwrap();
|
let cookie = cookie_rs::Cookie::parse("foobar=value;path=/").unwrap();
|
||||||
assert!(Cookie::new_wrapped(cookie, u, CookieSource::HTTP).is_some());
|
assert!(Cookie::new_wrapped(cookie, u, CookieSource::HTTP).is_some());
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ fn delay_to_ensure_different_timestamp() {
|
||||||
fn test_sort_order() {
|
fn test_sort_order() {
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
let url = &url!("http://example.com/foo");
|
let url = &Url::parse("http://example.com/foo").unwrap();
|
||||||
let a_wrapped = cookie_rs::Cookie::parse("baz=bar; Path=/foo/bar/").unwrap();
|
let a_wrapped = cookie_rs::Cookie::parse("baz=bar; Path=/foo/bar/").unwrap();
|
||||||
let a = Cookie::new_wrapped(a_wrapped.clone(), url, CookieSource::HTTP).unwrap();
|
let a = Cookie::new_wrapped(a_wrapped.clone(), url, CookieSource::HTTP).unwrap();
|
||||||
delay_to_ensure_different_timestamp();
|
delay_to_ensure_different_timestamp();
|
||||||
|
|
|
@ -6,6 +6,7 @@ use net::hsts::{HSTSList, HSTSEntry};
|
||||||
use net::hsts::{secure_url, preload_hsts_domains};
|
use net::hsts::{secure_url, preload_hsts_domains};
|
||||||
use net_traits::IncludeSubdomains;
|
use net_traits::IncludeSubdomains;
|
||||||
use time;
|
use time;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() {
|
fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() {
|
||||||
|
@ -255,7 +256,7 @@ fn test_preload_hsts_domains_well_formed() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_secure_url_does_not_change_explicit_port() {
|
fn test_secure_url_does_not_change_explicit_port() {
|
||||||
let url = url!("http://mozilla.org:8080/");
|
let url = Url::parse("http://mozilla.org:8080/").unwrap();
|
||||||
let secure = secure_url(&url);
|
let secure = secure_url(&url);
|
||||||
|
|
||||||
assert!(secure.port().unwrap() == 8080u16);
|
assert!(secure.port().unwrap() == 8080u16);
|
||||||
|
@ -263,7 +264,7 @@ fn test_secure_url_does_not_change_explicit_port() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_secure_url_does_not_affect_non_http_schemas() {
|
fn test_secure_url_does_not_affect_non_http_schemas() {
|
||||||
let url = url!("file://mozilla.org");
|
let url = Url::parse("file://mozilla.org").unwrap();
|
||||||
let secure = secure_url(&url);
|
let secure = secure_url(&url);
|
||||||
|
|
||||||
assert_eq!(&secure.scheme, "file");
|
assert_eq!(&secure.scheme, "file");
|
||||||
|
@ -271,7 +272,7 @@ fn test_secure_url_does_not_affect_non_http_schemas() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_secure_url_forces_an_http_host_in_list_to_https() {
|
fn test_secure_url_forces_an_http_host_in_list_to_https() {
|
||||||
let url = url!("http://mozilla.org");
|
let url = Url::parse("http://mozilla.org").unwrap();
|
||||||
let secure = secure_url(&url);
|
let secure = secure_url(&url);
|
||||||
|
|
||||||
assert_eq!(&secure.scheme, "https");
|
assert_eq!(&secure.scheme, "https");
|
||||||
|
|
|
@ -372,7 +372,7 @@ fn expect_devtools_http_response(devtools_port: &Receiver<DevtoolsControlMsg>) -
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_check_default_headers_loaded_in_every_request() {
|
fn test_check_default_headers_loaded_in_every_request() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ fn test_check_default_headers_loaded_in_every_request() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length_should_be_set_to_0() {
|
fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length_should_be_set_to_0() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ fn test_request_and_response_data_with_network_messages() {
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
let url = url!("https://mozilla.com");
|
let url = Url::parse("https://mozilla.com").unwrap();
|
||||||
let (devtools_chan, devtools_port) = mpsc::channel::<DevtoolsControlMsg>();
|
let (devtools_chan, devtools_port) = mpsc::channel::<DevtoolsControlMsg>();
|
||||||
// This will probably have to be changed as it uses fake_root_pipeline_id which is marked for removal.
|
// This will probably have to be changed as it uses fake_root_pipeline_id which is marked for removal.
|
||||||
let pipeline_id = PipelineId::fake_root_pipeline_id();
|
let pipeline_id = PipelineId::fake_root_pipeline_id();
|
||||||
|
@ -526,7 +526,7 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
let url = url!("https://mozilla.com");
|
let url = Url::parse("https://mozilla.com").unwrap();
|
||||||
let (devtools_chan, devtools_port) = mpsc::channel::<DevtoolsControlMsg>();
|
let (devtools_chan, devtools_port) = mpsc::channel::<DevtoolsControlMsg>();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
let _ = load::<MockRequest>(load_data, &http_state, Some(devtools_chan), &Factory,
|
let _ = load::<MockRequest>(load_data, &http_state, Some(devtools_chan), &Factory,
|
||||||
|
@ -556,7 +556,7 @@ fn test_load_when_redirecting_from_a_post_should_rewrite_next_request_as_get() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.method = Method::Post;
|
load_data.method = Method::Post;
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ fn test_load_should_decode_the_response_as_deflate_when_response_headers_have_co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -617,7 +617,7 @@ fn test_load_should_decode_the_response_as_gzip_when_response_headers_have_conte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ fn test_load_doesnt_send_request_body_on_any_redirect() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Body on POST!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Body on POST!".as_bytes()));
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ fn test_load_doesnt_add_host_to_sts_list_when_url_is_http_even_if_sts_headers_ar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ fn test_load_adds_host_to_sts_list_when_url_is_https_and_sts_headers_are_present
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("https://mozilla.com");
|
let url = Url::parse("https://mozilla.com").unwrap();
|
||||||
|
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_resource_manager() {
|
fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_resource_manager() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
||||||
|
@ -800,8 +800,8 @@ fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_re
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_sends_secure_cookie_if_http_changed_to_https_due_to_entry_in_hsts_store() {
|
fn test_load_sends_secure_cookie_if_http_changed_to_https_due_to_entry_in_hsts_store() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let secured_url = url!("https://mozilla.com");
|
let secured_url = Url::parse("https://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
{
|
{
|
||||||
|
@ -842,7 +842,7 @@ fn test_load_sends_secure_cookie_if_http_changed_to_https_due_to_entry_in_hsts_s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_sends_cookie_if_nonhttp() {
|
fn test_load_sends_cookie_if_nonhttp() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -919,7 +919,7 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url!("http://mozilla.com"), None);
|
let load_data = LoadData::new(LoadContext::Browsing, Url::parse("http://mozilla.com").unwrap(), None);
|
||||||
let _ = load::<MockRequest>(load_data,
|
let _ = load::<MockRequest>(load_data,
|
||||||
&http_state,
|
&http_state,
|
||||||
None,
|
None,
|
||||||
|
@ -933,8 +933,8 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() {
|
fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() {
|
||||||
|
|
||||||
let sec_url = url!("https://mozilla.com");
|
let sec_url = Url::parse("https://mozilla.com").unwrap();
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() {
|
||||||
fn test_load_sets_content_length_to_length_of_request_body() {
|
fn test_load_sets_content_length_to_length_of_request_body() {
|
||||||
let content = "This is a request body";
|
let content = "This is a request body";
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec(content.as_bytes()));
|
load_data.data = Some(<[_]>::to_vec(content.as_bytes()));
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ fn test_load_uses_explicit_accept_from_headers_in_load_data() {
|
||||||
let mut accept_headers = Headers::new();
|
let mut accept_headers = Headers::new();
|
||||||
accept_headers.set(Accept(vec![text_html.clone()]));
|
accept_headers.set(Accept(vec![text_html.clone()]));
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
||||||
load_data.headers.set(Accept(vec![text_html.clone()]));
|
load_data.headers.set(Accept(vec![text_html.clone()]));
|
||||||
|
@ -1017,7 +1017,7 @@ fn test_load_sets_default_accept_to_html_xhtml_xml_and_then_anything_else() {
|
||||||
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800)),
|
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800)),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
||||||
|
|
||||||
|
@ -1038,7 +1038,7 @@ fn test_load_uses_explicit_accept_encoding_from_load_data_headers() {
|
||||||
let mut accept_encoding_headers = Headers::new();
|
let mut accept_encoding_headers = Headers::new();
|
||||||
accept_encoding_headers.set(AcceptEncoding(vec![qitem(Encoding::Chunked)]));
|
accept_encoding_headers.set(AcceptEncoding(vec![qitem(Encoding::Chunked)]));
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
||||||
load_data.headers.set(AcceptEncoding(vec![qitem(Encoding::Chunked)]));
|
load_data.headers.set(AcceptEncoding(vec![qitem(Encoding::Chunked)]));
|
||||||
|
@ -1062,7 +1062,7 @@ fn test_load_sets_default_accept_encoding_to_gzip_and_deflate() {
|
||||||
qitem(Encoding::Deflate),
|
qitem(Encoding::Deflate),
|
||||||
qitem(Encoding::EncodingExt("br".to_owned()))]));
|
qitem(Encoding::EncodingExt("br".to_owned()))]));
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
|
||||||
|
|
||||||
|
@ -1096,7 +1096,7 @@ fn test_load_errors_when_there_a_redirect_loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -1126,7 +1126,7 @@ fn test_load_errors_when_there_is_too_many_redirects() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -1164,7 +1164,7 @@ fn test_load_follows_a_redirect() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -1191,7 +1191,7 @@ impl HttpRequestFactory for DontConnectFactory {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_errors_when_scheme_is_not_http_or_https() {
|
fn test_load_errors_when_scheme_is_not_http_or_https() {
|
||||||
let url = url!("ftp://not-supported");
|
let url = Url::parse("ftp://not-supported").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -1209,7 +1209,7 @@ fn test_load_errors_when_scheme_is_not_http_or_https() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_https() {
|
fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_https() {
|
||||||
let url = url!("view-source:ftp://not-supported");
|
let url = Url::parse("view-source:ftp://not-supported").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
@ -1251,7 +1251,7 @@ fn test_load_errors_when_cancelled() {
|
||||||
let cancel_listener = CancellationListener::new(Some(cancel_resource));
|
let cancel_listener = CancellationListener::new(Some(cancel_resource));
|
||||||
cancel_sender.send(()).unwrap();
|
cancel_sender.send(()).unwrap();
|
||||||
|
|
||||||
let url = url!("https://mozilla.com");
|
let url = Url::parse("https://mozilla.com").unwrap();
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
@ -1268,8 +1268,8 @@ fn test_load_errors_when_cancelled() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_redirect_from_x_to_y_provides_y_cookies_from_y() {
|
fn test_redirect_from_x_to_y_provides_y_cookies_from_y() {
|
||||||
let url_x = url!("http://mozilla.com");
|
let url_x = Url::parse("http://mozilla.com").unwrap();
|
||||||
let url_y = url!("http://mozilla.org");
|
let url_y = Url::parse("http://mozilla.org").unwrap();
|
||||||
|
|
||||||
struct Factory;
|
struct Factory;
|
||||||
|
|
||||||
|
@ -1338,7 +1338,7 @@ fn test_redirect_from_x_to_y_provides_y_cookies_from_y() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() {
|
fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() {
|
||||||
let url = url!("http://mozilla.org/initial/");
|
let url = Url::parse("http://mozilla.org/initial/").unwrap();
|
||||||
|
|
||||||
struct Factory;
|
struct Factory;
|
||||||
|
|
||||||
|
@ -1385,7 +1385,7 @@ fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() {
|
fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() {
|
||||||
let url = url!("http://mozilla.com");
|
let url = Url::parse("http://mozilla.com").unwrap();
|
||||||
|
|
||||||
let http_state = HttpState::new();
|
let http_state = HttpState::new();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn test_exit() {
|
||||||
fn test_bad_scheme() {
|
fn test_bad_scheme() {
|
||||||
let resource_thread = new_resource_thread("".to_owned(), None);
|
let resource_thread = new_resource_thread("".to_owned(), None);
|
||||||
let (start_chan, start) = ipc::channel().unwrap();
|
let (start_chan, start) = ipc::channel().unwrap();
|
||||||
let url = url!("bogus://whatever");
|
let url = Url::parse("bogus://whatever").unwrap();
|
||||||
resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
||||||
LoadConsumer::Channel(start_chan), None)).unwrap();
|
LoadConsumer::Channel(start_chan), None)).unwrap();
|
||||||
let response = start.recv().unwrap();
|
let response = start.recv().unwrap();
|
||||||
|
@ -156,13 +156,13 @@ fn test_replace_hosts() {
|
||||||
host_table.insert("foo.bar.com".to_owned(), "127.0.0.1".to_owned());
|
host_table.insert("foo.bar.com".to_owned(), "127.0.0.1".to_owned());
|
||||||
host_table.insert("servo.test.server".to_owned(), "127.0.0.2".to_owned());
|
host_table.insert("servo.test.server".to_owned(), "127.0.0.2".to_owned());
|
||||||
|
|
||||||
let url = url!("http://foo.bar.com:8000/foo");
|
let url = Url::parse("http://foo.bar.com:8000/foo").unwrap();
|
||||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.1");
|
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.1");
|
||||||
|
|
||||||
let url = url!("http://servo.test.server");
|
let url = Url::parse("http://servo.test.server").unwrap();
|
||||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.2");
|
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "127.0.0.2");
|
||||||
|
|
||||||
let url = url!("http://a.foo.bar.com");
|
let url = Url::parse("http://a.foo.bar.com").unwrap();
|
||||||
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "a.foo.bar.com");
|
assert_eq!(host_replacement(&host_table, &url).domain().unwrap(), "a.foo.bar.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "plugin_tests"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = ["The Servo Project Developers"]
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "plugin_tests"
|
|
||||||
path = "lib.rs"
|
|
||||||
doctest = false
|
|
||||||
|
|
||||||
[dependencies.plugins]
|
|
||||||
path = "../../../components/plugins"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
url = {version = "0.5.7", features = ["heap_size"]}
|
|
|
@ -1,11 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(plugins)]
|
|
||||||
|
|
||||||
extern crate url;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod url_plugin;
|
|
|
@ -1,24 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_url_plugin() {
|
|
||||||
assert_eq!("ftp://google.com/",
|
|
||||||
url!("ftp://google.com").to_string());
|
|
||||||
|
|
||||||
assert_eq!("ftp://google.com:443/",
|
|
||||||
url!("ftp://google.com:443").to_string());
|
|
||||||
|
|
||||||
assert_eq!("ftp://google.com:443/a/b/c",
|
|
||||||
url!("ftp://google.com:443/a/b/c").to_string());
|
|
||||||
|
|
||||||
assert_eq!("ftp://google.com:443/?a=b&c=d",
|
|
||||||
url!("ftp://google.com:443?a=b&c=d").to_string());
|
|
||||||
|
|
||||||
assert_eq!("http://[2001::1]/",
|
|
||||||
url!("http://[2001::1]:80").to_string());
|
|
||||||
|
|
||||||
assert_eq!("about:blank",
|
|
||||||
url!("about:blank").to_string());
|
|
||||||
}
|
|
|
@ -3,32 +3,33 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use script::origin::Origin;
|
use script::origin::Origin;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn same_origin() {
|
fn same_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.com/b.html"));
|
let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
|
||||||
assert!(a.same_origin(&b));
|
assert!(a.same_origin(&b));
|
||||||
assert_eq!(a.is_scheme_host_port_tuple(), true);
|
assert_eq!(a.is_scheme_host_port_tuple(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn identical_origin() {
|
fn identical_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
assert!(a.same_origin(&a));
|
assert!(a.same_origin(&a));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cross_origin() {
|
fn cross_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.org/b.html"));
|
let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
|
||||||
assert!(!a.same_origin(&b));
|
assert!(!a.same_origin(&b));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alias_same_origin() {
|
fn alias_same_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.com/b.html"));
|
let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
|
||||||
let c = b.alias();
|
let c = b.alias();
|
||||||
assert!(a.same_origin(&c));
|
assert!(a.same_origin(&c));
|
||||||
assert!(b.same_origin(&b));
|
assert!(b.same_origin(&b));
|
||||||
|
@ -38,8 +39,8 @@ fn alias_same_origin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alias_cross_origin() {
|
fn alias_cross_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.org/b.html"));
|
let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
|
||||||
let c = b.alias();
|
let c = b.alias();
|
||||||
assert!(!a.same_origin(&c));
|
assert!(!a.same_origin(&c));
|
||||||
assert!(b.same_origin(&c));
|
assert!(b.same_origin(&c));
|
||||||
|
@ -48,10 +49,10 @@ fn alias_cross_origin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alias_update_same_origin() {
|
fn alias_update_same_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.org/b.html"));
|
let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
|
||||||
let c = b.alias();
|
let c = b.alias();
|
||||||
b.set(url!("http://example.com/c.html").origin());
|
b.set(Url::parse("http://example.com/c.html").unwrap().origin());
|
||||||
assert!(a.same_origin(&c));
|
assert!(a.same_origin(&c));
|
||||||
assert!(b.same_origin(&c));
|
assert!(b.same_origin(&c));
|
||||||
assert!(c.same_origin(&c));
|
assert!(c.same_origin(&c));
|
||||||
|
@ -59,10 +60,10 @@ fn alias_update_same_origin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alias_update_cross_origin() {
|
fn alias_update_cross_origin() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.com/b.html"));
|
let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
|
||||||
let c = b.alias();
|
let c = b.alias();
|
||||||
b.set(url!("http://example.org/c.html").origin());
|
b.set(Url::parse("http://example.org/c.html").unwrap().origin());
|
||||||
assert!(!a.same_origin(&c));
|
assert!(!a.same_origin(&c));
|
||||||
assert!(b.same_origin(&c));
|
assert!(b.same_origin(&c));
|
||||||
assert!(c.same_origin(&c));
|
assert!(c.same_origin(&c));
|
||||||
|
@ -70,8 +71,8 @@ fn alias_update_cross_origin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alias_chain() {
|
fn alias_chain() {
|
||||||
let a = Origin::new(&url!("http://example.com/a.html"));
|
let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
|
||||||
let b = Origin::new(&url!("http://example.com/b.html"));
|
let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
|
||||||
let c = b.copy();
|
let c = b.copy();
|
||||||
let d = c.alias();
|
let d = c.alias();
|
||||||
let e = d.alias();
|
let e = d.alias();
|
||||||
|
@ -80,7 +81,7 @@ fn alias_chain() {
|
||||||
assert!(c.same_origin(&e));
|
assert!(c.same_origin(&e));
|
||||||
assert!(d.same_origin(&e));
|
assert!(d.same_origin(&e));
|
||||||
assert!(e.same_origin(&e));
|
assert!(e.same_origin(&e));
|
||||||
c.set(url!("http://example.org/c.html").origin());
|
c.set(Url::parse("http://example.org/c.html").unwrap().origin());
|
||||||
assert!(a.same_origin(&b));
|
assert!(a.same_origin(&b));
|
||||||
assert!(!b.same_origin(&c));
|
assert!(!b.same_origin(&c));
|
||||||
assert!(c.same_origin(&d));
|
assert!(c.same_origin(&d));
|
||||||
|
|
|
@ -11,6 +11,7 @@ use style::media_queries::*;
|
||||||
use style::servo::Stylesheet;
|
use style::servo::Stylesheet;
|
||||||
use style::stylesheets::{Origin, CSSRuleIteratorExt};
|
use style::stylesheets::{Origin, CSSRuleIteratorExt};
|
||||||
use style::values::specified;
|
use style::values::specified;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
pub struct CSSErrorReporterTest;
|
pub struct CSSErrorReporterTest;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ impl ParseErrorReporter for CSSErrorReporterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str) {
|
fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str) {
|
||||||
let url = url!("http://localhost");
|
let url = Url::parse("http://localhost").unwrap();
|
||||||
let stylesheet = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest));
|
let stylesheet = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest));
|
||||||
let mut rule_count = 0;
|
let mut rule_count = 0;
|
||||||
for rule in stylesheet.rules().media() {
|
for rule in stylesheet.rules().media() {
|
||||||
|
@ -34,7 +35,7 @@ fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
|
fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
|
||||||
let url = url!("http://localhost");
|
let url = Url::parse("http://localhost").unwrap();
|
||||||
let ss = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest));
|
let ss = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest));
|
||||||
let rule_count = ss.effective_rules(device).style().count();
|
let rule_count = ss.effective_rules(device).style().count();
|
||||||
assert!(rule_count == expected_rule_count, css.to_owned());
|
assert!(rule_count == expected_rule_count, css.to_owned());
|
||||||
|
|
|
@ -13,6 +13,7 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredV
|
||||||
use style::stylesheets::{CSSRule, StyleRule, Origin};
|
use style::stylesheets::{CSSRule, StyleRule, Origin};
|
||||||
use style::error_reporting::ParseErrorReporter;
|
use style::error_reporting::ParseErrorReporter;
|
||||||
use style::servo::Stylesheet;
|
use style::servo::Stylesheet;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_stylesheet() {
|
fn test_parse_stylesheet() {
|
||||||
|
@ -23,7 +24,7 @@ fn test_parse_stylesheet() {
|
||||||
html , body /**/ { display: block; }
|
html , body /**/ { display: block; }
|
||||||
#d1 > .ok { background: blue; }
|
#d1 > .ok { background: blue; }
|
||||||
";
|
";
|
||||||
let url = url!("about::test");
|
let url = Url::parse("about::test").unwrap();
|
||||||
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent,
|
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent,
|
||||||
Box::new(CSSErrorReporterTest));
|
Box::new(CSSErrorReporterTest));
|
||||||
assert_eq!(stylesheet, Stylesheet {
|
assert_eq!(stylesheet, Stylesheet {
|
||||||
|
@ -198,7 +199,7 @@ fn test_report_error_stylesheet() {
|
||||||
invalid: true;
|
invalid: true;
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
let url = url!("about::test");
|
let url = Url::parse("about::test").unwrap();
|
||||||
let error_reporter = Box::new(CSSInvalidErrorReporterTest::new());
|
let error_reporter = Box::new(CSSInvalidErrorReporterTest::new());
|
||||||
|
|
||||||
let errors = error_reporter.errors.clone();
|
let errors = error_reporter.errors.clone();
|
||||||
|
|
|
@ -16,10 +16,11 @@ use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
|
||||||
use style::values::specified::ViewportPercentageLength::Vw;
|
use style::values::specified::ViewportPercentageLength::Vw;
|
||||||
use style::viewport::*;
|
use style::viewport::*;
|
||||||
use style_traits::viewport::*;
|
use style_traits::viewport::*;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
macro_rules! stylesheet {
|
macro_rules! stylesheet {
|
||||||
($css:expr, $origin:ident, $error_reporter:expr) => {
|
($css:expr, $origin:ident, $error_reporter:expr) => {
|
||||||
Stylesheet::from_str($css, url!("http://localhost"), Origin::$origin, $error_reporter);
|
Stylesheet::from_str($css, Url::parse("http://localhost").unwrap(), Origin::$origin, $error_reporter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +280,7 @@ fn multiple_stylesheets_cascading() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn constrain_viewport() {
|
fn constrain_viewport() {
|
||||||
let url = url!("http://localhost");
|
let url = Url::parse("http://localhost").unwrap();
|
||||||
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
|
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
|
||||||
|
|
||||||
macro_rules! from_css {
|
macro_rules! from_css {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue