servo: Merge #10606 - Remove the url! plugin (from servo:remove-url-plugin); r=nox
authorSimon Sapin <simon.sapin@exyr.org>
Thu, 14 Apr 2016 18:45:05 +0500
changeset 338518 1d2d8eb7bbac5a9b59a9051e765db07ded736e41
parent 338517 244dbd6196d4099e1d85eecba38e26a6523222aa
child 338519 14e80afdf536718c1785ff674fbcb3d3dcf1dc0b
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #10606 - Remove the url! plugin (from servo:remove-url-plugin); r=nox 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 was originally part of #9840, but it’s taking a while to land and I keep removing new uses of `url!` when rebasing. r? @nox Source-Repo: https://github.com/servo/servo Source-Revision: 3368565b3c6c76e5ce2d170d5c5cfb2f52a56956
servo/components/compositing/constellation.rs
servo/components/plugins/Cargo.toml
servo/components/plugins/lib.rs
servo/components/plugins/url_plugin.rs
servo/components/script/dom/document.rs
servo/components/script/dom/htmliframeelement.rs
servo/components/script/script_thread.rs
servo/components/servo/Cargo.lock
servo/components/servo/Cargo.toml
servo/components/style/font_face.rs
servo/components/style/parser.rs
servo/components/style/selector_matching.rs
servo/components/util/opts.rs
servo/ports/cef/Cargo.lock
servo/ports/geckolib/Cargo.lock
servo/ports/gonk/Cargo.lock
servo/tests/unit/net/cookie.rs
servo/tests/unit/net/hsts.rs
servo/tests/unit/net/http_loader.rs
servo/tests/unit/net/resource_thread.rs
servo/tests/unit/plugin/Cargo.toml
servo/tests/unit/plugin/lib.rs
servo/tests/unit/plugin/url_plugin.rs
servo/tests/unit/script/origin.rs
servo/tests/unit/style/media_queries.rs
servo/tests/unit/style/stylesheets.rs
servo/tests/unit/style/viewport.rs
--- a/servo/components/compositing/constellation.rs
+++ b/servo/components/compositing/constellation.rs
@@ -863,17 +863,17 @@ impl<LTF: LayoutThreadFactory, STF: Scri
 
         warn!("creating replacement pipeline for about:failure");
 
         let new_pipeline_id = PipelineId::new();
         self.new_pipeline(new_pipeline_id,
                           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));
 
     }
 
     fn handle_init_load(&mut self, url: Url) {
         let window_size = self.window_size.visible_viewport;
         let root_pipeline_id = PipelineId::new();
@@ -946,17 +946,17 @@ impl<LTF: LayoutThreadFactory, STF: Scri
             let source_pipeline =  match self.pipelines.get(&load_info.containing_pipeline_id) {
                 Some(source_pipeline) => source_pipeline,
                 None => return warn!("Script loaded url in closed iframe {}.", load_info.containing_pipeline_id),
             };
 
             // 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
             let source_url = &source_pipeline.url;
 
             let same_script = source_url.host() == new_url.host() &&
                               source_url.port() == new_url.port() &&
                               load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed;
--- a/servo/components/plugins/Cargo.toml
+++ b/servo/components/plugins/Cargo.toml
@@ -11,12 +11,11 @@ plugin = true
 
 [dependencies.clippy]
 git = "https://github.com/Manishearth/rust-clippy"
 rev = "9dca15de3e8ea266d3e7e868c0f358ed4fa5f195"
 optional = true
 
 [dependencies]
 tenacious = "0.1.2"
-url = {version = "0.5.7", features = ["heap_size"]}
 
 [features]
 default = []
--- a/servo/components/plugins/lib.rs
+++ b/servo/components/plugins/lib.rs
@@ -23,40 +23,35 @@ extern crate clippy;
 extern crate rustc;
 extern crate rustc_front;
 extern crate rustc_plugin;
 #[macro_use]
 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;
 use syntax::parse::token::intern;
 
 // Public for documentation to show up
 /// Handles the auto-deriving for `#[derive(JSTraceable)]`
 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;
 
 #[plugin_registrar]
 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);
     reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass);
     reg.register_early_lint_pass(box lints::ban::BanPass);
     reg.register_late_lint_pass(box tenacious::TenaciousPass);
     reg.register_attribute("must_root".to_string(), Whitelisted);
     reg.register_attribute("servo_lang".to_string(), Whitelisted);
