| 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 '#'"); |
| 11 a.href = "file:///path/testurl.html#middle"; | 11 a.href = "file:///path/testurl.html#middle"; |
| 12 a.hash = "#hash_value"; | 12 a.hash = "#hash_value"; |
| 13 shouldBe("a.href", "'file:///path/testurl.html#hash_value'"); | 13 shouldBe("a.href", "'file:///path/testurl.html#hash_value'"); |
| 14 | 14 |
| 15 debug("'?' in hash value"); | 15 debug("'?' in hash value"); |
| 16 a.href = "http://www.mydomain.com/path/testurl.html#middle"; | 16 a.href = "http://www.mydomain.com/path/testurl.html#middle"; |
| 17 a.hash = "#hash?value"; | 17 a.hash = "#hash?value"; |
| 18 shouldBe("a.href", "'http://www.mydomain.com/path/testurl.html#hash?value'"); | 18 shouldBe("a.href", "'http://www.mydomain.com/path/testurl.html#hash?value'"); |
| 19 | 19 |
| 20 // The expected behavior should change when character table is updated. | 20 // The expected behavior should change when character table is updated. |
| 21 // IE8 and Firefox3.5.2 don't consider these characters as illegal. | 21 // IE8 and Firefox3.5.2 don't consider these characters as illegal. |
| 22 debug("'#' in hash value, and illegal characters in hostname"); | 22 debug("'#' in hash value, and illegal characters in hostname"); |
| 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 // IE8 converts null to "null", which is not the right thing to do. | |
| 28 // Firefox 3.5.2 removes the '#' at the end, and it should per | |
| 29 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . | |
| 30 debug("Set hash to null"); | 27 debug("Set hash to null"); |
| 31 a.href = "https://www.mydomain.com/path/testurl.html#middle"; | 28 a.href = "https://www.mydomain.com/path/testurl.html#middle"; |
| 32 a.hash = null; | 29 a.hash = null; |
| 33 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'"); | 30 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#null'"); |
| 34 | 31 |
| 35 // 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 |
| 36 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . | 33 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib
utes . |
| 37 debug("Set hash to empty string"); | 34 debug("Set hash to empty string"); |
| 38 a.href = "https://www.mydomain.com/path/testurl.html#middle"; | 35 a.href = "https://www.mydomain.com/path/testurl.html#middle"; |
| 39 a.hash = ""; | 36 a.hash = ""; |
| 40 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'"); | 37 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'"); |
| 41 | 38 |
| 42 // 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. |
| 43 debug("Add hash to mailto: protocol"); | 40 debug("Add hash to mailto: protocol"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 59 | 56 |
| 60 // 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. |
| 61 debug("Add hash to non-standard protocol"); | 58 debug("Add hash to non-standard protocol"); |
| 62 try { | 59 try { |
| 63 a.href = "foo:bar"; | 60 a.href = "foo:bar"; |
| 64 a.hash = "#hash"; | 61 a.hash = "#hash"; |
| 65 shouldBe("a.href", "'foo:bar#hash'"); | 62 shouldBe("a.href", "'foo:bar#hash'"); |
| 66 } catch(e) { | 63 } catch(e) { |
| 67 debug("Exception: " + e.description); | 64 debug("Exception: " + e.description); |
| 68 } | 65 } |
| OLD | NEW |