2010-05-05 Adam Barth <abarth@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 May 2010 05:23:00 +0000 (05:23 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 May 2010 05:23:00 +0000 (05:23 +0000)
        Reviewed by Alexey Proskuryakov.

        Add a test of URL segmentation from a data URL base
        https://bugs.webkit.org/show_bug.cgi?id=38606

        As requested by Alexey.  These tests find some interesting behavior in
        both KURL and GURL.  We'll need to go through them in more detail later
        to understand what the right behavior is.

        * fast/url/script-tests/segments-from-data-url.js: Added.
        * fast/url/segments-from-data-url-expected.txt: Added.
        * fast/url/segments-from-data-url.html: Added.

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

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

index 5911058..7d3feb9 100644 (file)
@@ -2,6 +2,21 @@
 
         Reviewed by Alexey Proskuryakov.
 
+        Add a test of URL segmentation from a data URL base
+        https://bugs.webkit.org/show_bug.cgi?id=38606
+
+        As requested by Alexey.  These tests find some interesting behavior in
+        both KURL and GURL.  We'll need to go through them in more detail later
+        to understand what the right behavior is.
+
+        * fast/url/script-tests/segments-from-data-url.js: Added.
+        * fast/url/segments-from-data-url-expected.txt: Added.
+        * fast/url/segments-from-data-url.html: Added.
+
+2010-05-05  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Alexey Proskuryakov.
+
         Add a test of URL segmentation
         https://bugs.webkit.org/show_bug.cgi?id=38600
 
diff --git a/LayoutTests/fast/url/script-tests/segments-from-data-url.js b/LayoutTests/fast/url/script-tests/segments-from-data-url.js
new file mode 100644 (file)
index 0000000..8fc3013
--- /dev/null
@@ -0,0 +1,83 @@
+description("Test URL segmentation");
+
+cases = [ 
+  // [URL, [SCHEME, HOST, PORT, PATH, QUERY, REF]]
+  ["http://user:pass@foo:21/bar;par?b#c",    ["http:","foo","21","/bar;par","?b","#c"]],
+  ["http:foo.com",                           ["http:","foo.com","0","/","",""]],
+  ["\\t   :foo.com   \\n",                   [":","","0","","",""]],
+  [" foo.com  ",                             [":","","0","","",""]],
+  ["a:\\t foo.com",                          ["a:","","0"," foo.com","",""]],
+  ["http://f:21/ b ? d # e ",                ["http:","f","21","/%20b%20","?%20d%20","# e"]],
+  ["http://f:/c",                            ["http:","f","0","/c","",""]],
+  ["http://f:0/c",                           ["http:","f","0","/c","",""]],
+  ["http://f:00000000000000/c",              ["http:","f","0","/c","",""]],
+  ["http://f:00000000000000000000080/c",     ["http:","f","0","/c","",""]],
+  ["http://f:b/c",                           [":","","0","","",""]],
+  ["http://f: /c",                           [":","","0","","",""]],
+  ["http://f:\\n/c",                         ["http:","f","0","/c","",""]],
+  ["http://f:fifty-two/c",                   [":","","0","","",""]],
+  ["http://f:999999/c",                      [":","","0","","",""]],
+  ["http://f: 21 / b ? d # e ",              [":","","0","","",""]],
+  ["",                                       ["data:","","0","text/plain,baseURL","",""]],
+  ["  \\t",                                  ["data:","","0","text/plain,baseURL","",""]],
+  [":foo.com/",                              [":","","0","","",""]],
+  [":foo.com\\\\",                           [":","","0","","",""]],
+  [":",                                      [":","","0","","",""]],
+  [":a",                                     [":","","0","","",""]],
+  [":/",                                     [":","","0","","",""]],
+  [":\\\\",                                  [":","","0","","",""]],
+  [":#",                                     [":","","0","","",""]],
+  ["#",                                      [":","","0","","",""]],
+  ["#/",                                     [":","","0","","",""]],
+  ["#\\\\",                                  [":","","0","","",""]],
+  ["#;?",                                    [":","","0","","",""]],
+  ["?",                                      [":","","0","","",""]],
+  ["/",                                      [":","","0","","",""]],
+  [":23",                                    [":","","0","","",""]],
+  ["/:23",                                   ["data:","","0","/:23","",""]],
+  ["//",                                     [":","","0","","",""]],
+  ["::",                                     [":","","0","","",""]],
+  ["::23",                                   [":","","0","","",""]],
+  ["foo://",                                 ["foo:","","0","//","",""]],
+  ["http://a:b@c:29/d",                      ["http:","c","29","/d","",""]],
+  ["http::@c:29",                            ["http:","c","29","/","",""]],
+  ["http://&a:foo(b]c@d:2/",                 ["http:","d","2","/","",""]],
+  ["http://::@c@d:2",                        ["http:","d","2","/","",""]],
+  ["http://foo.com:b@d/",                    ["http:","d","0","/","",""]],
+  ["http://foo.com/\\\\@",                   ["http:","foo.com","0","//@","",""]],
+  ["http:\\\\\\\\foo.com\\\\",               ["http:","foo.com","0","/","",""]],
+  ["http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\", ["http:","a","0","/b:c/d@foo.com/","",""]],
+  ["foo:/",                                  ["foo:","","0","/","",""]],
+  ["foo:/bar.com/",                          ["foo:","","0","/bar.com/","",""]],
+  ["foo://///////",                          ["foo:","","0","/////////","",""]],
+  ["foo://///////bar.com/",                  ["foo:","","0","/////////bar.com/","",""]],
+  ["foo:////://///",                         ["foo:","","0","////://///","",""]],
+  ["c:/foo",                                 ["c:","","0","/foo","",""]],
+  ["//foo/bar",                              [":","","0","","",""]],
+  ["http://foo/path;a??e#f#g",               ["http:","foo","0","/path;a","??e","#f#g"]],
+  ["http://foo/abcd?efgh?ijkl",              ["http:","foo","0","/abcd","?efgh?ijkl",""]],
+  ["http://foo/abcd#foo?bar",                ["http:","foo","0","/abcd","","#foo?bar"]],
+  ["[61:24:74]:98",                          ["data:","","0","text/[61:24:74]:98","",""]],
+  ["http://[61:27]:98",                      [":","","0","","",""]],
+  ["http:[61:27]/:foo",                      [":","","0","","",""]],
+  ["http://[1::2]:3:4",                      [":","","0","","",""]],
+  ["http://2001::1",                         [":","","0","","",""]],
+  ["http://[2001::1",                        [":","","0","","",""]],
+  ["http://2001::1]",                        [":","","0","","",""]],
+  ["http://2001::1]:80",                     [":","","0","","",""]],
+  ["http://[2001::1]",                       ["http:","[2001::1]","0","/","",""]],
+  ["http://[2001::1]:80",                    ["http:","[2001::1]","0","/","",""]],
+  ["http://[[::]]",                          [":","","0","","",""]],
+];
+
+var originalBaseURL = canonicalize(".");
+setBaseURL("data:text/plain,baseURL");
+
+for (var i = 0; i < cases.length; ++i) {
+  shouldBe("segments('" + cases[i][0] + "')",
+           "'" + JSON.stringify(cases[i][1]) + "'");
+}
+
+setBaseURL(originalBaseURL);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/url/segments-from-data-url-expected.txt b/LayoutTests/fast/url/segments-from-data-url-expected.txt
new file mode 100644 (file)
index 0000000..5d102ef
--- /dev/null
@@ -0,0 +1,75 @@
+Test URL segmentation
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS segments('http://user:pass@foo:21/bar;par?b#c') is '["http:","foo","21","/bar;par","?b","#c"]'
+FAIL segments('http:foo.com') should be ["http:","foo.com","0","/","",""]. Was ["http:","","0","foo.com","",""].
+PASS segments('\t   :foo.com   \n') is '[":","","0","","",""]'
+PASS segments(' foo.com  ') is '[":","","0","","",""]'
+PASS segments('a:\t foo.com') is '["a:","","0"," foo.com","",""]'
+FAIL segments('http://f:21/ b ? d # e ') should be ["http:","f","21","/%20b%20","?%20d%20","# e"]. Was ["http:","f","21","/ b ","?%20d%20","#%20e"].
+PASS segments('http://f:/c') is '["http:","f","0","/c","",""]'
+PASS segments('http://f:0/c') is '["http:","f","0","/c","",""]'
+PASS segments('http://f:00000000000000/c') is '["http:","f","0","/c","",""]'
+FAIL segments('http://f:00000000000000000000080/c') should be ["http:","f","0","/c","",""]. Was ["http:","f","80","/c","",""].
+PASS segments('http://f:b/c') is '[":","","0","","",""]'
+PASS segments('http://f: /c') is '[":","","0","","",""]'
+PASS segments('http://f:\n/c') is '["http:","f","0","/c","",""]'
+PASS segments('http://f:fifty-two/c') is '[":","","0","","",""]'
+FAIL segments('http://f:999999/c') should be [":","","0","","",""]. Was ["http:","f","65535","/c","",""].
+PASS segments('http://f: 21 / b ? d # e ') is '[":","","0","","",""]'
+FAIL segments('') should be ["data:","","0","text/plain,baseURL","",""]. Was [":","","0","","",""].
+FAIL segments('  \t') should be ["data:","","0","text/plain,baseURL","",""]. Was [":","","0","","",""].
+PASS segments(':foo.com/') is '[":","","0","","",""]'
+PASS segments(':foo.com\\') is '[":","","0","","",""]'
+PASS segments(':') is '[":","","0","","",""]'
+PASS segments(':a') is '[":","","0","","",""]'
+PASS segments(':/') is '[":","","0","","",""]'
+PASS segments(':\\') is '[":","","0","","",""]'
+PASS segments(':#') is '[":","","0","","",""]'
+FAIL segments('#') should be [":","","0","","",""]. Was ["data:","","0","text/plain,baseURL","",""].
+FAIL segments('#/') should be [":","","0","","",""]. Was ["data:","","0","text/plain,baseURL","","#/"].
+FAIL segments('#\\') should be [":","","0","","",""]. Was ["data:","","0","text/plain,baseURL","","#\\"].
+FAIL segments('#;?') should be [":","","0","","",""]. Was ["data:","","0","text/plain,baseURL","","#;?"].
+PASS segments('?') is '[":","","0","","",""]'
+PASS segments('/') is '[":","","0","","",""]'
+PASS segments(':23') is '[":","","0","","",""]'
+FAIL segments('/:23') should be ["data:","","0","/:23","",""]. Was [":","","0","","",""].
+PASS segments('//') is '[":","","0","","",""]'
+PASS segments('::') is '[":","","0","","",""]'
+PASS segments('::23') is '[":","","0","","",""]'
+PASS segments('foo://') is '["foo:","","0","//","",""]'
+PASS segments('http://a:b@c:29/d') is '["http:","c","29","/d","",""]'
+FAIL segments('http::@c:29') should be ["http:","c","29","/","",""]. Was ["http:","","0",":@c:29","",""].
+FAIL segments('http://&a:foo(b]c@d:2/') should be ["http:","d","2","/","",""]. Was [":","","0","","",""].
+FAIL segments('http://::@c@d:2') should be ["http:","d","2","/","",""]. Was [":","","0","","",""].
+PASS segments('http://foo.com:b@d/') is '["http:","d","0","/","",""]'
+PASS segments('http://foo.com/\\@') is '["http:","foo.com","0","//@","",""]'
+PASS segments('http:\\\\foo.com\\') is '["http:","foo.com","0","/","",""]'
+PASS segments('http:\\\\a\\b:c\\d@foo.com\\') is '["http:","a","0","/b:c/d@foo.com/","",""]'
+PASS segments('foo:/') is '["foo:","","0","/","",""]'
+PASS segments('foo:/bar.com/') is '["foo:","","0","/bar.com/","",""]'
+PASS segments('foo://///////') is '["foo:","","0","/////////","",""]'
+PASS segments('foo://///////bar.com/') is '["foo:","","0","/////////bar.com/","",""]'
+PASS segments('foo:////://///') is '["foo:","","0","////://///","",""]'
+PASS segments('c:/foo') is '["c:","","0","/foo","",""]'
+PASS segments('//foo/bar') is '[":","","0","","",""]'
+FAIL segments('http://foo/path;a??e#f#g') should be ["http:","foo","0","/path;a","??e","#f#g"]. Was ["http:","foo","0","/path;a","??e","#f%23g"].
+PASS segments('http://foo/abcd?efgh?ijkl') is '["http:","foo","0","/abcd","?efgh?ijkl",""]'
+PASS segments('http://foo/abcd#foo?bar') is '["http:","foo","0","/abcd","","#foo?bar"]'
+FAIL segments('[61:24:74]:98') should be ["data:","","0","text/[61:24:74]:98","",""]. Was [":","","0","","",""].
+FAIL segments('http://[61:27]:98') should be [":","","0","","",""]. Was ["http:","[61:27]","98","/","",""].
+FAIL segments('http:[61:27]/:foo') should be [":","","0","","",""]. Was ["http:","","0","[61:27]/:foo","",""].
+PASS segments('http://[1::2]:3:4') is '[":","","0","","",""]'
+PASS segments('http://2001::1') is '[":","","0","","",""]'
+PASS segments('http://[2001::1') is '[":","","0","","",""]'
+PASS segments('http://2001::1]') is '[":","","0","","",""]'
+PASS segments('http://2001::1]:80') is '[":","","0","","",""]'
+PASS segments('http://[2001::1]') is '["http:","[2001::1]","0","/","",""]'
+FAIL segments('http://[2001::1]:80') should be ["http:","[2001::1]","0","/","",""]. Was ["http:","[2001::1]","80","/","",""].
+PASS segments('http://[[::]]') is '[":","","0","","",""]'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/url/segments-from-data-url.html b/LayoutTests/fast/url/segments-from-data-url.html
new file mode 100644 (file)
index 0000000..55be754
--- /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/segments-from-data-url.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>