deleted file mode 100644
--- a/servo/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)
-    }
-}
--- a/servo/components/script/dom/document.rs
+++ b/servo/components/script/dom/document.rs
@@ -1598,17 +1598,17 @@ impl Document {
                          browsing_context: Option<&BrowsingContext>,
                          url: Option<Url>,
                          is_html_document: IsHTMLDocument,
                          content_type: Option<DOMString>,
                          last_modified: Option<String>,
                          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)
         } else {
             (DocumentReadyState::Complete, true)
         };
 
         // Incomplete implementation of Document origin specification at
--- a/servo/components/script/dom/htmliframeelement.rs
+++ b/servo/components/script/dom/htmliframeelement.rs
@@ -141,17 +141,17 @@ impl HTMLIFrameElement {
             // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
             self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
         }
     }
 
     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));
     }
 
     #[allow(unsafe_code)]
     pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
         // TODO(gw): Support mozbrowser event types that have detail which is not a string.
--- a/servo/components/script/script_thread.rs
+++ b/servo/components/script/script_thread.rs
@@ -1875,17 +1875,17 @@ impl ScriptThread {
         ROUTER.add_route(action_receiver.to_opaque(), box move |message| {
             listener.notify(message.to().unwrap());
         });
         let response_target = AsyncResponseTarget {
             sender: action_sender,
         };
 
         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 {
             context: LoadContext::Browsing,
             url: load_data.url,
             method: load_data.method,
             headers: Headers::new(),
             preserved_headers: load_data.headers,
--- a/servo/components/servo/Cargo.lock
+++ b/servo/components/servo/Cargo.lock
@@ -27,17 +27,16 @@ dependencies = [
  "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "msg 0.0.1",
  "net 0.0.1",
  "net_tests 0.0.1",
  "net_traits 0.0.1",
  "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",
  "script_tests 0.0.1",
  "script_traits 0.0.1",
  "style 0.0.1",
  "style_tests 0.0.1",
  "url 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1522,29 +1521,20 @@ name = "plugin_compiletest"
 version = "0.0.1"
 dependencies = [
  "compiletest_helper 0.0.1",
  "plugins 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]]
 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]]
 name = "pnacl-build-helper"
 version = "1.4.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/components/servo/Cargo.toml
+++ b/servo/components/servo/Cargo.toml
@@ -28,19 +28,16 @@ path = "../../tests/unit/gfx"
 path = "../../tests/unit/layout"
 
 [dev-dependencies.net_tests]
 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"
 
 [dev-dependencies.style_tests]
 path = "../../tests/unit/style"
 
 [dev-dependencies.util_tests]
 path = "../../tests/unit/util"
--- a/servo/components/style/font_face.rs
+++ b/servo/components/style/font_face.rs
@@ -97,17 +97,17 @@ impl<'a, 'b> DeclarationParser for FontF
 }
 
 fn parse_one_src(context: &ParserContext, input: &mut Parser) -> Result<Source, ()> {
     if input.try(|input| input.expect_function_matching("local")).is_ok() {
         return Ok(Source::Local(try!(input.parse_nested_block(parse_one_family))))
     }
     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() {
         try!(input.parse_nested_block(|input| {
             input.parse_comma_separated(|input| {
                 Ok((try!(input.expect_string())).into_owned())
             })
         }))
--- a/servo/components/style/parser.rs
+++ b/servo/components/style/parser.rs
@@ -29,17 +29,17 @@ 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())
     }
 }
 
 
 /// Defaults to a no-op.
 /// Set a `RUST_LOG=style::errors` environment variable
 /// to log CSS parse errors to stderr.
 pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str, parsercontext: &ParserContext) {
--- a/servo/components/style/selector_matching.rs
+++ b/servo/components/style/selector_matching.rs
@@ -64,17 +64,17 @@ lazy_static! {
 }
 
 lazy_static! {
     pub static ref QUIRKS_MODE_STYLESHEET: Stylesheet<ServoSelectorImpl> = {
         match read_resource_file(&["quirks-mode.css"]) {
             Ok(res) => {
                 Stylesheet::from_bytes(
                     &res,
-                    url!("chrome:///quirks-mode.css"),
+                    Url::parse("chrome:///quirks-mode.css").unwrap(),
                     None,
                     None,
                     Origin::UserAgent,
                     box StdoutErrorReporter)
             },
             Err(..) => {
                 error!("Stylist failed to load 'quirks-mode.css'!");
                 process::exit(1);
--- a/servo/components/util/opts.rs
+++ b/servo/components/util/opts.rs
@@ -458,17 +458,17 @@ const DEFAULT_USER_AGENT: UserAgent = Us
 const DEFAULT_USER_AGENT: UserAgent = UserAgent::Gonk;
 
 #[cfg(not(any(target_os = "android", target_os = "gonk")))]
 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,
         device_pixels_per_px: None,
         time_profiler_period: None,
         mem_profiler_period: None,
         layout_threads: 1,
         nonincremental_layout: false,
--- a/servo/ports/cef/Cargo.lock
+++ b/servo/ports/cef/Cargo.lock
@@ -1403,17 +1403,16 @@ name = "pkg-config"
 version = "0.3.5"
 source = "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]]
 name = "pnacl-build-helper"
 version = "1.4.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/ports/geckolib/Cargo.lock
+++ b/servo/ports/geckolib/Cargo.lock
@@ -268,17 +268,16 @@ name = "phf_shared"
 version = "0.7.13"
 source = "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]]
 name = "quasi"
 version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
--- a/servo/ports/gonk/Cargo.lock
+++ b/servo/ports/gonk/Cargo.lock
@@ -1385,17 +1385,16 @@ name = "pkg-config"
 version = "0.3.5"
 source = "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]]
 name = "pnacl-build-helper"
 version = "1.4.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/tests/unit/net/cookie.rs
+++ b/servo/tests/unit/net/cookie.rs
@@ -2,16 +2,17 @@
  * 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/. */
 
 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() {
     assert!(Cookie::domain_match("foo.com", "foo.com"));
     assert!(Cookie::domain_match("bar.foo.com", "foo.com"));
     assert!(Cookie::domain_match("baz.bar.foo.com", "foo.com"));
 
     assert!(!Cookie::domain_match("bar.foo.com", "bar.com"));
@@ -51,19 +52,19 @@ fn test_default_path() {
     assert!(&*Cookie::default_path("") == "/");
     assert!(&*Cookie::default_path("foo") == "/");
 }
 
 #[test]
 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());
     assert!(cookie_rs::Cookie::parse(" baz = ").is_ok());
 
     // cookie domains test
     let cookie = cookie_rs::Cookie::parse(" baz = bar; Domain =  ").unwrap();
     assert!(Cookie::new_wrapped(cookie.clone(), url, CookieSource::HTTP).is_some());
@@ -89,17 +90,17 @@ fn fn_cookie_constructor() {
     let cookie = Cookie::new_wrapped(cookie, url, CookieSource::HTTP).unwrap();
     assert!(cookie.cookie.value == "bar");
     assert!(cookie.cookie.name == "baz");
     assert!(cookie.cookie.secure);
     assert!(&cookie.cookie.path.as_ref().unwrap()[..] == "/foo/bar/");
     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());
 }
 
 #[cfg(target_os = "windows")]
 fn delay_to_ensure_different_timestamp() {
     use std::thread;
     use std::time::Duration;
@@ -112,17 +113,17 @@ fn delay_to_ensure_different_timestamp()
 #[cfg(not(target_os = "windows"))]
 fn delay_to_ensure_different_timestamp() {
 }
 
 #[test]
 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();
     let a_prime = Cookie::new_wrapped(a_wrapped, url, CookieSource::HTTP).unwrap();
     let b = cookie_rs::Cookie::parse("baz=bar;Path=/foo/bar/baz/").unwrap();
     let b = Cookie::new_wrapped(b, url, CookieSource::HTTP).unwrap();
 
     assert!(b.cookie.path.as_ref().unwrap().len() > a.cookie.path.as_ref().unwrap().len());
--- a/servo/tests/unit/net/hsts.rs
+++ b/servo/tests/unit/net/hsts.rs
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use net::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() {
     let entry = HSTSEntry {
         host: "mozilla.org".to_owned(),
         include_subdomains: false,
         max_age: Some(20),
         timestamp: None
@@ -250,29 +251,29 @@ fn test_hsts_list_with_expired_entry_is_
 #[test]
 fn test_preload_hsts_domains_well_formed() {
     let hsts_list = preload_hsts_domains().unwrap();
     assert!(!hsts_list.entries.is_empty());
 }
 
 #[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);
 }
 
 #[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");
 }
 
 #[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");
 }
--- a/servo/tests/unit/net/http_loader.rs
+++ b/servo/tests/unit/net/http_loader.rs
@@ -367,17 +367,17 @@ fn expect_devtools_http_response(devtool
             }
         },
         _ => panic!("No HttpResponse Received"),
     }
 }
 
 #[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();
 
     let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
     load_data.data = None;
     load_data.method = Method::Get;
 
     let mut headers = Headers::new();
@@ -410,17 +410,17 @@ fn test_check_default_headers_loaded_in_
                                                 &AssertMustHaveHeadersRequestFactory {
                                                     expected_headers: headers,
                                                     body: <[_]>::to_vec(&[])
                                                 }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None));
 }
 
 #[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();
 
     let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
     load_data.data = None;
     load_data.method = Method::Post;
 
     let mut content_length = Headers::new();
