| 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-port.js"></script> | 7 <script> |
| 8 description('Test setting the port attribute of the URL in HTMLAnchorElement.'); |
| 9 |
| 10 var a = document.createElement('a'); |
| 11 |
| 12 debug("Default port as number"); |
| 13 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 14 a.port = 443; |
| 15 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'"); |
| 16 |
| 17 debug("Default port as string"); |
| 18 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 19 a.port = "443"; |
| 20 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'"); |
| 21 |
| 22 debug("Set port to 0"); |
| 23 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 24 a.port = "0"; |
| 25 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'"); |
| 26 |
| 27 // Firefox 3.5.2 does not accept the port if any character is not a digit. |
| 28 debug("Set port to non-number"); |
| 29 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 30 a.port = "4a"; |
| 31 shouldBe("a.href", "'https://www.mydomain.com:4/path/testurl.html?key=value'"); |
| 32 |
| 33 // Firefox 3.5.2 does not accept the port if it is null. |
| 34 debug("Set port to null"); |
| 35 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 36 a.port = null; |
| 37 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'"); |
| 38 |
| 39 // Firefox 3.5.2 does not accept the port if it is null. |
| 40 debug("Set port to empty string"); |
| 41 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 42 a.port = ""; |
| 43 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'"); |
| 44 |
| 45 debug("Set port to undefined"); |
| 46 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value"; |
| 47 a.port = undefined; |
| 48 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'"); |
| 49 |
| 50 // Firefox 3.5.2 does not allow setting the port on a URL with protocol foo: . |
| 51 debug("Set port to URL with foo: protocol"); |
| 52 a.href = "foo://bar/"; |
| 53 a.port = 50; |
| 54 shouldBe("a.href", "'foo://bar:50/'"); |
| 55 </script> |
| 8 </body> | 56 </body> |
| 9 </html> | 57 </html> |
| OLD | NEW |