| OLD | NEW |
| 1 description('Test setting the hostname attribute of the URL in HTMLAnchorElement
.'); | 1 description('Test setting the hostname attribute of the URL in HTMLAnchorElement
.'); |
| 2 | 2 |
| 3 var a = document.createElement('a'); | 3 var a = document.createElement('a'); |
| 4 | 4 |
| 5 debug("Basic test"); | 5 debug("Basic test"); |
| 6 a.href = "https://www.mydomain.com:8080/path/"; | 6 a.href = "https://www.mydomain.com:8080/path/"; |
| 7 a.hostname = "www.otherdomain.com"; | 7 a.hostname = "www.otherdomain.com"; |
| 8 shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'"); | 8 shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'"); |
| 9 | 9 |
| 10 // IE8 throws an exception "The URL is invalid". | 10 // IE8 throws an exception "The URL is invalid". |
| 11 try { | 11 try { |
| 12 debug("Extra slashes before hostname"); | 12 debug("Extra slashes before hostname"); |
| 13 a.href = "https://www.mydomain.com:8080/path/"; | 13 a.href = "https://www.mydomain.com:8080/path/"; |
| 14 a.hostname = "//www.otherdomain.com"; | 14 a.hostname = "//www.otherdomain.com"; |
| 15 shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'"); | 15 shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'"); |
| 16 } catch(e) { | 16 } catch(e) { |
| 17 debug("Exception: " + e.description); | 17 debug("Exception: " + e.description); |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Firefox 3.5.2 does not allow setting the host to foo: protocol | 20 // Firefox 3.5.2 does not allow setting the host to foo: protocol |
| 21 debug("Set hostname to URL with foo: protocol"); | 21 debug("Set hostname to URL with foo: protocol"); |
| 22 a.href = "foo://www.mydomain.com/path/"; | 22 a.href = "foo://www.mydomain.com/path/"; |
| 23 a.hostname = "www.otherdomain.com"; | 23 a.hostname = "www.otherdomain.com"; |
| 24 shouldBe("a.href", "'foo://www.otherdomain.com/path/'"); | 24 shouldBe("a.href", "'foo://www.otherdomain.com/path/'"); |
| 25 | 25 |
| 26 // IE8 converts null to "null", which is not the right thing to do. | |
| 27 // Firefox 3.5.2 allows setting the hostname to null, which is wrong per | |
| 28 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . | |
| 29 debug("Set hostname to null"); | 26 debug("Set hostname to null"); |
| 30 a.href = "https://www.mydomain.com:8080/path/"; | 27 a.href = "https://www.mydomain.com:8080/path/"; |
| 31 a.hostname = null; | 28 a.hostname = null; |
| 32 shouldBe("a.href", "'https://www.mydomain.com:8080/path/'"); | 29 shouldBe("a.href", "'https://null:8080/path/'"); |
| 33 | 30 |
| 34 // Both IE8 and Firefox 3.5.2 allow setting the host to empty string, against th
e spec at | 31 // Both IE8 and Firefox 3.5.2 allow setting the host to empty string, against th
e spec at |
| 35 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . | 32 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . |
| 36 // Since both do that in a buggy way, WebKit should not follow either one of the
m. | 33 // Since both do that in a buggy way, WebKit should not follow either one of the
m. |
| 37 debug("Set hostname to empty string"); | 34 debug("Set hostname to empty string"); |
| 38 a.href = "https://www.mydomain.com:8080/path/"; | 35 a.href = "https://www.mydomain.com:8080/path/"; |
| 39 a.hostname = ""; | 36 a.hostname = ""; |
| 40 shouldBe("a.href", "'https://www.mydomain.com:8080/path/'"); | 37 shouldBe("a.href", "'https://www.mydomain.com:8080/path/'"); |
| 41 | 38 |
| 42 // IE8 fails to process really: protocol. | 39 // IE8 fails to process really: protocol. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 61 a.hostname= "a"; | 58 a.hostname= "a"; |
| 62 shouldBe("a.href", "'c:/path/testurl.html'"); | 59 shouldBe("a.href", "'c:/path/testurl.html'"); |
| 63 } catch(e) { | 60 } catch(e) { |
| 64 debug("Exception: " + e.description); | 61 debug("Exception: " + e.description); |
| 65 } | 62 } |
| 66 | 63 |
| 67 debug("Set hostname to undefined"); | 64 debug("Set hostname to undefined"); |
| 68 a.href = "https://www.mydomain.com:8080/path/"; | 65 a.href = "https://www.mydomain.com:8080/path/"; |
| 69 a.hostname = undefined; | 66 a.hostname = undefined; |
| 70 shouldBe("a.href", "'https://undefined:8080/path/'"); | 67 shouldBe("a.href", "'https://undefined:8080/path/'"); |
| OLD | NEW |