| 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-protocol.js"></script> | 7 <script> |
| 8 description('Test setting the protocol attribute of the URL in HTMLAnchorElement
.'); |
| 9 |
| 10 var a = document.createElement('a'); |
| 11 |
| 12 debug("Basic test"); |
| 13 a.href = "https://www.mydomain.com/path/"; |
| 14 a.protocol = "http-foo"; |
| 15 shouldBe("a.href", "'http-foo://www.mydomain.com/path/'"); |
| 16 |
| 17 // IE8 throws "Invalid argument" exception. |
| 18 debug("Set a protocol that contains ':'"); |
| 19 try { |
| 20 a.href = "https://www.mydomain.com/path/"; |
| 21 a.protocol = "http:foo"; |
| 22 shouldBe("a.href", "'http://www.mydomain.com/path/'"); |
| 23 } catch(e) { |
| 24 debug("Exception: " + e.description); |
| 25 } |
| 26 |
| 27 // IE8 throws "Invalid argument" exception. |
| 28 debug("Set a protocol that contains invalid characters"); |
| 29 try { |
| 30 a.href = "https://www.mydomain.com/path/"; |
| 31 a.protocol = "http^foo"; |
| 32 shouldBe("a.href", "'https://www.mydomain.com/path/'"); |
| 33 } catch(e) { |
| 34 debug("Exception: " + e.description); |
| 35 } |
| 36 |
| 37 // The expected behavior should change when the character table is updated. |
| 38 // IE8 encodes '^' in the host. |
| 39 debug("Set a protocol to a URL with invalid host name"); |
| 40 a.href = "h:^^"; |
| 41 a.protocol = "foo"; |
| 42 shouldBe("a.href", "'foo:^^'"); |
| 43 |
| 44 // IE8 throws "Invalid argument" exception. |
| 45 try { |
| 46 debug("Set a protocol that starts with ':'"); |
| 47 a.href = "https://www.mydomain.com/path/"; |
| 48 a.protocol = ":http"; |
| 49 shouldBe("a.href", "'https://www.mydomain.com/path/'"); |
| 50 } catch(e) { |
| 51 debug("Exception: " + e.description); |
| 52 } |
| 53 |
| 54 debug("Set protocol to null"); |
| 55 a.href = "https://www.mydomain.com/path/"; |
| 56 a.protocol = null; |
| 57 shouldBe("a.href", "'null://www.mydomain.com/path/'"); |
| 58 |
| 59 // IE8 throws "Invalid argument" exception. |
| 60 try { |
| 61 debug("Set protocol to empty string"); |
| 62 a.href = "https://www.mydomain.com/path/"; |
| 63 a.protocol = ""; |
| 64 shouldBe("a.href", "'https://www.mydomain.com/path/'"); |
| 65 } catch(e) { |
| 66 debug("Exception: " + e.description); |
| 67 } |
| 68 |
| 69 // Firefox 4 adds three slashes, unlike Safari and Chrome |
| 70 debug("Set protocol to http on malformed URL"); |
| 71 a.href = "foo:??bar"; |
| 72 a.protocol = "http"; |
| 73 shouldBe("a.href", "'http:/??bar'"); |
| 74 |
| 75 // IE8 keeps the protocol if it is 'c:'. |
| 76 debug("Set protocol to a URL which points to a local file"); |
| 77 a.href = "c:\path"; |
| 78 a.protocol = "f-oo"; |
| 79 shouldBe("a.href", "'f-oo:path'"); |
| 80 |
| 81 debug("Set protocol to undefined"); |
| 82 a.href = "https://www.mydomain.com/path/"; |
| 83 a.protocol = undefined; |
| 84 shouldBe("a.href", "'undefined://www.mydomain.com/path/'"); |
| 85 </script> |
| 8 </body> | 86 </body> |
| 9 </html> | 87 </html> |
| OLD | NEW |