tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / dom / HTMLAnchorElement / script-tests / set-href-attribute-port.js
1 description('Test setting the port attribute of the URL in HTMLAnchorElement.');
2
3 var a = document.createElement('a');
4
5 debug("Default port as number");
6 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
7 a.port = 443;
8 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
9
10 debug("Default port as string");
11 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
12 a.port = "443";
13 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
14
15 debug("Set port to 0");
16 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
17 a.port = "0";
18 shouldBe("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.
21 debug("Set port to non-number");
22 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
23 a.port = "4a";
24 shouldBe("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.
27 debug("Set port to null");
28 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
29 a.port = null;
30 shouldBe("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.
33 debug("Set port to empty string");
34 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
35 a.port = "";
36 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
37
38 debug("Set port to undefined");
39 a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
40 a.port = undefined;
41 shouldBe("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: .
44 debug("Set port to URL with foo: protocol");
45 a.href = "foo://bar/";
46 a.port = 50;
47 shouldBe("a.href", "'foo://bar:50/'");