tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / ValidityState-typeMismatch-url.js
1 description("Input type=url validation test");
2
3 function check(value, mismatchExpected, disabled) {
4     i.value = value;
5     i.disabled = !!disabled;
6     var actual = i.validity.typeMismatch;
7     var didPass = actual == mismatchExpected;
8     var resultText = value + ' is ' + (didPass ? 'a correct ' : 'an incorrect ') + (actual ? 'invalid' : 'valid') + ' url' + (disabled ? ' when disabled.' : '.');
9     if (didPass)
10         testPassed(resultText);
11     else
12         testFailed(resultText);
13 }
14
15 function expectValid(value, disabled) {
16     check(value, false, disabled);
17 }
18
19 function expectInvalid(value) {
20     check(value, true);
21 }
22
23 var i = document.createElement('input');
24 i.type = 'url';
25
26 // Valid values
27 expectValid('http://www.google.com');
28 expectValid('http://foo:bar@www.google.com:80');
29 expectValid('http://localhost');
30 expectValid('http://127.0.0.1');
31 expectValid('http://[0000:0000:0000:0000:0000:0000:7f00:0001]/');
32 expectValid('http://[0000:0000:0000:0000:0000:0000:127.0.0.1]/');
33 expectValid('http://[::7f00:0001]/');
34 expectValid('http://[1::2:3]/');
35 expectValid('http://[0000:0::ffff:10.0.0.1]/');
36 expectValid('http://a');
37 expectValid('http://www.google.com/search?rls=en&q=WebKit&ie=UTF-8&oe=UTF-8');
38 expectValid('ftp://ftp.myhost.com');
39 expectValid('ssh://ssh.myhost.com');
40 expectValid('mailto:tkent@chromium.org');
41 expectValid('mailto:tkent@chromium.org?body=hello');
42 expectValid('file:///Users/tkent/.zshrc');
43 expectValid('file:///C:/human.sys');
44 expectValid('tel:+1-800-12345;ext=9999');
45 expectValid('tel:03(1234)5678');
46 expectValid('somescheme://ssh.myhost.com');
47 expectValid('http://a/\\\/\'\'*<>/');
48 expectValid('http://a/dfs/\kds@sds');
49 expectValid('http://a.a:1/search?a&b');
50 expectValid('http://www.google.com/#top');
51 expectValid('http://\u30C6\u30B9\u30C8\u3002jp/\u30D1\u30B9?\u540D\u524D=\u5024');
52
53 // Invalid values
54 expectInvalid('www.google.com');
55 expectInvalid('127.0.0.1');
56 expectInvalid('.com');
57 expectInvalid('http://www.google.com:aaaa');
58 expectInvalid('://');
59 expectInvalid('/http://www.google.com');
60 expectInvalid('----ftp://a');
61 expectInvalid('scheme//a');
62 expectInvalid('http://[v8.:::]/');
63
64 // KURL's host name restriction is stricter than RFC 3986. KURLGoogle is not.
65 i.value = 'http://www.g**gle.com'
66 var strictHost = i.validity.typeMismatch;
67 if (strictHost) {
68     expectInvalid('http:// www.google.com');
69     expectInvalid('http://www .google.com');
70     expectInvalid('http://www.&#10;google.&#13;com');
71     expectInvalid('http://host+');
72     expectInvalid('http://myurl!');
73 } else {
74     expectValid('http:// www.google.com');
75     expectValid('http://www .google.com');
76     expectValid('http://www.&#10;google.&#13;com');
77     expectValid('http://host+');
78     expectValid('http://myurl!');
79 }
80
81 // Disabled
82 expectValid('invalid', true);