@@ -447,17 +447,17 @@ fn test_request_and_response_data_with_n
             Ok(MockRequest::new(
                    ResponseType::WithHeaders(<[_]>::to_vec("Yay!".as_bytes()), headers))
             )
         }
     }
 
     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();
     let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), Some(pipeline_id));
     let mut request_headers = Headers::new();
     request_headers.set(Host { hostname: "bar.foo".to_owned(), port: None });
     load_data.headers = request_headers.clone();
     let _ = load::<MockRequest>(load_data, &http_state, Some(devtools_chan), &Factory,
@@ -521,17 +521,17 @@ fn test_request_and_response_message_fro
             Ok(MockRequest::new(
                    ResponseType::WithHeaders(<[_]>::to_vec("Yay!".as_bytes()), headers))
             )
         }
     }
 
     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,
                                 DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None));
 
     // notification received from devtools
     assert!(devtools_port.try_recv().is_err());
 }
@@ -551,17 +551,17 @@ fn test_load_when_redirecting_from_a_pos
                 Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.org".to_owned())))
             } else {
                 assert_eq!(Method::Get, method);
                 Ok(MockRequest::new(ResponseType::Text(<[_]>::to_vec("Yay!".as_bytes()))))
             }
         }
     }
 
-    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;
 
     let http_state = HttpState::new();
 
     let _ = load::<MockRequest>(load_data, &http_state, None, &Factory,
                                 DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None));
 }
