1 description('Test setting the pathname attribute of the URL in HTMLAnchorElement.');
3 var a
= document
.createElement('a');
5 debug("Set pathname that starts with slash");
6 a
.href
= "https://www.mydomain.com/path/testurl.html?key=value";
7 a
.pathname
= "/path name";
8 shouldBe("a.href", "'https://www.mydomain.com/path%20name?key=value'");
10 // IE8 throws an "Invalid URL" exception.
12 debug("Set pathname that does not start with slash and contains '?'");
13 a
.href
= "https://www.mydomain.com/path/testurl.html?key=value";
15 shouldBe("a.href", "'https://www.mydomain.com/pa%3Fth?key=value'");
17 debug("Exception: " + e
.description
);
20 // IE8 throws an "Invalid URL" exception.
22 debug("Set pathname that starts with double slash and contains '#'");
23 a
.href
= "https://www.mydomain.com/path?key=value";
24 a
.pathname
= "//path#name";
25 shouldBe("a.href", "'https://www.mydomain.com//path%23name?key=value'");
27 debug("Exception: " + e
.description
);
30 debug("Set a pathname containing .. in it");
31 a
.href
= "https://www.mydomain.com/path/testurl.html?key=value";
32 a
.pathname
= "/it/../path";
33 shouldBe("a.href", "'https://www.mydomain.com/path?key=value'");
35 debug("Set pathname to null");
36 a
.href
= "https://www.mydomain.com/path/testurl.html?key=value";
38 shouldBe("a.href", "'https://www.mydomain.com/null?key=value'");
40 debug("Set pathname to empty string");
41 a
.href
= "https://www.mydomain.com/?key=value";
43 shouldBe("a.href", "'https://www.mydomain.com/?key=value'");
45 // The expected behavior should change when the character table is updated.
46 // IE8 considers this URL as valid.
47 debug("Set pathname that includes illegal characters to URL that contains illegal characters.");
48 a
.href
= "https://www.my|d[]()omain.com/path/testurl.html?key=value";
49 a
.pathname
= "p$a|th";
50 shouldBe("a.href", "'https://www.my|d[]()omain.com/path/testurl.html?key=value'");
52 // IE8 throws a security exception.
54 debug("Set pathname to URL that contains '@' in host");
55 a
.href
= "http://w@#ww";
57 shouldBe("a.href", "'http://w@/path#ww'");
59 debug("Exception: " + e
.description
);
62 // IE8 allows setting the pathname, for non-hierarchial URL.
63 // It is not supposed to allow that per
64 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
65 debug("Set pathname to a URL with non-hierarchical protocol");
66 a
.href
= "tel:+1800-555-1212";
67 a
.pathname
= "the-path";
68 shouldBe("a.href", "'tel:+1800-555-1212'");