| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/set-href-attribute-pathname.js"></script> | 7 <script> |
| 8 description('Test setting the pathname attribute of the URL in HTMLAnchorElement
.'); |
| 9 |
| 10 var a = document.createElement('a'); |
| 11 |
| 12 debug("Set pathname that starts with slash"); |
| 13 a.href = "https://www.mydomain.com/path/testurl.html?key=value"; |
| 14 a.pathname = "/path name"; |
| 15 shouldBe("a.href", "'https://www.mydomain.com/path%20name?key=value'"); |
| 16 |
| 17 // IE8 throws an "Invalid URL" exception. |
| 18 try { |
| 19 debug("Set pathname that does not start with slash and contains '?'"); |
| 20 a.href = "https://www.mydomain.com/path/testurl.html?key=value"; |
| 21 a.pathname = "pa?th"; |
| 22 shouldBe("a.href", "'https://www.mydomain.com/pa%3Fth?key=value'"); |
| 23 } catch(e) { |
| 24 debug("Exception: " + e.description); |
| 25 } |
| 26 |
| 27 // IE8 throws an "Invalid URL" exception. |
| 28 try { |
| 29 debug("Set pathname that starts with double slash and contains '#'"); |
| 30 a.href = "https://www.mydomain.com/path?key=value"; |
| 31 a.pathname = "//path#name"; |
| 32 shouldBe("a.href", "'https://www.mydomain.com//path%23name?key=value'"); |
| 33 } catch(e) { |
| 34 debug("Exception: " + e.description); |
| 35 } |
| 36 |
| 37 debug("Set a pathname containing .. in it"); |
| 38 a.href = "https://www.mydomain.com/path/testurl.html?key=value"; |
| 39 a.pathname = "/it/../path"; |
| 40 shouldBe("a.href", "'https://www.mydomain.com/path?key=value'"); |
| 41 |
| 42 debug("Set pathname to null"); |
| 43 a.href = "https://www.mydomain.com/path/testurl.html?key=value"; |
| 44 a.pathname = null; |
| 45 shouldBe("a.href", "'https://www.mydomain.com/null?key=value'"); |
| 46 |
| 47 debug("Set pathname to empty string"); |
| 48 a.href = "https://www.mydomain.com/?key=value"; |
| 49 a.pathname = ""; |
| 50 shouldBe("a.href", "'https://www.mydomain.com/?key=value'"); |
| 51 |
| 52 // The expected behavior should change when the character table is updated. |
| 53 // IE8 considers this URL as valid. |
| 54 debug("Set pathname that includes illegal characters to URL that contains illega
l characters."); |
| 55 a.href = "https://www.my|d[]()omain.com/path/testurl.html?key=value"; |
| 56 a.pathname = "p$a|th"; |
| 57 shouldBe("a.href", "'https://www.my|d[]()omain.com/path/testurl.html?key=value'"
); |
| 58 |
| 59 // IE8 throws a security exception. |
| 60 try { |
| 61 debug("Set pathname to URL that contains '@' in host"); |
| 62 a.href = "http://w@#ww"; |
| 63 a.pathname = "path"; |
| 64 shouldBe("a.href", "'http://w@/path#ww'"); |
| 65 } catch(e) { |
| 66 debug("Exception: " + e.description); |
| 67 } |
| 68 |
| 69 // IE8 allows setting the pathname, for non-hierarchial URL. |
| 70 // It is not supposed to allow that per |
| 71 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . |
| 72 debug("Set pathname to a URL with non-hierarchical protocol"); |
| 73 a.href = "tel:+1800-555-1212"; |
| 74 a.pathname = "the-path"; |
| 75 shouldBe("a.href", "'tel:+1800-555-1212'"); |
| 76 </script> |
| 8 </body> | 77 </body> |
| 9 </html> | 78 </html> |
| OLD | NEW |