@@ -579,17 +579,17 @@ fn test_load_should_decode_the_response_
             let encoded_content = e.finish().unwrap();
 
             let mut headers = Headers::new();
             headers.set(ContentEncoding(vec![Encoding::Deflate]));
             Ok(MockRequest::new(ResponseType::WithHeaders(encoded_content, headers)))
         }
     }
 
-    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();
 
     let mut response = load::<MockRequest>(
         load_data, &http_state, None,
         &Factory,
         DEFAULT_USER_AGENT.to_owned(),
@@ -612,17 +612,17 @@ fn test_load_should_decode_the_response_
             let encoded_content = e.finish().unwrap();
 
             let mut headers = Headers::new();
             headers.set(ContentEncoding(vec![Encoding::Gzip]));
             Ok(MockRequest::new(ResponseType::WithHeaders(encoded_content, headers)))
         }
     }
 
-    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();
 
     let mut response = load::<MockRequest>(
         load_data,
         &http_state,
         None, &Factory,
         DEFAULT_USER_AGENT.to_owned(),
@@ -653,17 +653,17 @@ fn test_load_doesnt_send_request_body_on
                         ResponseType::Text(<[_]>::to_vec("Yay!".as_bytes())),
                         None
                     )
                 )
             }
         }
     }
 
-    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()));
 
     let http_state = HttpState::new();
 
     let _ = load::<AssertMustHaveBodyRequest>(
         load_data, &http_state,
         None,
@@ -682,17 +682,17 @@ fn test_load_doesnt_add_host_to_sts_list
         fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
             let content = <[_]>::to_vec("Yay!".as_bytes());
             let mut headers = Headers::new();
             headers.set(StrictTransportSecurity::excluding_subdomains(31536000));
             Ok(MockRequest::new(ResponseType::WithHeaders(content, headers)))
         }
     }
 
