| <!DOCTYPE HTML> |
| <link rel="help" href="http://url.spec.whatwg.org/#dom-url-password"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| |
| test(function() { |
| var url = new URL('http://www.domain.com/'); |
| assert_equals(url.password, ''); |
| |
| url = new URL('http://user:pass@www.domain.com/'); |
| assert_equals(url.password, 'pass'); |
| |
| url.password = 'changed'; |
| assert_equals(url.toString(), 'http://user:changed@www.domain.com/'); |
| |
| url.password = ''; |
| assert_equals(url.toString(), 'http://user@www.domain.com/'); |
| }, 'password property'); |
| |
| test(function() { |
| var url = new URL('about:test'); |
| assert_equals(url.password, ''); |
| |
| url.password = 'pass'; |
| assert_equals(url.password, ''); |
| assert_equals(url.toString(), 'about:test'); |
| }, 'password property on non relative URL'); |
| |
| test(function() { |
| var url = new URL('http://www.domain.com/'); |
| url.href = 'invalid'; |
| assert_equals(url.password, ''); |
| |
| url.password = 'pass'; |
| assert_equals(url.password, ''); |
| assert_equals(url.href, 'invalid'); |
| }, 'password property invalid URL'); |
| |
| </script> |