| Index: LayoutTests/fast/domurl/url-host.html
|
| diff --git a/LayoutTests/fast/domurl/url-host.html b/LayoutTests/fast/domurl/url-host.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fe68d4f62b807ab7d1e1c93bf5cebc0bd205f960
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/domurl/url-host.html
|
| @@ -0,0 +1,110 @@
|
| +<!DOCTYPE HTML>
|
| +<link rel="help" href="http://url.spec.whatwg.org/#dom-url-host">
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| +<script>
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + assert_equals(url.host, 'www.mydomain.com:8080');
|
| + url.host = 'www.otherdomain.com:0';
|
| + assert_equals(url.href, 'https://www.otherdomain.com:0/path/');
|
| +}, 'Basic test');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/?key=value');
|
| + url.host = 'www.other?domain.com:8080';
|
| + assert_equals(url.href, 'https://www.other%3Fdomain.com:8080/path/?key=value');
|
| +}, 'Set host with ? in it');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.otherdomain.com:80';
|
| + assert_equals(url.href, 'https://www.otherdomain.com:80/path/');
|
| +}, 'Set default port for another protocol');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.otherdomain.com:443';
|
| + assert_equals(url.href, 'https://www.otherdomain.com/path/');
|
| +}, 'Set default port');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.otherdomain.com:44a5';
|
| + assert_equals(url.href, 'https://www.otherdomain.com:44/path/');
|
| +}, 'Set host with letters in port number');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.otherdomain.com: 443';
|
| + assert_equals(url.href, 'https://www.otherdomain.com:0/path/');
|
| +}, 'Leading space in port number');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.otherdomain.com:';
|
| + assert_equals(url.href, 'https://www.otherdomain.com:0/path/');
|
| +}, 'Colon without port number');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = null;
|
| + assert_equals(url.href, 'https://null:8080/path/');
|
| +}, 'Set host to null');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = '';
|
| + assert_equals(url.href, 'https://www.mydomain.com:8080/path/');
|
| +}, 'Set host to empty string');
|
| +
|
| +test(function() {
|
| + var url = new URL('file:///path/');
|
| + assert_equals(url.host, '');
|
| + url.host = 'mydomain.com';
|
| + assert_equals(url.href, 'file://mydomain.com/path/');
|
| +}, 'Set host to URL with file: protocol');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://www.mydomain.com:8080/path/');
|
| + url.host = 'www.other\\dom/ain.com';
|
| + assert_equals(url.href, 'https://www.other%5Cdom%2Fain.com:8080/path/');
|
| +}, 'Set host containing slashes in it');
|
| +
|
| +test(function() {
|
| + var url = new URL('https:/\rww.my@domain.com:8080/path/');
|
| + assert_equals(url.host, 'domain.com:8080');
|
| + url.host = 'www.other!domain.com:15';
|
| + assert_equals(url.href, 'https://ww.my@www.other%21domain.com:15/path/');
|
| +}, 'Set host to a malformed URL');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://domain.com:8080/path/');
|
| + url.host = ':www.otherdomain.com:15';
|
| + assert_equals(url.href, 'https://domain.com:8080/path/');
|
| +}, 'Set host that starts with :');
|
| +
|
| +test(function() {
|
| + var url = new URL('https://rwwmy@domain.com:8080/purl..th/');
|
| + url.host = 'www.other!domain.com:25';
|
| + assert_equals(url.href, 'https://rwwmy@www.other%21domain.com:25/purl..th/');
|
| +}, 'Set host to URL containing username and ..');
|
| +
|
| +test(function() {
|
| + var url = new URL('tel:+1-816-555-1212');
|
| + assert_equals(url.host, '');
|
| + url.host = '+1-800-555-1212';
|
| + assert_equals(url.href, 'tel:+1-816-555-1212');
|
| +}, 'Set host to a URL with tel: protocol');
|
| +
|
| +test(function() {
|
| + var url = new URL('http://abc.de/path/file?query#fragment');
|
| + url.href = 'invalid';
|
| + assert_equals(url.host, '');
|
| + url.host = 'changed';
|
| + assert_equals(url.host, '');
|
| + assert_equals(url.href, 'invalid');
|
| +}, 'host property invalid URL');
|
| +
|
| +</script>
|
|
|