-    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();
 
     let _ = load::<MockRequest>(load_data,
                                 &http_state,
                                 None,
@@ -713,17 +713,17 @@ fn test_load_adds_host_to_sts_list_when_
         fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
             let content = <[_]>::to_vec("Yay!".as_bytes());
             let mut headers = Headers::new();
             headers.set(StrictTransportSecurity::excluding_subdomains(31536000));
             Ok(MockRequest::new(ResponseType::WithHeaders(content, headers)))
         }
     }
 
-    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();
 
     let _ = load::<MockRequest>(load_data,
                                 &http_state,
                                 None,
@@ -744,17 +744,17 @@ fn test_load_sets_cookies_in_the_resourc
         fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
             let content = <[_]>::to_vec("Yay!".as_bytes());
             let mut headers = Headers::new();
             headers.set(SetCookie(vec![CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned())]));
             Ok(MockRequest::new(ResponseType::WithHeaders(content, headers)))
         }
     }
 
-    let url = url!("http://mozilla.com");
+    let url = Url::parse("http://mozilla.com").unwrap();
 
     let http_state = HttpState::new();
 
     assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", "");
 
     let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
 
     let _ = load::<MockRequest>(load_data,
@@ -764,17 +764,17 @@ fn test_load_sets_cookies_in_the_resourc
                                 DEFAULT_USER_AGENT.to_owned(),
                                 &CancellationListener::new(None));
 
     assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", "mozillaIs=theBest");
 }
 
 #[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()));
 
     let http_state = HttpState::new();
 
     {
         let mut cookie_jar = http_state.cookie_jar.write().unwrap();
@@ -795,18 +795,18 @@ fn test_load_sets_requests_cookies_heade
                                                         expected_headers: cookie,
                                                         body: <[_]>::to_vec(&*load_data.data.unwrap())
                                                     }, DEFAULT_USER_AGENT.to_owned(),
                                                     &CancellationListener::new(None));
 }
 
 #[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();
     {
         let mut hsts_list = http_state.hsts_list.write().unwrap();
         let entry = HSTSEntry::new(
             "mozilla.com".to_owned(), IncludeSubdomains::Included, Some(1000000)
         ).unwrap();
         hsts_list.push(entry);
@@ -837,17 +837,17 @@ fn test_load_sends_secure_cookie_if_http
         &AssertMustIncludeHeadersRequestFactory {
             expected_headers: headers,
             body: <[_]>::to_vec(&*load_data.data.unwrap())
         }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None));
 }
 
 #[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();
 
     {
         let mut cookie_jar = http_state.cookie_jar.write().unwrap();
         let cookie_url = url.clone();
         let cookie = Cookie::new_wrapped(
             CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned()),
@@ -881,17 +881,17 @@ fn test_cookie_set_with_httponly_should_
         fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
             let content = <[_]>::to_vec("Yay!".as_bytes());
             let mut headers = Headers::new();
             headers.set_raw("set-cookie", vec![b"mozillaIs=theBest; HttpOnly;".to_vec()]);
             Ok(MockRequest::new(ResponseType::WithHeaders(content, headers)))
         }
     }
 
