Remove the url! plugin.

In rust-url 1.0 the `Url` struct is going to have private fields, and there
is no way to to create an aribitrary one without going through the parser.

The plugin never had a clear demonstrated performance benefit,
it was made mostly because it was possible and relatively easy at the time.
This commit is contained in:
Simon Sapin 2016-02-26 17:01:51 +01:00
parent 87d5424d4d
commit 6889f37d9e
27 changed files with 84 additions and 296 deletions

View file

@ -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));