| OLD | NEW |
| 1 description('Test setting the hash attribute of the URL in HTMLAnchorElement.'); | 1 description('Test setting the hash attribute of the URL in HTMLAnchorElement.'); |
| 2 | 2 |
| 3 var a = document.createElement('a'); | 3 var a = document.createElement('a'); |
| 4 | 4 |
| 5 debug("Hash value does not start with '#'"); | 5 debug("Hash value does not start with '#'"); |
| 6 a.href = "https://www.mydomain.com:8080/path/testurl.html#middle"; | 6 a.href = "https://www.mydomain.com:8080/path/testurl.html#middle"; |
| 7 a.hash = "hash-value"; | 7 a.hash = "hash-value"; |
| 8 shouldBe("a.href", "'https://www.mydomain.com:8080/path/testurl.html#hash-value'
"); | 8 shouldBe("a.href", "'https://www.mydomain.com:8080/path/testurl.html#hash-value'
"); |
| 9 | 9 |
| 10 debug("Hash value starts with '#'"); | 10 debug("Hash value starts with '#'"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 a.href = "https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle"; | 23 a.href = "https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle"; |
| 24 a.hash = "#hash#value"; | 24 a.hash = "#hash#value"; |
| 25 shouldBe("a.href", "'https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle'
"); | 25 shouldBe("a.href", "'https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle'
"); |
| 26 | 26 |
| 27 debug("Set hash to null"); | 27 debug("Set hash to null"); |
| 28 a.href = "https://www.mydomain.com/path/testurl.html#middle"; | 28 a.href = "https://www.mydomain.com/path/testurl.html#middle"; |
| 29 a.hash = null; | 29 a.hash = null; |
| 30 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#null'"); | 30 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#null'"); |
| 31 | 31 |
| 32 // Firefox 3.5.2 removes the '#' at the end, and it should per | 32 // Firefox 3.5.2 removes the '#' at the end, and it should per |
| 33 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . | 33 // http://url.spec.whatwg.org/#dom-url-hash |
| 34 debug("Set hash to empty string"); | 34 debug("Set hash to empty string"); |
| 35 a.href = "https://www.mydomain.com/path/testurl.html#middle"; | 35 a.href = "https://www.mydomain.com/path/testurl.html#middle"; |
| 36 a.hash = ""; | 36 a.hash = ""; |
| 37 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'"); | 37 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html'"); |
| 38 | 38 |
| 39 // Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should. | 39 // Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should. |
| 40 debug("Add hash to mailto: protocol"); | 40 debug("Add hash to mailto: protocol"); |
| 41 a.href = "mailto:e-mail_address@goes_here"; | 41 a.href = "mailto:e-mail_address@goes_here"; |
| 42 a.hash = "hash-value"; | 42 a.hash = "hash-value"; |
| 43 shouldBe("a.href", "'mailto:e-mail_address@goes_here#hash-value'"); | 43 shouldBe("a.href", "'mailto:e-mail_address@goes_here#hash-value'"); |
| 44 | 44 |
| 45 // IE8 does not percent-encode spaces in the hash component, but it does that | 45 // IE8 does not percent-encode spaces in the hash component, but it does that |
| 46 // in the path component. | 46 // in the path component. |
| 47 debug("Add hash to file: protocol"); | 47 debug("Add hash to file: protocol"); |
| 48 a.href = "file:///some path"; | 48 a.href = "file:///some path"; |
| 49 a.hash = "hash value"; | 49 a.hash = "hash value"; |
| 50 shouldBe("a.href", "'file:///some%20path#hash value'"); | 50 shouldBe("a.href", "'file:///some%20path#hash value'"); |
| 51 | 51 |
| 52 debug("Set hash to '#'"); | 52 debug("Set hash to '#'"); |
| 53 a.href = "http://mydomain.com#middle"; | 53 a.href = "http://mydomain.com#middle"; |
| 54 a.hash = "#"; | 54 a.hash = "#"; |
| 55 shouldBe("a.href", "'http://mydomain.com/#'"); | 55 shouldBe("a.href", "'http://mydomain.com/'"); |
| 56 | 56 |
| 57 // Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should. | 57 // Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should. |
| 58 debug("Add hash to non-standard protocol"); | 58 debug("Add hash to non-standard protocol"); |
| 59 try { | 59 try { |
| 60 a.href = "foo:bar"; | 60 a.href = "foo:bar"; |
| 61 a.hash = "#hash"; | 61 a.hash = "#hash"; |
| 62 shouldBe("a.href", "'foo:bar#hash'"); | 62 shouldBe("a.href", "'foo:bar#hash'"); |
| 63 } catch(e) { | 63 } catch(e) { |
| 64 debug("Exception: " + e.description); | 64 debug("Exception: " + e.description); |
| 65 } | 65 } |
| OLD | NEW |