-    let url = url!("http://mozilla.com");
+    let url = Url::parse("http://mozilla.com").unwrap();
 
     let http_state = HttpState::new();
 
     let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
     let _ = load::<MockRequest>(load_data,
                                 &http_state,
                                 None,
                                 &Factory,
@@ -914,32 +914,32 @@ fn test_when_cookie_received_marked_secu
             let mut headers = Headers::new();
             headers.set_raw("set-cookie", vec![b"mozillaIs=theBest; Secure;".to_vec()]);
             Ok(MockRequest::new(ResponseType::WithHeaders(content, headers)))
         }
     }
 
     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,
                                 &Factory,
                                 DEFAULT_USER_AGENT.to_owned(),
                                 &CancellationListener::new(None));
 
     assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", "");
 }
 
 #[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();
 
     {
         let mut cookie_jar = http_state.cookie_jar.write().unwrap();
         let cookie_url = sec_url.clone();
         let cookie = Cookie::new_wrapped(
             CookiePair::parse("mozillaIs=theBest; Secure;").unwrap(),
@@ -961,17 +961,17 @@ fn test_when_cookie_set_marked_httpsonly
             body: <[_]>::to_vec(&*load_data.data.unwrap())
         }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None));
 }
 
 #[test]
 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()));
 
     let mut content_len_headers = Headers::new();
     content_len_headers.set(ContentLength(content.as_bytes().len() as u64));
 
     let http_state = HttpState::new();
 
@@ -985,17 +985,17 @@ fn test_load_sets_content_length_to_leng
 
 #[test]
 fn test_load_uses_explicit_accept_from_headers_in_load_data() {
     let text_html = qitem(Mime(TopLevel::Text, SubLevel::Html, vec![]));
 
     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()]));
 
     let http_state = HttpState::new();
 
     let _ = load::<AssertRequestMustIncludeHeaders>(load_data,
                                                     &http_state,
@@ -1012,17 +1012,17 @@ fn test_load_sets_default_accept_to_html
     let mut accept_headers = Headers::new();
     accept_headers.set(Accept(vec![
         qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
         qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
         QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), Quality(900)),
         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()));
 
     let http_state = HttpState::new();
 
     let _ = load::<AssertRequestMustIncludeHeaders>(load_data,
                                                     &http_state,
                                                     None,
@@ -1033,17 +1033,17 @@ fn test_load_sets_default_accept_to_html
                                                     &CancellationListener::new(None));
 }
 
 #[test]
 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)]));
 
     let http_state = HttpState::new();
 
     let _ = load::<AssertRequestMustIncludeHeaders>(load_data,
                                                     &http_state,
@@ -1057,17 +1057,17 @@ fn test_load_uses_explicit_accept_encodi
 
 #[test]
 fn test_load_sets_default_accept_encoding_to_gzip_and_deflate() {
     let mut accept_encoding_headers = Headers::new();
     accept_encoding_headers.set(AcceptEncoding(vec![qitem(Encoding::Gzip),
                                                     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()));
 
     let http_state = HttpState::new();
 
     let _ = load::<AssertRequestMustIncludeHeaders>(load_data,
                                                     &http_state,
                                                     None,
@@ -1091,17 +1091,17 @@ fn test_load_errors_when_there_a_redirec
             } else if url.domain().unwrap() == "mozilla.org" {
                 Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.com".to_owned())))
             } else {
                 panic!("unexpected host {:?}", url)
             }
         }
     }
 
-    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();
 
     match load::<MockRequest>(load_data, &http_state, None, &Factory,
                               DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) {
         Err(LoadError::InvalidRedirect(_, msg)) => {
             assert_eq!(msg, "redirect loop");
@@ -1121,17 +1121,17 @@ fn test_load_errors_when_there_is_too_ma
             if url.domain().unwrap() == "mozilla.com" {
                 Ok(MockRequest::new(ResponseType::Redirect(format!("{}/1", url.serialize()))))
             } else {
                 panic!("unexpected host {:?}", url)
             }
         }
     }
 
-    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();
 
     match load::<MockRequest>(load_data, &http_state, None, &Factory,
                               DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) {
         Err(LoadError::MaxRedirects(url)) => {
             assert_eq!(url.domain().unwrap(), "mozilla.com")
@@ -1159,17 +1159,17 @@ fn test_load_follows_a_redirect() {
                     )
                 )
             } else {
                 panic!("unexpected host {:?}", url)
             }
         }
     }
 
