Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js

Issue 26506003: Setting host without port should keep old port (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: git rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 description('Test setting the host attribute of the URL in HTMLAnchorElement.'); 1 description('Test setting the host attribute of the URL in HTMLAnchorElement.');
2 2
3 var a = document.createElement('a'); 3 var a = document.createElement('a');
4 4
5 debug("Basic test"); 5 debug("Basic test");
6 a.href = "https://www.mydomain.com:8080/path/"; 6 a.href = "https://www.mydomain.com:8080/path/";
7 a.host = "www.otherdomain.com:0"; 7 a.host = "www.otherdomain.com:0";
8 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'"); 8 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
9 9
10 debug("Set host without port");
11 a.href = "https://www.mydomain.com:8080/path/";
12 a.host = "www.otherdomain.com";
13 shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
14
10 // IE8 throws "The URL is invalid" exception. 15 // IE8 throws "The URL is invalid" exception.
11 debug("Set host with '?' in it"); 16 debug("Set host with '?' in it");
12 try { 17 try {
13 a.href = "https://www.mydomain.com:8080/path/?key=value"; 18 a.href = "https://www.mydomain.com:8080/path/?key=value";
14 a.host = "www.other?domain.com:8080"; 19 a.host = "www.other?domain.com:8080";
15 shouldBe("a.href", "'https://www.other/?domain.com:8080/path/?key=value'"); 20 shouldBe("a.href", "'https://www.other/?domain.com:8080/path/?key=value'");
16 } catch(e) { 21 } catch(e) {
17 debug("Exception: " + e.description); 22 debug("Exception: " + e.description);
18 } 23 }
19 24
20 debug("Set default port for another protocol"); 25 debug("Set default port for another protocol");
21 a.href = "https://www.mydomain.com:8080/path/"; 26 a.href = "https://www.mydomain.com:8080/path/";
22 a.host = "www.otherdomain.com:80"; 27 a.host = "www.otherdomain.com:80";
23 shouldBe("a.href", "'https://www.otherdomain.com:80/path/'"); 28 shouldBe("a.href", "'https://www.otherdomain.com:80/path/'");
24 29
25 debug("Set default port"); 30 debug("Set default port");
26 a.href = "https://www.mydomain.com:8080/path/"; 31 a.href = "https://www.mydomain.com:8080/path/";
27 a.host = "www.otherdomain.com:443"; 32 a.host = "www.otherdomain.com:443";
28 shouldBe("a.href", "'https://www.otherdomain.com/path/'"); 33 shouldBe("a.href", "'https://www.otherdomain.com/path/'");
29 34
35 debug("Set host with invalid port");
36 a.href = "https://www.mydomain.com:8080/path/";
37 a.host = "www.otherdomain.com:invalid";
38 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
39
30 // Firefox 3.5.2 rejects a port that contains non-digits. 40 // Firefox 3.5.2 rejects a port that contains non-digits.
31 debug("Set host with letters in port number"); 41 debug("Set host with letters in port number");
32 a.href = "https://www.mydomain.com:8080/path/"; 42 a.href = "https://www.mydomain.com:8080/path/";
33 a.host = "www.otherdomain.com:44a5"; 43 a.host = "www.otherdomain.com:44a5";
34 shouldBe("a.href", "'https://www.otherdomain.com:44/path/'"); 44 shouldBe("a.href", "'https://www.otherdomain.com:44/path/'");
35 45
36 // Firefox 3.5.2 ignores the leading space in the port, but errs on reparsing th e port. 46 // Firefox 3.5.2 ignores the leading space in the port, but errs on reparsing th e port.
37 debug("Leading space in port number"); 47 debug("Leading space in port number");
38 a.href = "https://www.mydomain.com:8080/path/"; 48 a.href = "https://www.mydomain.com:8080/path/";
39 a.host = "www.otherdomain.com: 443"; 49 a.host = "www.otherdomain.com: 443";
(...skipping 22 matching lines...) Expand all
62 debug("Set host to URL with file: protocol"); 72 debug("Set host to URL with file: protocol");
63 a.href = "file:///path/"; 73 a.href = "file:///path/";
64 a.host = "mydomain.com"; 74 a.host = "mydomain.com";
65 shouldBe("a.href", "'file://mydomain.com/path/'"); 75 shouldBe("a.href", "'file://mydomain.com/path/'");
66 76
67 // IE8 throws if the host contains '/' 77 // IE8 throws if the host contains '/'
68 debug("Set host containing slashes in it"); 78 debug("Set host containing slashes in it");
69 try { 79 try {
70 a.href = "https://www.mydomain.com:8080/path/"; 80 a.href = "https://www.mydomain.com:8080/path/";
71 a.host = "www.other\dom/ain.com"; 81 a.host = "www.other\dom/ain.com";
72 shouldBe("a.href", "'https://www.otherdom/ain.com/path/'"); 82 shouldBe("a.href", "'https://www.otherdom%2Fain.com:8080/path/'");
73 } catch(e) { 83 } catch(e) {
74 debug("Exception: " + e.description); 84 debug("Exception: " + e.description);
75 } 85 }
76 86
77 // WebKit fails to strip the \r in the authority, and therefore treats the URL a s invalid 87 // WebKit fails to strip the \r in the authority, and therefore treats the URL a s invalid
78 // and gets a different result than Firefox or Chrome; we should probably strip it 88 // and gets a different result than Firefox or Chrome; we should probably strip it
79 debug("Set host to a malformed URL"); 89 debug("Set host to a malformed URL");
80 a.href = "https:/\rww.my@domain.com:8080/path/"; 90 a.href = "https:/\rww.my@domain.com:8080/path/";
81 a.host = "www.other!domain.com:15"; 91 a.host = "www.other!domain.com:15";
82 shouldBe("a.href", "'https:/\\rww.my@domain.com:8080/path/'"); 92 shouldBe("a.href", "'https:/\\rww.my@domain.com:8080/path/'");
(...skipping 19 matching lines...) Expand all
102 } catch(e) { 112 } catch(e) {
103 debug("Exception: " + e.description); 113 debug("Exception: " + e.description);
104 } 114 }
105 115
106 // Both IE8 and Firefox append the hosts, instead of rejecting, per 116 // Both IE8 and Firefox append the hosts, instead of rejecting, per
107 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib utes . 117 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attrib utes .
108 debug("Set host to a URL with tel: protocol"); 118 debug("Set host to a URL with tel: protocol");
109 a.href = "tel:+1-816-555-1212"; 119 a.href = "tel:+1-816-555-1212";
110 a.host = "+1-800-555-1212"; 120 a.host = "+1-800-555-1212";
111 shouldBe("a.href", "'tel:+1-816-555-1212'"); 121 shouldBe("a.href", "'tel:+1-816-555-1212'");
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698