2009-12-07 Kent Tamura <tkent@chromium.org>
[WebKit-https.git] / LayoutTests / fast / forms / script-tests / ValidityState-typeMismatch-url.js
index 2efd2b6acac60836713d220b11fe6689324ee175..040cd4f8a5f6b2249adc72d70f3ba8c3228ded6a 100644 (file)
@@ -11,36 +11,70 @@ function check(value, mismatchExpected) {
         testFailed(resultText);
 }
 
+function expectValid(value) {
+    check(value, false);
+}
+
+function expectInvalid(value) {
+    check(value, true);
+}
+
 var i = document.createElement('input');
 i.type = 'url';
 
 // Valid values
-check('http://www.google.com', false);
-check('http://localhost', false);
-check('http://127.0.0.1', false);
-check('http://a', false);
-check('http://www.google.com/search?rls=en&q=WebKit&ie=UTF-8&oe=UTF-8', false);
-check('ftp://ftp.myhost.com', false);
-check('ssh://ssh.myhost.com', false);
-check('somescheme://ssh.myhost.com', false);
-check('http://a/\\\/\'\'*<>/', false);
-check('http://a/dfs/\kds@sds', false);
-check('http://a.a:1/search?a&b', false);
+expectValid('http://www.google.com');
+expectValid('http://foo:bar@www.google.com:80');
+expectValid('http://localhost');
+expectValid('http://127.0.0.1');
+expectValid('http://[0000:0000:0000:0000:0000:0000:7f00:0001]/');
+expectValid('http://[0000:0000:0000:0000:0000:0000:127.0.0.1]/');
+expectValid('http://[::7f00:0001]/');
+expectValid('http://[1::2:3]/');
+expectValid('http://[0000:0::ffff:10.0.0.1]/');
+expectValid('http://a');
+expectValid('http://www.google.com/search?rls=en&q=WebKit&ie=UTF-8&oe=UTF-8');
+expectValid('ftp://ftp.myhost.com');
+expectValid('ssh://ssh.myhost.com');
+expectValid('mailto:tkent@chromium.org');
+expectValid('mailto:tkent@chromium.org?body=hello');
+expectValid('file:///Users/tkent/.zshrc');
+expectValid('file:///C:/human.sys');
+expectValid('tel:+1-800-12345;ext=9999');
+expectValid('tel:03(1234)5678');
+expectValid('somescheme://ssh.myhost.com');
+expectValid('http://a/\\\/\'\'*<>/');
+expectValid('http://a/dfs/\kds@sds');
+expectValid('http://a.a:1/search?a&b');
+expectValid('http://www.google.com/#top');
+expectValid('http://\u30C6\u30B9\u30C8\u3002jp/\u30D1\u30B9?\u540D\u524D=\u5024');
 
 // Invalid values
-check('www.google.com', true);
-check('127.0.0.1', true);
-check('.com', true);
-check('http://www.g**gle.com', true);
-check('http://www.google.com:aaaa', true);
-check('http:// www.google.com', true);
-check('http://www .google.com', true);
-check('http://www.&#10;google.&#13;com', true);
-check('://', true);
-check('/http://www.google.com', true);
-check('----ftp://a', true);
-check('scheme//a', true);
-check('http://host+', true);
-check('http://myurl!', true);
+expectInvalid('www.google.com');
+expectInvalid('127.0.0.1');
+expectInvalid('.com');
+expectInvalid('http://www.google.com:aaaa');
+expectInvalid('://');
+expectInvalid('/http://www.google.com');
+expectInvalid('----ftp://a');
+expectInvalid('scheme//a');
+expectInvalid('http://[v8.:::]/');
+
+// KURL's host name restriction is stricter than RFC 3986. KURLGoogle is not.
+i.value = 'http://www.g**gle.com'
+var strictHost = i.validity.typeMismatch;
+if (strictHost) {
+    expectInvalid('http:// www.google.com');
+    expectInvalid('http://www .google.com');
+    expectInvalid('http://www.&#10;google.&#13;com');
+    expectInvalid('http://host+');
+    expectInvalid('http://myurl!');
+} else {
+    expectValid('http:// www.google.com');
+    expectValid('http://www .google.com');
+    expectValid('http://www.&#10;google.&#13;com');
+    expectValid('http://host+');
+    expectValid('http://myurl!');
+}
 
 var successfullyParsed = true;