-    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();
 
     match load::<MockRequest>(load_data, &http_state, None, &Factory,
                               DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) {
         Err(e) => panic!("expected to follow a redirect {:?}", e),
         Ok(mut lr) => {
@@ -1186,17 +1186,17 @@ impl HttpRequestFactory for DontConnectF
 
     fn create(&self, url: Url, _: Method) -> Result<MockRequest, LoadError> {
         Err(LoadError::Connection(url, "should not have connected".to_owned()))
     }
 }
 
 #[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();
 
     match load::<MockRequest>(load_data,
                               &http_state,
                               None,
                               &DontConnectFactory,
@@ -1204,17 +1204,17 @@ fn test_load_errors_when_scheme_is_not_h
                               &CancellationListener::new(None)) {
         Err(LoadError::UnsupportedScheme(_)) => {}
         _ => panic!("expected ftp scheme to be unsupported")
     }
 }
 
 #[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();
 
     match load::<MockRequest>(load_data,
                               &http_state,
                               None,
                               &DontConnectFactory,
@@ -1246,35 +1246,35 @@ fn test_load_errors_when_cancelled() {
     }
 
     let (id_sender, _id_receiver) = ipc::channel().unwrap();
     let (cancel_sender, cancel_receiver) = mpsc::channel();
     let cancel_resource = CancellableResource::new(cancel_receiver, ResourceId(0), id_sender);
     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();
 
     match load::<MockRequest>(load_data,
                               &http_state,
                               None,
                               &Factory,
                               DEFAULT_USER_AGENT.to_owned(),
                               &cancel_listener) {
         Err(LoadError::Cancelled(_, _)) => (),
         _ => panic!("expected load cancelled error!")
     }
 }
 
 #[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;
 
     impl HttpRequestFactory for Factory {
         type R = AssertRequestMustIncludeHeaders;
 
         fn create(&self, url: Url, _: Method) -> Result<AssertRequestMustIncludeHeaders, LoadError> {
             if url.domain().unwrap() == "mozilla.com" {
@@ -1333,17 +1333,17 @@ fn  test_redirect_from_x_to_y_provides_y
             let response = read_response(&mut lr);
             assert_eq!(response, "Yay!".to_owned());
         }
     }
 }
 
 #[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;
 
     impl HttpRequestFactory for Factory {
         type R = AssertRequestMustIncludeHeaders;
 
         fn create(&self, url: Url, _: Method) -> Result<AssertRequestMustIncludeHeaders, LoadError> {
             if url.path().unwrap()[0] == "initial" {
@@ -1380,17 +1380,17 @@ fn test_redirect_from_x_to_x_provides_x_
             let response = read_response(&mut lr);
             assert_eq!(response, "Yay!".to_owned());
         }
     }
 }
 
 #[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();
 
     let auth_entry = AuthCacheEntry {
                         user_name: "username".to_owned(),
                         password: "test".to_owned(),
                      };
 
--- a/servo/tests/unit/net/resource_thread.rs
+++ b/servo/tests/unit/net/resource_thread.rs
@@ -16,17 +16,17 @@ fn test_exit() {
     let resource_thread = new_resource_thread("".to_owned(), None);
     resource_thread.send(ControlMsg::Exit).unwrap();
 }
 
 #[test]
 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();
     match response.progress_port.recv().unwrap() {
       ProgressMsg::Done(result) => { assert!(result.is_err()) }
       _ => panic!("bleh")
     }
     resource_thread.send(ControlMsg::Exit).unwrap();
