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