2010-04-14 Adam Barth <abarth@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Apr 2010 17:06:35 +0000 (17:06 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Apr 2010 17:06:35 +0000 (17:06 +0000)
        Reviewed by Darin Fisher.

        Add LayoutTests for parsing standard URLs
        https://bugs.webkit.org/show_bug.cgi?id=37580

        * fast/url/script-tests/standard-url.js: Added.
        * fast/url/standard-url-expected.txt: Added.
        * fast/url/standard-url.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@57585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/url/script-tests/standard-url.js [new file with mode: 0644]
LayoutTests/fast/url/standard-url-expected.txt [new file with mode: 0644]
LayoutTests/fast/url/standard-url.html [new file with mode: 0644]

index 2e69ed6..8a305a3 100644 (file)
@@ -1,3 +1,14 @@
+2010-04-14  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Darin Fisher.
+
+        Add LayoutTests for parsing standard URLs
+        https://bugs.webkit.org/show_bug.cgi?id=37580
+
+        * fast/url/script-tests/standard-url.js: Added.
+        * fast/url/standard-url-expected.txt: Added.
+        * fast/url/standard-url.html: Added.
+
 2010-04-14  Adam Roben  <aroben@apple.com>
 
         Roll out r57566
diff --git a/LayoutTests/fast/url/script-tests/standard-url.js b/LayoutTests/fast/url/script-tests/standard-url.js
new file mode 100644 (file)
index 0000000..e137520
--- /dev/null
@@ -0,0 +1,46 @@
+description("Canonicalization of standard URLs");
+
+cases = [ 
+  ["http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#"],
+  ["http://[www.google.com]/", "http://[www.google.com]/"],
+  ["ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#"],
+  ["http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo"],
+  // Disabled because this gets treated as a relative URL.
+  // ["www.google.com", ":www.google.com/"],
+  ["http://192.0x00A80001", "http://192.168.0.1/"],
+  ["http://www/foo%2Ehtml", "http://www/foo.html"],
+  ["http://user:pass@/", "http://user:pass@/"],
+  ["http://%25DOMAIN:foobar@foodomain.com/", "http://%25DOMAIN:foobar@foodomain.com/"],
+  // Backslashes should get converted to forward slashes.
+  ["http:\\\\\\\\www.google.com\\\\foo", "http://www.google.com/foo"],
+  // Busted refs shouldn't make the whole thing fail.
+  ["http://www.google.com/asdf#\xc2", "http://www.google.com/asdf#\xef\xbf\xbd"],
+  // Basic port tests.
+  ["http://foo:80/", "http://foo/"],
+  ["http://foo:81/", "http://foo:81/"],
+  ["httpa://foo:80/", "httpa://foo:80/"],
+  ["http://foo:-80/", "http://foo:-80/"],
+  ["https://foo:443/", "https://foo/"],
+  ["https://foo:80/", "https://foo:80/"],
+  ["ftp://foo:21/", "ftp://foo/"],
+  ["ftp://foo:80/", "ftp://foo:80/"],
+  ["gopher://foo:70/", "gopher://foo/"],
+  ["gopher://foo:443/", "gopher://foo:443/"],
+  ["ws://foo:80/", "ws://foo/"],
+  ["ws://foo:81/", "ws://foo:81/"],
+  ["ws://foo:443/", "ws://foo:443/"],
+  ["ws://foo:815/", "ws://foo:815/"],
+  ["wss://foo:80/", "wss://foo:80/"],
+  ["wss://foo:81/", "wss://foo:81/"],
+  ["wss://foo:443/", "wss://foo/"],
+  ["wss://foo:815/", "wss://foo:815/"],
+];
+
+for (var i = 0; i < cases.length; ++i) {
+  test_vector = cases[i][0];
+  expected_result = cases[i][1];
+  shouldBe("canonicalize('" + test_vector + "')",
+           "'" + expected_result + "'");
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/url/standard-url-expected.txt b/LayoutTests/fast/url/standard-url-expected.txt
new file mode 100644 (file)
index 0000000..d8bae81
--- /dev/null
@@ -0,0 +1,37 @@
+Canonicalization of standard URLs
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS canonicalize('http://www.google.com/foo?bar=baz#') is 'http://www.google.com/foo?bar=baz#'
+PASS canonicalize('http://[www.google.com]/') is 'http://[www.google.com]/'
+FAIL canonicalize('ht  tp:@www.google.com:80/;p?#') should be ht%09tp://www.google.com:80/;p?#. Was http:@www.google.com:80/;p?#.
+FAIL canonicalize('http:////////user:@google.com:99?foo') should be http://user@google.com:99/?foo. Was http://////user:@google.com:99?foo.
+FAIL canonicalize('http://192.0x00A80001') should be http://192.168.0.1/. Was http://192.0x00A80001/.
+FAIL canonicalize('http://www/foo%2Ehtml') should be http://www/foo.html. Was http://www/foo%2Ehtml.
+PASS canonicalize('http://user:pass@/') is 'http://user:pass@/'
+PASS canonicalize('http://%25DOMAIN:foobar@foodomain.com/') is 'http://%25DOMAIN:foobar@foodomain.com/'
+PASS canonicalize('http:\\\\www.google.com\\foo') is 'http://www.google.com/foo'
+FAIL canonicalize('http://www.google.com/asdf#Â') should be http://www.google.com/asdf#�. Was http://www.google.com/asdf#%C2.
+FAIL canonicalize('http://foo:80/') should be http://foo/. Was http://foo:80/.
+PASS canonicalize('http://foo:81/') is 'http://foo:81/'
+PASS canonicalize('httpa://foo:80/') is 'httpa://foo:80/'
+PASS canonicalize('http://foo:-80/') is 'http://foo:-80/'
+FAIL canonicalize('https://foo:443/') should be https://foo/. Was https://foo:443/.
+PASS canonicalize('https://foo:80/') is 'https://foo:80/'
+FAIL canonicalize('ftp://foo:21/') should be ftp://foo/. Was ftp://foo:21/.
+PASS canonicalize('ftp://foo:80/') is 'ftp://foo:80/'
+FAIL canonicalize('gopher://foo:70/') should be gopher://foo/. Was gopher://foo:70/.
+PASS canonicalize('gopher://foo:443/') is 'gopher://foo:443/'
+FAIL canonicalize('ws://foo:80/') should be ws://foo/. Was ws://foo:80/.
+PASS canonicalize('ws://foo:81/') is 'ws://foo:81/'
+PASS canonicalize('ws://foo:443/') is 'ws://foo:443/'
+PASS canonicalize('ws://foo:815/') is 'ws://foo:815/'
+PASS canonicalize('wss://foo:80/') is 'wss://foo:80/'
+PASS canonicalize('wss://foo:81/') is 'wss://foo:81/'
+FAIL canonicalize('wss://foo:443/') should be wss://foo/. Was wss://foo:443/.
+PASS canonicalize('wss://foo:815/') is 'wss://foo:815/'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/url/standard-url.html b/LayoutTests/fast/url/standard-url.html
new file mode 100644 (file)
index 0000000..6f1b1d4
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<script src="resources/utilities.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/standard-url.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>