@@ -151,23 +151,23 @@ fn test_parse_hostsfile_with_end_of_line
 }
 
 #[test]
 fn test_replace_hosts() {
     let mut host_table = HashMap::new();
     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");
 }
 
 #[test]
 fn test_cancelled_listener() {
     use std::io::Write;
     use std::net::TcpListener;
     use std::thread;
deleted file mode 100644
--- a/servo/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"]}
deleted file mode 100644
--- a/servo/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;
deleted file mode 100644
--- a/servo/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());
-}
--- a/servo/tests/unit/script/origin.rs
+++ b/servo/tests/unit/script/origin.rs
@@ -1,91 +1,92 @@
 /* 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 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));
     assert!(c.same_origin(&b));
     assert_eq!(c.is_scheme_host_port_tuple(), true);
 }
 
 #[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));
     assert!(c.same_origin(&c));
 }
 
 #[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));
 }
 
 #[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));
 }
 
 #[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();
     assert!(a.same_origin(&e));
     assert!(b.same_origin(&e));
     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));
     assert!(d.same_origin(&e));
     assert!(!e.same_origin(&a));
 }
 
 #[test]
--- a/servo/tests/unit/style/media_queries.rs
+++ b/servo/tests/unit/style/media_queries.rs
@@ -6,40 +6,41 @@ use app_units::Au;
 use cssparser::{Parser, SourcePosition};
 use euclid::size::Size2D;
 use std::borrow::ToOwned;
 use style::error_reporting::ParseErrorReporter;
 use style::media_queries::*;
 use style::servo::Stylesheet;
 use style::stylesheets::{Origin, CSSRuleIteratorExt};
 use style::values::specified;
+use url::Url;
 
 pub struct CSSErrorReporterTest;
 
 impl ParseErrorReporter for CSSErrorReporterTest {
      fn report_error(&self, _input: &mut Parser, _position: SourcePosition, _message: &str) {
      }
      fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
         Box::new(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() {
         rule_count += 1;
         callback(&rule.media_queries, css);
     }
     assert!(rule_count > 0);
 }
 
 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());
 }
 
 #[test]
 fn test_mq_empty() {
     test_media_rule("@media { }", |list, css| {
--- a/servo/tests/unit/style/stylesheets.rs
+++ b/servo/tests/unit/style/stylesheets.rs
@@ -8,27 +8,28 @@ use selectors::parser::*;
 use std::borrow::ToOwned;
 use std::sync::Arc;
 use std::sync::Mutex;
 use string_cache::Atom;
 use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
 use style::stylesheets::{CSSRule, StyleRule, Origin};
 use style::error_reporting::ParseErrorReporter;
 use style::servo::Stylesheet;
+use url::Url;
 
 #[test]
 fn test_parse_stylesheet() {
     let css = r"
         @namespace url(http://www.w3.org/1999/xhtml);
         /* FIXME: only if scripting is enabled */
         input[type=hidden i] { display: none !important; }
         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 {
         origin: Origin::UserAgent,
         media: None,
         dirty_on_viewport_size_change: false,
         rules: vec![
             CSSRule::Namespace(None, ns!(html)),
@@ -193,17 +194,17 @@ impl ParseErrorReporter for CSSInvalidEr
 fn test_report_error_stylesheet() {
     let css = r"
     div {
         background-color: red;
         display: invalid;
         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();
 
     Stylesheet::from_str(css, url, Origin::UserAgent, error_reporter);
 
     let mut errors = errors.lock().unwrap();
 
--- a/servo/tests/unit/style/viewport.rs
+++ b/servo/tests/unit/style/viewport.rs
@@ -11,20 +11,21 @@ use style::media_queries::{Device, Media
 use style::parser::ParserContext;
 use style::servo::Stylesheet;
 use style::stylesheets::{Origin, CSSRuleIteratorExt};
 use style::values::specified::Length::{self, ViewportPercentage};
 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);
     }
 }
 
 fn test_viewport_rule<F>(css: &str,
                          device: &Device,
                          callback: F)
     where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str)
 {
@@ -274,17 +275,17 @@ fn multiple_stylesheets_cascading() {
     assert_decl_len!(declarations == 3);
     assert_decl_eq!(&declarations[0], UserAgent, MinWidth: viewport_length!(100., px), !important);
     assert_decl_eq!(&declarations[1], User, MinHeight: viewport_length!(200., px), !important);
     assert_decl_eq!(&declarations[2], Author, Zoom: Zoom::Number(3.), !important);
 }
 
 #[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 {
         ($css:expr) => {
             &ViewportRule::parse(&mut Parser::new($css), &context).unwrap()
         }
     }