aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/constellation.rs4
-rw-r--r--components/plugins/Cargo.toml1
-rw-r--r--components/plugins/lib.rs5
-rw-r--r--components/plugins/url_plugin.rs146
-rw-r--r--components/script/dom/document.rs2
-rw-r--r--components/script/dom/htmliframeelement.rs2
-rw-r--r--components/script/script_thread.rs2
-rw-r--r--components/servo/Cargo.lock10
-rw-r--r--components/servo/Cargo.toml3
-rw-r--r--components/style/font_face.rs2
-rw-r--r--components/style/parser.rs2
-rw-r--r--components/style/selector_matching.rs2
-rw-r--r--components/util/opts.rs2
-rw-r--r--ports/cef/Cargo.lock1
-rw-r--r--ports/geckolib/Cargo.lock1
-rw-r--r--ports/gonk/Cargo.lock1
-rw-r--r--tests/unit/net/cookie.rs9
-rw-r--r--tests/unit/net/hsts.rs7
-rw-r--r--tests/unit/net/http_loader.rs68
-rw-r--r--tests/unit/net/resource_thread.rs8
-rw-r--r--tests/unit/plugin/Cargo.toml15
-rw-r--r--tests/unit/plugin/lib.rs11
-rw-r--r--tests/unit/plugin/url_plugin.rs24
-rw-r--r--tests/unit/script/origin.rs37
-rw-r--r--tests/unit/style/media_queries.rs5
-rw-r--r--tests/unit/style/stylesheets.rs5
-rw-r--r--tests/unit/style/viewport.rs5
27 files changed, 84 insertions, 296 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index 74b09dcb477..97d3fca36c2 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -868,7 +868,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
parent_info,
window_size,
None,
- LoadData::new(url!("about:failure")));
+ LoadData::new(Url::parse("about:failure").unwrap()));
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.
let new_url = load_info.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,
// then reuse the script thread in creating the new pipeline
diff --git a/components/plugins/Cargo.toml b/components/plugins/Cargo.toml
index cb4818d1e7f..9a1820a46db 100644
--- a/components/plugins/Cargo.toml
+++ b/components/plugins/Cargo.toml
@@ -16,7 +16,6 @@ optional = true
[dependencies]
tenacious = "0.1.2"
-url = {version = "0.5.7", features = ["heap_size"]}
[features]
default = []
diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs
index c4e21c0ad4e..7e982bcb9e4 100644
--- a/components/plugins/lib.rs
+++ b/components/plugins/lib.rs
@@ -28,8 +28,6 @@ extern crate syntax;
extern crate syntax_ext;
extern crate tenacious;
-extern crate url;
-
use rustc_plugin::Registry;
use syntax::ext::base::*;
use syntax::feature_gate::AttributeType::Whitelisted;
@@ -41,8 +39,6 @@ pub mod jstraceable;
pub mod lints;
/// Autogenerates implementations of Reflectable on DOM structs
pub mod reflector;
-/// The `url!` plugin.
-mod url_plugin;
/// Utilities for writing plugins
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("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
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::unrooted_must_root::UnrootedPass::new());
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
diff --git a/components/plugins/url_plugin.rs b/components/plugins/url_plugin.rs
deleted file mode 100644
index 9aa182068b3..00000000000
--- a/components/plugins/url_plugin.rs
+++ /dev/null
@@ -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)
- }
-}
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 723e461df30..bb5f85e7438 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1603,7 +1603,7 @@ impl Document {
source: DocumentSource,
doc_loader: DocumentLoader)
-> 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 {
(DocumentReadyState::Loading, false)
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 56ad1d3df39..3824d981af1 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -146,7 +146,7 @@ impl HTMLIFrameElement {
pub fn process_the_iframe_attributes(&self) {
let url = match self.get_url() {
Some(url) => url.clone(),
- None => url!("about:blank"),
+ None => Url::parse("about:blank").unwrap(),
};
self.navigate_or_reload_child_browsing_context(Some(url));
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 7cb24e110bc..7029f34e753 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1880,7 +1880,7 @@ impl ScriptThread {
};
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 {
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 85f65250dbe..4768325432e 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -32,7 +32,6 @@ dependencies = [
"net_traits_tests 0.0.1",
"offscreen_gl_context 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"plugin_compiletest 0.0.1",
- "plugin_tests 0.0.1",
"profile 0.0.1",
"profile_traits 0.0.1",
"script 0.0.1",
@@ -1527,19 +1526,10 @@ dependencies = [
]
[[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]]
name = "plugins"
version = "0.0.1"
dependencies = [
"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]]
diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml
index a06e3093031..f62468c5151 100644
--- a/components/servo/Cargo.toml
+++ b/components/servo/Cargo.toml
@@ -33,9 +33,6 @@ path = "../../tests/unit/net"
[dev-dependencies.net_traits_tests]
path = "../../tests/unit/net_traits"
-[dev-dependencies.plugin_tests]
-path = "../../tests/unit/plugin"
-
[dev-dependencies.script_tests]
path = "../../tests/unit/script"
diff --git a/components/style/font_face.rs b/components/style/font_face.rs
index 0810afac5a8..8c9b1f3d28a 100644
--- a/components/style/font_face.rs
+++ b/components/style/font_face.rs
@@ -102,7 +102,7 @@ fn parse_one_src(context: &ParserContext, input: &mut Parser) -> Result<Source,
}
let url = try!(input.expect_url());
let url = context.base_url.join(&url).unwrap_or_else(
- |_error| url!("about:invalid"));
+ |_error| Url::parse("about:invalid").unwrap());
// Parsing optional format()
let format_hints = if input.try(|input| input.expect_function_matching("format")).is_ok() {
diff --git a/components/style/parser.rs b/components/style/parser.rs
index 44ee04bd5f2..b044367e8dd 100644
--- a/components/style/parser.rs
+++ b/components/style/parser.rs
@@ -34,7 +34,7 @@ impl<'a> ParserContext<'a> {
impl<'a> ParserContext<'a> {
pub fn parse_url(&self, input: &str) -> Url {
self.base_url.join(input)
- .unwrap_or_else(|_| url!("about:invalid"))
+ .unwrap_or_else(|_| Url::parse("about:invalid").unwrap())
}
}
diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs
index d210f888e39..2fa960d286e 100644
--- a/components/style/selector_matching.rs
+++ b/components/style/selector_matching.rs
@@ -69,7 +69,7 @@ lazy_static! {
Ok(res) => {
Stylesheet::from_bytes(
&res,
- url!("chrome:///quirks-mode.css"),
+ Url::parse("chrome:///quirks-mode.css").unwrap(),
None,
None,
Origin::UserAgent,
diff --git a/components/util/opts.rs b/components/util/opts.rs
index 9b5dea10f9c..a828925c88e 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -463,7 +463,7 @@ const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;
pub fn default_opts() -> Opts {
Opts {
is_running_problem_test: false,
- url: Some(url!("about:blank")),
+ url: Some(Url::parse("about:blank").unwrap()),
paint_threads: 1,
gpu_painting: false,
tile_size: 512,
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 2d36666b76b..8fff6dbebdf 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -1408,7 +1408,6 @@ name = "plugins"
version = "0.0.1"
dependencies = [
"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]]
diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock
index 8516abbe295..3241ad4a0f4 100644
--- a/ports/geckolib/Cargo.lock
+++ b/ports/geckolib/Cargo.lock
@@ -273,7 +273,6 @@ name = "plugins"
version = "0.0.1"
dependencies = [
"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]]
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 94f16308b37..34c304b128e 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -1390,7 +1390,6 @@ name = "plugins"
version = "0.0.1"
dependencies = [
"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]]
diff --git a/tests/unit/net/cookie.rs b/tests/unit/net/cookie.rs
index a7b10403745..8d94f9cba70 100644
--- a/tests/unit/net/cookie.rs
+++ b/tests/unit/net/cookie.rs
@@ -7,6 +7,7 @@ extern crate cookie as cookie_rs;
use net::cookie::Cookie;
use net::cookie_storage::CookieStorage;
use net_traits::CookieSource;
+use url::Url;
#[test]
fn test_domain_match() {
@@ -56,9 +57,9 @@ fn test_default_path() {
fn fn_cookie_constructor() {
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
assert!(cookie_rs::Cookie::parse(" baz ").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.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();
assert!(Cookie::new_wrapped(cookie, u, CookieSource::HTTP).is_some());
}
@@ -117,7 +118,7 @@ fn delay_to_ensure_different_timestamp() {
fn test_sort_order() {
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 = Cookie::new_wrapped(a_wrapped.clone(), url, CookieSource::HTTP).unwrap();
delay_to_ensure_different_timestamp();
diff --git a/tests/unit/net/hsts.rs b/tests/unit/net/hsts.rs
index 16de7db6203..898f31b06b0 100644
--- a/tests/unit/net/hsts.rs
+++ b/tests/unit/net/hsts.rs
@@ -6,6 +6,7 @@ use net::hsts::{HSTSList, HSTSEntry};
use net::hsts::{secure_url, preload_hsts_domains};
use net_traits::IncludeSubdomains;
use time;
+use url::Url;
#[test]
fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() {
@@ -255,7 +256,7 @@ fn test_preload_hsts_domains_well_formed() {
#[test]
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);
assert!(secure.port().unwrap() == 8080u16);
@@ -263,7 +264,7 @@ fn test_secure_url_does_not_change_explicit_port() {
#[test]
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);
assert_eq!(&secure.scheme, "file");
@@ -271,7 +272,7 @@ fn test_secure_url_does_not_affect_non_http_schemas() {
#[test]
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);
assert_eq!(&secure.scheme, "https");
diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs
index 5486840a535..d882e99b084 100644
--- a/tests/unit/net/http_loader.rs
+++ b/tests/unit/net/http_loader.rs
@@ -372,7 +372,7 @@ fn expect_devtools_http_response(devtools_port: &Receiver<DevtoolsControlMsg>) -
#[test]
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();
@@ -415,7 +415,7 @@ fn test_check_default_headers_loaded_in_every_request() {
#[test]
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();
@@ -452,7 +452,7 @@ fn test_request_and_response_data_with_network_messages() {
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>();
// 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();
@@ -526,7 +526,7 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
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 load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
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);
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 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 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);
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);
@@ -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);
@@ -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();
@@ -769,7 +769,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
#[test]
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);
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]
fn test_load_sends_secure_cookie_if_http_changed_to_https_due_to_entry_in_hsts_store() {
- let url = url!("http://mozilla.com");
- let secured_url = url!("https://mozilla.com");
+ let url = Url::parse("http://mozilla.com").unwrap();
+ let secured_url = Url::parse("https://mozilla.com").unwrap();
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]
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();
@@ -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();
@@ -919,7 +919,7 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
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,
&http_state,
None,
@@ -933,8 +933,8 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
#[test]
fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() {
- let sec_url = url!("https://mozilla.com");
- let url = url!("http://mozilla.com");
+ let sec_url = Url::parse("https://mozilla.com").unwrap();
+ let url = Url::parse("http://mozilla.com").unwrap();
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() {
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);
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();
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);
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
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)),
]));
- 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);
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();
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);
load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes()));
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::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);
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 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 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 http_state = HttpState::new();
@@ -1191,7 +1191,7 @@ impl HttpRequestFactory for DontConnectFactory {
#[test]
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 http_state = HttpState::new();
@@ -1209,7 +1209,7 @@ fn test_load_errors_when_scheme_is_not_http_or_https() {
#[test]
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 http_state = HttpState::new();
@@ -1251,7 +1251,7 @@ fn test_load_errors_when_cancelled() {
let cancel_listener = CancellationListener::new(Some(cancel_resource));
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 http_state = HttpState::new();
@@ -1268,8 +1268,8 @@ fn test_load_errors_when_cancelled() {
#[test]
fn test_redirect_from_x_to_y_provides_y_cookies_from_y() {
- let url_x = url!("http://mozilla.com");
- let url_y = url!("http://mozilla.org");
+ let url_x = Url::parse("http://mozilla.com").unwrap();
+ let url_y = Url::parse("http://mozilla.org").unwrap();
struct Factory;
@@ -1338,7 +1338,7 @@ fn test_redirect_from_x_to_y_provides_y_cookies_from_y() {
#[test]
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;
@@ -1385,7 +1385,7 @@ fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() {
#[test]
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();
diff --git a/tests/unit/net/resource_thread.rs b/tests/unit/net/resource_thread.rs
index fd9140befd9..fdaa0cd6bdb 100644
--- a/tests/unit/net/resource_thread.rs
+++ b/tests/unit/net/resource_thread.rs
@@ -21,7 +21,7 @@ fn test_exit() {
fn test_bad_scheme() {
let resource_thread = new_resource_thread("".to_owned(), None);
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),
LoadConsumer::Channel(start_chan), None)).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("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");
- 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");
- 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");
}
diff --git a/tests/unit/plugin/Cargo.toml b/tests/unit/plugin/Cargo.toml
deleted file mode 100644
index 1689ae1693e..00000000000
--- a/tests/unit/plugin/Cargo.toml
+++ /dev/null
@@ -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"]}
diff --git a/tests/unit/plugin/lib.rs b/tests/unit/plugin/lib.rs
deleted file mode 100644
index 6e2a9155081..00000000000
--- a/tests/unit/plugin/lib.rs
+++ /dev/null
@@ -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;
diff --git a/tests/unit/plugin/url_plugin.rs b/tests/unit/plugin/url_plugin.rs
deleted file mode 100644
index 911a53e84e8..00000000000
--- a/tests/unit/plugin/url_plugin.rs
+++ /dev/null
@@ -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());
-}
diff --git a/tests/unit/script/origin.rs b/tests/unit/script/origin.rs
index 81e5d538686..c580888de1a 100644
--- a/tests/unit/script/origin.rs
+++ b/tests/unit/script/origin.rs
@@ -3,32 +3,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use script::origin::Origin;
+use url::Url;
#[test]
fn same_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.com/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
assert!(a.same_origin(&b));
assert_eq!(a.is_scheme_host_port_tuple(), true);
}
#[test]
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));
}
#[test]
fn cross_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.org/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
assert!(!a.same_origin(&b));
}
#[test]
fn alias_same_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.com/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
let c = b.alias();
assert!(a.same_origin(&c));
assert!(b.same_origin(&b));
@@ -38,8 +39,8 @@ fn alias_same_origin() {
#[test]
fn alias_cross_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.org/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
let c = b.alias();
assert!(!a.same_origin(&c));
assert!(b.same_origin(&c));
@@ -48,10 +49,10 @@ fn alias_cross_origin() {
#[test]
fn alias_update_same_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.org/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.org/b.html").unwrap());
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!(b.same_origin(&c));
assert!(c.same_origin(&c));
@@ -59,10 +60,10 @@ fn alias_update_same_origin() {
#[test]
fn alias_update_cross_origin() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.com/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
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!(b.same_origin(&c));
assert!(c.same_origin(&c));
@@ -70,8 +71,8 @@ fn alias_update_cross_origin() {
#[test]
fn alias_chain() {
- let a = Origin::new(&url!("http://example.com/a.html"));
- let b = Origin::new(&url!("http://example.com/b.html"));
+ let a = Origin::new(&Url::parse("http://example.com/a.html").unwrap());
+ let b = Origin::new(&Url::parse("http://example.com/b.html").unwrap());
let c = b.copy();
let d = c.alias();
let e = d.alias();
@@ -80,7 +81,7 @@ fn alias_chain() {
assert!(c.same_origin(&e));
assert!(d.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!(!b.same_origin(&c));
assert!(c.same_origin(&d));
diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs
index c194fa4ee92..daa6f1c2569 100644
--- a/tests/unit/style/media_queries.rs
+++ b/tests/unit/style/media_queries.rs
@@ -11,6 +11,7 @@ use style::media_queries::*;
use style::servo::Stylesheet;
use style::stylesheets::{Origin, CSSRuleIteratorExt};
use style::values::specified;
+use url::Url;
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) {
- 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 mut rule_count = 0;
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) {
- 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 rule_count = ss.effective_rules(device).style().count();
assert!(rule_count == expected_rule_count, css.to_owned());
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index 1bed8f94a1d..53e891f5dd1 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -13,6 +13,7 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredV
use style::stylesheets::{CSSRule, StyleRule, Origin};
use style::error_reporting::ParseErrorReporter;
use style::servo::Stylesheet;
+use url::Url;
#[test]
fn test_parse_stylesheet() {
@@ -23,7 +24,7 @@ fn test_parse_stylesheet() {
html , body /**/ { display: block; }
#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,
Box::new(CSSErrorReporterTest));
assert_eq!(stylesheet, Stylesheet {
@@ -198,7 +199,7 @@ fn test_report_error_stylesheet() {
invalid: true;
}
";
- let url = url!("about::test");
+ let url = Url::parse("about::test").unwrap();
let error_reporter = Box::new(CSSInvalidErrorReporterTest::new());
let errors = error_reporter.errors.clone();
diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs
index 15707faec75..316e7c25340 100644
--- a/tests/unit/style/viewport.rs
+++ b/tests/unit/style/viewport.rs
@@ -16,10 +16,11 @@ use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
use style::values::specified::ViewportPercentageLength::Vw;
use style::viewport::*;
use style_traits::viewport::*;
+use url::Url;
macro_rules! stylesheet {
($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]
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));
macro_rules! from_css {