blob: 526b12bf0f92514b0724ebf0c1cbc86b47195113 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* 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 servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
#[test]
fn same_origin() {
let a = MutableOrigin::new(ServoUrl::parse("http://example.com/a.html").unwrap().origin());
let b = MutableOrigin::new(ServoUrl::parse("http://example.com/b.html").unwrap().origin());
assert!(a.same_origin(&b));
assert_eq!(a.is_tuple(), true);
}
#[test]
fn identical_origin() {
let a = MutableOrigin::new(ServoUrl::parse("http://example.com/a.html").unwrap().origin());
assert!(a.same_origin(&a));
}
#[test]
fn cross_origin() {
let a = MutableOrigin::new(ServoUrl::parse("http://example.com/a.html").unwrap().origin());
let b = MutableOrigin::new(ServoUrl::parse("http://example.org/b.html").unwrap().origin());
assert!(!a.same_origin(&b));
}
#[test]
fn clone_same_origin() {
let a = MutableOrigin::new(ServoUrl::parse("http://example.com/a.html").unwrap().origin());
let b = MutableOrigin::new(ServoUrl::parse("http://example.com/b.html").unwrap().origin());
let c = b.clone();
assert!(a.same_origin(&c));
assert!(b.same_origin(&b));
assert!(c.same_origin(&b));
assert_eq!(c.is_tuple(), true);
}
#[test]
fn clone_cross_origin() {
let a = MutableOrigin::new(ServoUrl::parse("http://example.com/a.html").unwrap().origin());
let b = MutableOrigin::new(ServoUrl::parse("http://example.org/b.html").unwrap().origin());
let c = b.clone();
assert!(!a.same_origin(&c));
assert!(b.same_origin(&c));
assert!(c.same_origin(&c));
}
#[test]
fn opaque() {
let a = MutableOrigin::new(ImmutableOrigin::new_opaque());
let b = MutableOrigin::new(ImmutableOrigin::new_opaque());
assert!(!a.same_origin(&b));
assert_eq!(a.is_tuple(), false);
}
#[test]
fn opaque_clone() {
let a = MutableOrigin::new(ImmutableOrigin::new_opaque());
let b = a.clone();
assert!(a.same_origin(&b));
assert_eq!(a.is_tuple(), false);
}
|