Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / domurl / url-hash.html
blob76442c960e2fef75772885aa57b14f484fa87d73
1 <!DOCTYPE HTML>
2 <link rel="help" href="http://url.spec.whatwg.org/#dom-url-hash">
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
7 test(function() {
8 var url = new URL('http://www.domain.com/');
9 assert_equals(url.hash, '');
11 url = new URL('http://www.domain.com/#');
12 assert_equals(url.hash, '');
14 url = new URL('http://www.domain.com/#a');
15 assert_equals(url.hash, '#a');
17 url.hash = '';
18 assert_equals(url.hash, '');
19 assert_equals(url.toString(), 'http://www.domain.com/');
21 url.hash = '#';
22 assert_equals(url.hash, '');
23 assert_equals(url.toString(), 'http://www.domain.com/');
25 url.hash = 'a';
26 assert_equals(url.hash, '#a');
28 url.hash = '#a';
29 assert_equals(url.hash, '#a');
31 url.hash = 'a#b';
32 assert_equals(url.hash, '#a#b');
33 }, 'Basic hash');
35 test(function() {
36 var url = new URL('mailto:foo@bar.com');
37 assert_equals(url.hash, '');
39 url.hash = 'a';
40 assert_equals(url.hash, '');
41 }, 'non hierarchical');
43 test(function() {
44 var url = new URL('http://abc.de:8080/path/file?query#fragment');
45 url.href = 'invalid';
46 assert_equals(url.hash, '');
48 url.hash = 'changed';
49 assert_equals(url.hash, '');
50 assert_equals(url.href, 'invalid');
51 }, 'hash property invalid URL');
53 test(function() {
54 var url = new URL('http://www.domain.com/');
55 assert_equals(url.hash, '');
57 url.hash = '\udc01\ud802a';
58 assert_equals(url.hash, '#\ufffd\ufffda');
59 }, 'hash with unmatched surrogates');
61 </script>