The "port" property of an <a> whose href does not specify a port returns the wrong...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2011 00:13:20 +0000 (00:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2011 00:13:20 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66081

Source/WebCore:

HTMLAnchorElement now returns "" instead of "0" for unset port
Fixed KURLGoogle.cpp to have same behavior as KURL.cpp when setting port 0
Fixed Location.cpp to have same behavior as KURL.cpp when setting port 0

Patch by Rachel Blum <groby@chromium.org> on 2011-08-30
Reviewed by Adam Barth.

Tests: fast/dom/HTMLAnchorElement/get-href-attribute-port.html
       fast/dom/HTMLAnchorElement/set-href-attribute-port.html
       fast/loader/location-port.html
       fast/url/segments-from-data-url.html
       fast/url/segments.html
       fast/url/trivial-segments.html
       platform/chromium/fast/dom/HTMLAnchorElement/set-href-attribute-port.html

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::port):
* page/Location.cpp:
(WebCore::Location::host):
(WebCore::Location::port):
(WebCore::Location::setPort):
* platform/KURLGoogle.cpp:
(WebCore::KURL::setPort):

LayoutTests:

Updated tests to reflect behavior change around invalid port strings.
Updated chromium location-port test to reflect chromium issues

Patch by Rachel Blum <groby@chromium.org> on 2011-08-30
Reviewed by Adam Barth.

* fast/dom/HTMLAnchorElement/get-href-attribute-port-expected.txt: Added.
* fast/dom/HTMLAnchorElement/get-href-attribute-port.html: Added.
* fast/dom/HTMLAnchorElement/script-tests/get-href-attribute-port.js: Added.
* fast/loader/location-port-expected.txt:
* fast/loader/location-port.html:
* fast/url/script-tests/segments-from-data-url.js:
* fast/url/script-tests/segments.js:
* fast/url/script-tests/trivial-segments.js:
* fast/url/segments-expected.txt:
* fast/url/segments-from-data-url-expected.txt:
* fast/url/trivial-segments-expected.txt:
* platform/chromium-cg-mac/fast/loader/location-port-expected.txt:
* platform/chromium-win/fast/loader/location-port-expected.txt:
* platform/chromium/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt:

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/script-tests/get-href-attribute-port.js [new file with mode: 0644]
LayoutTests/fast/loader/location-port-expected.txt
LayoutTests/fast/loader/location-port.html
LayoutTests/fast/url/script-tests/segments-from-data-url.js
LayoutTests/fast/url/script-tests/segments.js
LayoutTests/fast/url/script-tests/trivial-segments.js
LayoutTests/fast/url/segments-expected.txt
LayoutTests/fast/url/segments-from-data-url-expected.txt
LayoutTests/fast/url/trivial-segments-expected.txt
LayoutTests/platform/chromium-cg-mac/fast/loader/location-port-expected.txt
LayoutTests/platform/chromium-win/fast/loader/location-port-expected.txt
LayoutTests/platform/chromium/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/page/Location.cpp
Source/WebCore/platform/KURLGoogle.cpp

index 6460621..8e88ea8 100644 (file)
@@ -1,3 +1,28 @@
+2011-08-30  Rachel Blum  <groby@chromium.org>
+
+        The "port" property of an <a> whose href does not specify a port returns the wrong value
+        https://bugs.webkit.org/show_bug.cgi?id=66081
+
+        Updated tests to reflect behavior change around invalid port strings. 
+        Updated chromium location-port test to reflect chromium issues
+        
+        Reviewed by Adam Barth.
+
+        * fast/dom/HTMLAnchorElement/get-href-attribute-port-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/get-href-attribute-port.html: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/get-href-attribute-port.js: Added.
+        * fast/loader/location-port-expected.txt:
+        * fast/loader/location-port.html:
+        * fast/url/script-tests/segments-from-data-url.js:
+        * fast/url/script-tests/segments.js:
+        * fast/url/script-tests/trivial-segments.js:
+        * fast/url/segments-expected.txt:
+        * fast/url/segments-from-data-url-expected.txt:
+        * fast/url/trivial-segments-expected.txt:
+        * platform/chromium-cg-mac/fast/loader/location-port-expected.txt:
+        * platform/chromium-win/fast/loader/location-port-expected.txt:
+        * platform/chromium/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt:
+
 2011-08-30  Scott Byer  <scottbyer@chromium.org>
 
         Fix pan scrolling on Windows to be clamped
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port-expected.txt
new file mode 100644 (file)
index 0000000..4889e15
--- /dev/null
@@ -0,0 +1,15 @@
+Test getting the port attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Default port is empty
+PASS a.port is ''
+Unspecified port should return empty string
+PASS a.port is ''
+Empty port should be empty
+PASS a.port is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port.html b/LayoutTests/fast/dom/HTMLAnchorElement/get-href-attribute-port.html
new file mode 100644 (file)
index 0000000..7256abf
--- /dev/null
@@ -0,0 +1,13 @@
+<!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>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/get-href-attribute-port.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/get-href-attribute-port.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/get-href-attribute-port.js
new file mode 100644 (file)
index 0000000..c0058f3
--- /dev/null
@@ -0,0 +1,16 @@
+description('Test getting the port attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Default port is empty");
+shouldBe("a.port", "''");
+
+debug("Unspecified port should return empty string");
+a.href = "http://example.com/";
+shouldBe("a.port", "''");
+
+debug("Empty port should be empty");
+a.href = "http://example.com:/";
+shouldBe("a.port", "''");
+
+var successfullyParsed = true;
index 32fab6e..5d29fa0 100644 (file)
@@ -4,3 +4,4 @@ PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 PASS: internalFrame.contentWindow.location.port == "88" should be true and is.
 PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 PASS: internalFrame.contentWindow.location.port == "80" should be true and is.
+PASS: internalFrame.contentWindow.location.host should be :0 and is.
index 23fa7cf..ed02855 100644 (file)
@@ -27,7 +27,7 @@
         var internalFrame = document.getElementById ('internal');
         shouldBe('internalFrame.contentWindow.location.port == "88"', true);
 
-        internalFrame.contentWindow.location.port = 0;
+        internalFrame.contentWindow.location.port = "";
         setTimeout(checkTest2, 300);
     }
 
         var internalFrame = document.getElementById ('internal');
         shouldBe('internalFrame.contentWindow.location.port == "80"', true);
 
+        internalFrame.contentWindow.location.port = 0;
+        setTimeout(checkTest4, 300);
+    }
+
+    function checkTest4() {
+        var internalFrame = document.getElementById ('internal');
+        shouldBe('internalFrame.contentWindow.location.host', ':0');
+
         if (window.layoutTestController)
             layoutTestController.notifyDone();
     }
 
+
     function runTests() {
         if (window.layoutTestController) {
             layoutTestController.clearBackForwardList();
index 5c4ae02..9be7142 100644 (file)
@@ -3,71 +3,71 @@ 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:foo.com",                           ["http:","foo.com","","/","",""]],
+  ["\\t   :foo.com   \\n",                   [":","","","","",""]],
+  [" foo.com  ",                             [":","","","","",""]],
+  ["a:\\t foo.com",                          ["a:","",""," 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:/c",                            ["http:","f","","/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",                         [":","","0","","",""]],
-  ["http://f:fifty-two/c",                   [":","","0","","",""]],
+  ["http://f:b/c",                           [":","","","","",""]],
+  ["http://f: /c",                           [":","","","","",""]],
+  ["http://f:\\n/c",                         [":","","","","",""]],
+  ["http://f:fifty-two/c",                   [":","","","","",""]],
   ["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://f: 21 / b ? d # e ",              [":","","","","",""]],
+  ["",                                       ["data:","","","text/plain,baseURL","",""]],
+  ["  \\t",                                  ["data:","","","text/plain,baseURL","",""]],
+  [":foo.com/",                              [":","","","","",""]],
+  [":foo.com\\\\",                           [":","","","","",""]],
+  [":",                                      [":","","","","",""]],
+  [":a",                                     [":","","","","",""]],
+  [":/",                                     [":","","","","",""]],
+  [":\\\\",                                  [":","","","","",""]],
+  [":#",                                     [":","","","","",""]],
+  ["#",                                      [":","","","","",""]],
+  ["#/",                                     [":","","","","",""]],
+  ["#\\\\",                                  [":","","","","",""]],
+  ["#;?",                                    [":","","","","",""]],
+  ["?",                                      [":","","","","",""]],
+  ["/",                                      [":","","","","",""]],
+  [":23",                                    [":","","","","",""]],
+  ["/:23",                                   ["data:","","","/:23","",""]],
+  ["//",                                     [":","","","","",""]],
+  ["::",                                     [":","","","","",""]],
+  ["::23",                                   [":","","","","",""]],
+  ["foo://",                                 ["foo:","","","//","",""]],
   ["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://foo.com:b@d/",                    ["http:","d","","/","",""]],
+  ["http://foo.com/\\\\@",                   ["http:","foo.com","","//@","",""]],
+  ["http:\\\\\\\\foo.com\\\\",               ["http:","foo.com","","/","",""]],
+  ["http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\", ["http:","a","","/b:c/d@foo.com/","",""]],
+  ["foo:/",                                  ["foo:","","","/","",""]],
+  ["foo:/bar.com/",                          ["foo:","","","/bar.com/","",""]],
+  ["foo://///////",                          ["foo:","","","/////////","",""]],
+  ["foo://///////bar.com/",                  ["foo:","","","/////////bar.com/","",""]],
+  ["foo:////://///",                         ["foo:","","","////://///","",""]],
+  ["c:/foo",                                 ["c:","","","/foo","",""]],
+  ["//foo/bar",                              [":","","","","",""]],
+  ["http://foo/path;a??e#f#g",               ["http:","foo","","/path;a","??e","#f#g"]],
+  ["http://foo/abcd?efgh?ijkl",              ["http:","foo","","/abcd","?efgh?ijkl",""]],
+  ["http://foo/abcd#foo?bar",                ["http:","foo","","/abcd","","#foo?bar"]],
+  ["[61:24:74]:98",                          ["data:","","","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","","",""]],
+  ["http:[61:27]/:foo",                      [":","","","","",""]],
+  ["http://[1::2]:3:4",                      [":","","","","",""]],
+  ["http://2001::1",                         [":","","","","",""]],
+  ["http://[2001::1",                        [":","","","","",""]],
+  ["http://2001::1]",                        [":","","","","",""]],
+  ["http://2001::1]:80",                     [":","","","","",""]],
+  ["http://[2001::1]",                       ["http:","[2001::1]","","/","",""]],
+  ["http://[2001::1]:80",                    ["http:","[2001::1]","","/","",""]],
+  ["http://[[::]]",                          [":","","","","",""]],
 ];
 
 var originalBaseURL = canonicalize(".");
index 037f243..a1e5dba 100644 (file)
@@ -3,95 +3,95 @@ 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:","example.org","0","/foo/foo.com","",""]],
-  ["\\t   :foo.com   \\n",                   ["http:","example.org","0","/foo/:foo.com","",""]],
-  [" foo.com  ",                             ["http:","example.org","0","/foo/foo.com","",""]],
-  ["a:\\t foo.com",                          ["a:","","0"," foo.com","",""]],
+  ["http:foo.com",                           ["http:","example.org","","/foo/foo.com","",""]],
+  ["\\t   :foo.com   \\n",                   ["http:","example.org","","/foo/:foo.com","",""]],
+  [" foo.com  ",                             ["http:","example.org","","/foo/foo.com","",""]],
+  ["a:\\t foo.com",                          ["a:","",""," 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:/c",                            ["http:","f","","/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",                         [":","","0","","",""]],
-  ["http://f:fifty-two/c",                   [":","","0","","",""]],
+  ["http://f:b/c",                           [":","","","","",""]],
+  ["http://f: /c",                           [":","","","","",""]],
+  ["http://f:\\n/c",                         [":","","","","",""]],
+  ["http://f:fifty-two/c",                   [":","","","","",""]],
   ["http://f:999999/c",                      [":","","0","","",""]],
-  ["http://f: 21 / b ? d # e ",              [":","","0","","",""]],
-  ["",                                       ["http:","example.org","0","/foo/bar","",""]],
-  ["  \\t",                                  ["http:","example.org","0","/foo/bar","",""]],
-  [":foo.com/",                              ["http:","example.org","0","/foo/:foo.com/","",""]],
-  [":foo.com\\\\",                           ["http:","example.org","0","/foo/:foo.com/","",""]],
-  [":",                                      ["http:","example.org","0","/foo/:","",""]],
-  [":a",                                     ["http:","example.org","0","/foo/:a","",""]],
-  [":/",                                     ["http:","example.org","0","/foo/:/","",""]],
-  [":\\\\",                                  ["http:","example.org","0","/foo/:/","",""]],
-  [":#",                                     ["http:","example.org","0","/foo/:","",""]],
-  ["#",                                      ["http:","example.org","0","/foo/bar","",""]],
-  ["#/",                                     ["http:","example.org","0","/foo/bar","","#/"]],
-  ["#\\\\",                                  ["http:","example.org","0","/foo/bar","","#\\\\"]],
-  ["#;?",                                    ["http:","example.org","0","/foo/bar","","#;?"]],
-  ["?",                                      ["http:","example.org","0","/foo/bar","",""]],
-  ["/",                                      ["http:","example.org","0","/","",""]],
-  [":23",                                    ["http:","example.org","0","/foo/:23","",""]],
-  ["/:23",                                   ["http:","example.org","0","/:23","",""]],
-  ["//",                                     [":","","0","","",""]],
-  ["::",                                     ["http:","example.org","0","/foo/::","",""]],
-  ["::23",                                   ["http:","example.org","0","/foo/::23","",""]],
-  ["foo://",                                 ["foo:","","0","//","",""]],
+  ["http://f: 21 / b ? d # e ",              [":","","","","",""]],
+  ["",                                       ["http:","example.org","","/foo/bar","",""]],
+  ["  \\t",                                  ["http:","example.org","","/foo/bar","",""]],
+  [":foo.com/",                              ["http:","example.org","","/foo/:foo.com/","",""]],
+  [":foo.com\\\\",                           ["http:","example.org","","/foo/:foo.com/","",""]],
+  [":",                                      ["http:","example.org","","/foo/:","",""]],
+  [":a",                                     ["http:","example.org","","/foo/:a","",""]],
+  [":/",                                     ["http:","example.org","","/foo/:/","",""]],
+  [":\\\\",                                  ["http:","example.org","","/foo/:/","",""]],
+  [":#",                                     ["http:","example.org","","/foo/:","",""]],
+  ["#",                                      ["http:","example.org","","/foo/bar","",""]],
+  ["#/",                                     ["http:","example.org","","/foo/bar","","#/"]],
+  ["#\\\\",                                  ["http:","example.org","","/foo/bar","","#\\\\"]],
+  ["#;?",                                    ["http:","example.org","","/foo/bar","","#;?"]],
+  ["?",                                      ["http:","example.org","","/foo/bar","",""]],
+  ["/",                                      ["http:","example.org","","/","",""]],
+  [":23",                                    ["http:","example.org","","/foo/:23","",""]],
+  ["/:23",                                   ["http:","example.org","","/:23","",""]],
+  ["//",                                     [":","","","","",""]],
+  ["::",                                     ["http:","example.org","","/foo/::","",""]],
+  ["::23",                                   ["http:","example.org","","/foo/::23","",""]],
+  ["foo://",                                 ["foo:","","","//","",""]],
   ["http://a:b@c:29/d",                      ["http:","c","29","/d","",""]],
-  ["http::@c:29",                            ["http:","example.org","0","/foo/:@c:29","",""]],
+  ["http::@c:29",                            ["http:","example.org","","/foo/:@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",                              ["http:","foo","0","/bar","",""]],
-  ["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",                          ["http:","example.org","0","/foo/[61:24:74]:98","",""]],
+  ["http://foo.com:b@d/",                    ["http:","d","","/","",""]],
+  ["http://foo.com/\\\\@",                   ["http:","foo.com","","//@","",""]],
+  ["http:\\\\\\\\foo.com\\\\",               ["http:","foo.com","","/","",""]],
+  ["http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\", ["http:","a","","/b:c/d@foo.com/","",""]],
+  ["foo:/",                                  ["foo:","","","/","",""]],
+  ["foo:/bar.com/",                          ["foo:","","","/bar.com/","",""]],
+  ["foo://///////",                          ["foo:","","","/////////","",""]],
+  ["foo://///////bar.com/",                  ["foo:","","","/////////bar.com/","",""]],
+  ["foo:////://///",                         ["foo:","","","////://///","",""]],
+  ["c:/foo",                                 ["c:","","","/foo","",""]],
+  ["//foo/bar",                              ["http:","foo","","/bar","",""]],
+  ["http://foo/path;a??e#f#g",               ["http:","foo","","/path;a","??e","#f#g"]],
+  ["http://foo/abcd?efgh?ijkl",              ["http:","foo","","/abcd","?efgh?ijkl",""]],
+  ["http://foo/abcd#foo?bar",                ["http:","foo","","/abcd","","#foo?bar"]],
+  ["[61:24:74]:98",                          ["http:","example.org","","/foo/[61:24:74]:98","",""]],
   ["http://[61:27]:98",                      [":","","0","","",""]],
-  ["http:[61:27]/:foo",                      ["http:","example.org","0","/foo/[61:27]/:foo","",""]],
-  ["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","","",""]],
-  ["http:/example.com/",                     ["http:","example.org","0","/example.com/","",""]],
-  ["ftp:/example.com/",                      ["ftp:","example.com","0","/","",""]],
-  ["https:/example.com/",                    ["https:","example.com","0","/","",""]],
-  ["madeupscheme:/example.com/",             ["madeupscheme:","","0","/example.com/","",""]],
-  ["file:/example.com/",                     ["file:","","0","/example.com/","",""]],
-  ["ftps:/example.com/",                     ["ftps:","","0","/example.com/","",""]],
-  ["gopher:/example.com/",                   ["gopher:","example.com","0","/","",""]],
-  ["ws:/example.com/",                       ["ws:","example.com","0","/","",""]],
-  ["wss:/example.com/",                      ["wss:","example.com","0","/","",""]],
-  ["data:/example.com/",                     ["data:","","0","/example.com/","",""]],
-  ["javascript:/example.com/",               ["javascript:","","0","/example.com/","",""]],
-  ["mailto:/example.com/",                   ["mailto:","","0","/example.com/","",""]],
-  ["http:example.com/",                      ["http:","example.org","0","/foo/example.com/","",""]],
-  ["ftp:example.com/",                       ["ftp:","example.com","0","/","",""]],
-  ["https:example.com/",                     ["https:","example.com","0","/","",""]],
-  ["madeupscheme:example.com/",              ["madeupscheme:","","0","example.com/","",""]],
-  ["file:example.com/",                      ["file:","","0","/example.com/","",""]],
-  ["ftps:example.com/",                      ["ftps:","","0","example.com/","",""]],
-  ["gopher:example.com/",                    ["gopher:","example.com","0","/","",""]],
-  ["ws:example.com/",                        ["ws:","example.com","0","/","",""]],
-  ["wss:example.com/",                       ["wss:","example.com","0","/","",""]],
-  ["data:example.com/",                      ["data:","","0","example.com/","",""]],
-  ["javascript:example.com/",                ["javascript:","","0","example.com/","",""]],
-  ["mailto:example.com/",                    ["mailto:","","0","example.com/","",""]],  
+  ["http:[61:27]/:foo",                      ["http:","example.org","","/foo/[61:27]/:foo","",""]],
+  ["http://[1::2]:3:4",                      [":","","","","",""]],
+  ["http://2001::1",                         [":","","","","",""]],
+  ["http://[2001::1",                        [":","","","","",""]],
+  ["http://2001::1]",                        [":","","","","",""]],
+  ["http://2001::1]:80",                     [":","","","","",""]],
+  ["http://[2001::1]",                       ["http:","[2001::1]","","/","",""]],
+  ["http://[2001::1]:80",                    ["http:","[2001::1]","","/","",""]],
+  ["http://[[::]]",                          [":","","","","",""]],
+  ["http:/example.com/",                     ["http:","example.org","","/example.com/","",""]],
+  ["ftp:/example.com/",                      ["ftp:","example.com","","/","",""]],
+  ["https:/example.com/",                    ["https:","example.com","","/","",""]],
+  ["madeupscheme:/example.com/",             ["madeupscheme:","","","/example.com/","",""]],
+  ["file:/example.com/",                     ["file:","","","/example.com/","",""]],
+  ["ftps:/example.com/",                     ["ftps:","","","/example.com/","",""]],
+  ["gopher:/example.com/",                   ["gopher:","example.com","","/","",""]],
+  ["ws:/example.com/",                       ["ws:","example.com","","/","",""]],
+  ["wss:/example.com/",                      ["wss:","example.com","","/","",""]],
+  ["data:/example.com/",                     ["data:","","","/example.com/","",""]],
+  ["javascript:/example.com/",               ["javascript:","","","/example.com/","",""]],
+  ["mailto:/example.com/",                   ["mailto:","","","/example.com/","",""]],
+  ["http:example.com/",                      ["http:","example.org","","/foo/example.com/","",""]],
+  ["ftp:example.com/",                       ["ftp:","example.com","","/","",""]],
+  ["https:example.com/",                     ["https:","example.com","","/","",""]],
+  ["madeupscheme:example.com/",              ["madeupscheme:","","","example.com/","",""]],
+  ["file:example.com/",                      ["file:","","","/example.com/","",""]],
+  ["ftps:example.com/",                      ["ftps:","","","example.com/","",""]],
+  ["gopher:example.com/",                    ["gopher:","example.com","","/","",""]],
+  ["ws:example.com/",                        ["ws:","example.com","","/","",""]],
+  ["wss:example.com/",                       ["wss:","example.com","","/","",""]],
+  ["data:example.com/",                      ["data:","","","example.com/","",""]],
+  ["javascript:example.com/",                ["javascript:","","","example.com/","",""]],
+  ["mailto:example.com/",                    ["mailto:","","","example.com/","",""]],  
 ];
 
 var originalBaseURL = canonicalize(".");
index 81edfd1..c19551b 100644 (file)
@@ -2,7 +2,7 @@ description("Test basic features of URL segmentation");
 
 cases = [ 
   // [URL, [SCHEME, HOST, PORT, PATH, QUERY, REF]]
-  ["http://example.com/", ["http:", "example.com", "0", "/", "", ""]],
+  ["http://example.com/", ["http:", "example.com", "", "/", "", ""]],
 ];
 
 var originalBaseURL = canonicalize(".");
index 38ea324..0e51a1a 100644 (file)
@@ -4,95 +4,95 @@ 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"]'
-PASS segments('http:foo.com') is '["http:","example.org","0","/foo/foo.com","",""]'
-PASS segments('\t   :foo.com   \n') is '["http:","example.org","0","/foo/:foo.com","",""]'
-PASS segments(' foo.com  ') is '["http:","example.org","0","/foo/foo.com","",""]'
-PASS segments('a:\t foo.com') is '["a:","","0"," foo.com","",""]'
+PASS segments('http:foo.com') is '["http:","example.org","","/foo/foo.com","",""]'
+PASS segments('\t   :foo.com   \n') is '["http:","example.org","","/foo/:foo.com","",""]'
+PASS segments(' foo.com  ') is '["http:","example.org","","/foo/foo.com","",""]'
+PASS segments('a:\t foo.com') is '["a:","",""," 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","# e"].
-PASS segments('http://f:/c') is '["http:","f","0","/c","",""]'
+PASS segments('http://f:/c') is '["http:","f","","/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 '[":","","0","","",""]'
-PASS segments('http://f:fifty-two/c') is '[":","","0","","",""]'
+PASS segments('http://f:b/c') is '[":","","","","",""]'
+PASS segments('http://f: /c') is '[":","","","","",""]'
+PASS segments('http://f:\n/c') is '[":","","","","",""]'
+PASS segments('http://f:fifty-two/c') is '[":","","","","",""]'
 FAIL segments('http://f:999999/c') should be [":","","0","","",""]. Was ["http:","f","65535","/c","",""].
-PASS segments('http://f: 21 / b ? d # e ') is '[":","","0","","",""]'
-PASS segments('') is '["http:","example.org","0","/foo/bar","",""]'
-PASS segments('  \t') is '["http:","example.org","0","/foo/bar","",""]'
-PASS segments(':foo.com/') is '["http:","example.org","0","/foo/:foo.com/","",""]'
-PASS segments(':foo.com\\') is '["http:","example.org","0","/foo/:foo.com/","",""]'
-PASS segments(':') is '["http:","example.org","0","/foo/:","",""]'
-PASS segments(':a') is '["http:","example.org","0","/foo/:a","",""]'
-PASS segments(':/') is '["http:","example.org","0","/foo/:/","",""]'
-PASS segments(':\\') is '["http:","example.org","0","/foo/:/","",""]'
-PASS segments(':#') is '["http:","example.org","0","/foo/:","",""]'
-PASS segments('#') is '["http:","example.org","0","/foo/bar","",""]'
-PASS segments('#/') is '["http:","example.org","0","/foo/bar","","#/"]'
-PASS segments('#\\') is '["http:","example.org","0","/foo/bar","","#\\\\"]'
-PASS segments('#;?') is '["http:","example.org","0","/foo/bar","","#;?"]'
-PASS segments('?') is '["http:","example.org","0","/foo/bar","",""]'
-PASS segments('/') is '["http:","example.org","0","/","",""]'
-PASS segments(':23') is '["http:","example.org","0","/foo/:23","",""]'
-PASS segments('/:23') is '["http:","example.org","0","/:23","",""]'
-FAIL segments('//') should be [":","","0","","",""]. Was ["http:","","0","/","",""].
-PASS segments('::') is '["http:","example.org","0","/foo/::","",""]'
-PASS segments('::23') is '["http:","example.org","0","/foo/::23","",""]'
-PASS segments('foo://') is '["foo:","","0","//","",""]'
+PASS segments('http://f: 21 / b ? d # e ') is '[":","","","","",""]'
+PASS segments('') is '["http:","example.org","","/foo/bar","",""]'
+PASS segments('  \t') is '["http:","example.org","","/foo/bar","",""]'
+PASS segments(':foo.com/') is '["http:","example.org","","/foo/:foo.com/","",""]'
+PASS segments(':foo.com\\') is '["http:","example.org","","/foo/:foo.com/","",""]'
+PASS segments(':') is '["http:","example.org","","/foo/:","",""]'
+PASS segments(':a') is '["http:","example.org","","/foo/:a","",""]'
+PASS segments(':/') is '["http:","example.org","","/foo/:/","",""]'
+PASS segments(':\\') is '["http:","example.org","","/foo/:/","",""]'
+PASS segments(':#') is '["http:","example.org","","/foo/:","",""]'
+PASS segments('#') is '["http:","example.org","","/foo/bar","",""]'
+PASS segments('#/') is '["http:","example.org","","/foo/bar","","#/"]'
+PASS segments('#\\') is '["http:","example.org","","/foo/bar","","#\\\\"]'
+PASS segments('#;?') is '["http:","example.org","","/foo/bar","","#;?"]'
+PASS segments('?') is '["http:","example.org","","/foo/bar","",""]'
+PASS segments('/') is '["http:","example.org","","/","",""]'
+PASS segments(':23') is '["http:","example.org","","/foo/:23","",""]'
+PASS segments('/:23') is '["http:","example.org","","/:23","",""]'
+FAIL segments('//') should be [":","","","","",""]. Was ["http:","","","/","",""].
+PASS segments('::') is '["http:","example.org","","/foo/::","",""]'
+PASS segments('::23') is '["http:","example.org","","/foo/::23","",""]'
+PASS segments('foo://') is '["foo:","","","//","",""]'
 PASS segments('http://a:b@c:29/d') is '["http:","c","29","/d","",""]'
-PASS segments('http::@c:29') is '["http:","example.org","0","/foo/:@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 '["http:","foo","0","/bar","",""]'
-PASS segments('http://foo/path;a??e#f#g') is '["http:","foo","0","/path;a","??e","#f#g"]'
-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"]'
-PASS segments('[61:24:74]:98') is '["http:","example.org","0","/foo/[61:24:74]:98","",""]'
+PASS segments('http::@c:29') is '["http:","example.org","","/foo/:@c:29","",""]'
+FAIL segments('http://&a:foo(b]c@d:2/') should be ["http:","d","2","/","",""]. Was [":","","","","",""].
+FAIL segments('http://::@c@d:2') should be ["http:","d","2","/","",""]. Was [":","","","","",""].
+PASS segments('http://foo.com:b@d/') is '["http:","d","","/","",""]'
+PASS segments('http://foo.com/\\@') is '["http:","foo.com","","//@","",""]'
+PASS segments('http:\\\\foo.com\\') is '["http:","foo.com","","/","",""]'
+PASS segments('http:\\\\a\\b:c\\d@foo.com\\') is '["http:","a","","/b:c/d@foo.com/","",""]'
+PASS segments('foo:/') is '["foo:","","","/","",""]'
+PASS segments('foo:/bar.com/') is '["foo:","","","/bar.com/","",""]'
+PASS segments('foo://///////') is '["foo:","","","/////////","",""]'
+PASS segments('foo://///////bar.com/') is '["foo:","","","/////////bar.com/","",""]'
+PASS segments('foo:////://///') is '["foo:","","","////://///","",""]'
+PASS segments('c:/foo') is '["c:","","","/foo","",""]'
+PASS segments('//foo/bar') is '["http:","foo","","/bar","",""]'
+PASS segments('http://foo/path;a??e#f#g') is '["http:","foo","","/path;a","??e","#f#g"]'
+PASS segments('http://foo/abcd?efgh?ijkl') is '["http:","foo","","/abcd","?efgh?ijkl",""]'
+PASS segments('http://foo/abcd#foo?bar') is '["http:","foo","","/abcd","","#foo?bar"]'
+PASS segments('[61:24:74]:98') is '["http:","example.org","","/foo/[61:24:74]:98","",""]'
 FAIL segments('http://[61:27]:98') should be [":","","0","","",""]. Was ["http:","[61:27]","98","/","",""].
-PASS segments('http:[61:27]/:foo') is '["http:","example.org","0","/foo/[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","/","",""]'
-PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","0","/","",""]'
-PASS segments('http://[[::]]') is '[":","","0","","",""]'
-FAIL segments('http:/example.com/') should be ["http:","example.org","0","/example.com/","",""]. Was ["http:","example.com","0","/","",""].
-PASS segments('ftp:/example.com/') is '["ftp:","example.com","0","/","",""]'
-PASS segments('https:/example.com/') is '["https:","example.com","0","/","",""]'
-PASS segments('madeupscheme:/example.com/') is '["madeupscheme:","","0","/example.com/","",""]'
-PASS segments('file:/example.com/') is '["file:","","0","/example.com/","",""]'
-PASS segments('ftps:/example.com/') is '["ftps:","","0","/example.com/","",""]'
-PASS segments('gopher:/example.com/') is '["gopher:","example.com","0","/","",""]'
-PASS segments('ws:/example.com/') is '["ws:","example.com","0","/","",""]'
-PASS segments('wss:/example.com/') is '["wss:","example.com","0","/","",""]'
-PASS segments('data:/example.com/') is '["data:","","0","/example.com/","",""]'
-PASS segments('javascript:/example.com/') is '["javascript:","","0","/example.com/","",""]'
-PASS segments('mailto:/example.com/') is '["mailto:","","0","/example.com/","",""]'
-PASS segments('http:example.com/') is '["http:","example.org","0","/foo/example.com/","",""]'
-PASS segments('ftp:example.com/') is '["ftp:","example.com","0","/","",""]'
-PASS segments('https:example.com/') is '["https:","example.com","0","/","",""]'
-PASS segments('madeupscheme:example.com/') is '["madeupscheme:","","0","example.com/","",""]'
-FAIL segments('file:example.com/') should be ["file:","","0","/example.com/","",""]. Was ["file:","","0","example.com/","",""].
-PASS segments('ftps:example.com/') is '["ftps:","","0","example.com/","",""]'
-PASS segments('gopher:example.com/') is '["gopher:","example.com","0","/","",""]'
-PASS segments('ws:example.com/') is '["ws:","example.com","0","/","",""]'
-PASS segments('wss:example.com/') is '["wss:","example.com","0","/","",""]'
-PASS segments('data:example.com/') is '["data:","","0","example.com/","",""]'
-PASS segments('javascript:example.com/') is '["javascript:","","0","example.com/","",""]'
-PASS segments('mailto:example.com/') is '["mailto:","","0","example.com/","",""]'
+PASS segments('http:[61:27]/:foo') is '["http:","example.org","","/foo/[61:27]/:foo","",""]'
+PASS segments('http://[1::2]:3:4') is '[":","","","","",""]'
+PASS segments('http://2001::1') is '[":","","","","",""]'
+PASS segments('http://[2001::1') is '[":","","","","",""]'
+PASS segments('http://2001::1]') is '[":","","","","",""]'
+PASS segments('http://2001::1]:80') is '[":","","","","",""]'
+PASS segments('http://[2001::1]') is '["http:","[2001::1]","","/","",""]'
+PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","","/","",""]'
+PASS segments('http://[[::]]') is '[":","","","","",""]'
+FAIL segments('http:/example.com/') should be ["http:","example.org","","/example.com/","",""]. Was ["http:","example.com","","/","",""].
+PASS segments('ftp:/example.com/') is '["ftp:","example.com","","/","",""]'
+PASS segments('https:/example.com/') is '["https:","example.com","","/","",""]'
+PASS segments('madeupscheme:/example.com/') is '["madeupscheme:","","","/example.com/","",""]'
+PASS segments('file:/example.com/') is '["file:","","","/example.com/","",""]'
+PASS segments('ftps:/example.com/') is '["ftps:","","","/example.com/","",""]'
+PASS segments('gopher:/example.com/') is '["gopher:","example.com","","/","",""]'
+PASS segments('ws:/example.com/') is '["ws:","example.com","","/","",""]'
+PASS segments('wss:/example.com/') is '["wss:","example.com","","/","",""]'
+PASS segments('data:/example.com/') is '["data:","","","/example.com/","",""]'
+PASS segments('javascript:/example.com/') is '["javascript:","","","/example.com/","",""]'
+PASS segments('mailto:/example.com/') is '["mailto:","","","/example.com/","",""]'
+PASS segments('http:example.com/') is '["http:","example.org","","/foo/example.com/","",""]'
+PASS segments('ftp:example.com/') is '["ftp:","example.com","","/","",""]'
+PASS segments('https:example.com/') is '["https:","example.com","","/","",""]'
+PASS segments('madeupscheme:example.com/') is '["madeupscheme:","","","example.com/","",""]'
+FAIL segments('file:example.com/') should be ["file:","","","/example.com/","",""]. Was ["file:","","","example.com/","",""].
+PASS segments('ftps:example.com/') is '["ftps:","","","example.com/","",""]'
+PASS segments('gopher:example.com/') is '["gopher:","example.com","","/","",""]'
+PASS segments('ws:example.com/') is '["ws:","example.com","","/","",""]'
+PASS segments('wss:example.com/') is '["wss:","example.com","","/","",""]'
+PASS segments('data:example.com/') is '["data:","","","example.com/","",""]'
+PASS segments('javascript:example.com/') is '["javascript:","","","example.com/","",""]'
+PASS segments('mailto:example.com/') is '["mailto:","","","example.com/","",""]'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 6066810..b4195a4 100644 (file)
@@ -4,71 +4,71 @@ 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"]'
-PASS segments('http:foo.com') is '["http:","foo.com","0","/","",""]'
-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","",""]'
+PASS segments('http:foo.com') is '["http:","foo.com","","/","",""]'
+PASS segments('\t   :foo.com   \n') is '[":","","","","",""]'
+PASS segments(' foo.com  ') is '[":","","","","",""]'
+PASS segments('a:\t foo.com') is '["a:","",""," 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","# e"].
-PASS segments('http://f:/c') is '["http:","f","0","/c","",""]'
+PASS segments('http://f:/c') is '["http:","f","","/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 '[":","","0","","",""]'
-PASS segments('http://f:fifty-two/c') is '[":","","0","","",""]'
+PASS segments('http://f:b/c') is '[":","","","","",""]'
+PASS segments('http://f: /c') is '[":","","","","",""]'
+PASS segments('http://f:\n/c') is '[":","","","","",""]'
+PASS segments('http://f:fifty-two/c') is '[":","","","","",""]'
 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://f: 21 / b ? d # e ') is '[":","","","","",""]'
+FAIL segments('') should be ["data:","","","text/plain,baseURL","",""]. Was [":","","","","",""].
+FAIL segments('  \t') should be ["data:","","","text/plain,baseURL","",""]. Was [":","","","","",""].
+PASS segments(':foo.com/') is '[":","","","","",""]'
+PASS segments(':foo.com\\') is '[":","","","","",""]'
+PASS segments(':') is '[":","","","","",""]'
+PASS segments(':a') is '[":","","","","",""]'
+PASS segments(':/') is '[":","","","","",""]'
+PASS segments(':\\') is '[":","","","","",""]'
+PASS segments(':#') is '[":","","","","",""]'
+FAIL segments('#') should be [":","","","","",""]. Was ["data:","","","text/plain,baseURL","",""].
+FAIL segments('#/') should be [":","","","","",""]. Was ["data:","","","text/plain,baseURL","","#/"].
+FAIL segments('#\\') should be [":","","","","",""]. Was ["data:","","","text/plain,baseURL","","#\\"].
+FAIL segments('#;?') should be [":","","","","",""]. Was ["data:","","","text/plain,baseURL","","#;?"].
+PASS segments('?') is '[":","","","","",""]'
+PASS segments('/') is '[":","","","","",""]'
+PASS segments(':23') is '[":","","","","",""]'
+FAIL segments('/:23') should be ["data:","","","/:23","",""]. Was [":","","","","",""].
+PASS segments('//') is '[":","","","","",""]'
+PASS segments('::') is '[":","","","","",""]'
+PASS segments('::23') is '[":","","","","",""]'
+PASS segments('foo://') is '["foo:","","","//","",""]'
 PASS segments('http://a:b@c:29/d') is '["http:","c","29","/d","",""]'
 PASS segments('http::@c:29') is '["http:","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","","",""]'
-PASS segments('http://foo/path;a??e#f#g') is '["http:","foo","0","/path;a","??e","#f#g"]'
-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://&a:foo(b]c@d:2/') should be ["http:","d","2","/","",""]. Was [":","","","","",""].
+FAIL segments('http://::@c@d:2') should be ["http:","d","2","/","",""]. Was [":","","","","",""].
+PASS segments('http://foo.com:b@d/') is '["http:","d","","/","",""]'
+PASS segments('http://foo.com/\\@') is '["http:","foo.com","","//@","",""]'
+PASS segments('http:\\\\foo.com\\') is '["http:","foo.com","","/","",""]'
+PASS segments('http:\\\\a\\b:c\\d@foo.com\\') is '["http:","a","","/b:c/d@foo.com/","",""]'
+PASS segments('foo:/') is '["foo:","","","/","",""]'
+PASS segments('foo:/bar.com/') is '["foo:","","","/bar.com/","",""]'
+PASS segments('foo://///////') is '["foo:","","","/////////","",""]'
+PASS segments('foo://///////bar.com/') is '["foo:","","","/////////bar.com/","",""]'
+PASS segments('foo:////://///') is '["foo:","","","////://///","",""]'
+PASS segments('c:/foo') is '["c:","","","/foo","",""]'
+PASS segments('//foo/bar') is '[":","","","","",""]'
+PASS segments('http://foo/path;a??e#f#g') is '["http:","foo","","/path;a","??e","#f#g"]'
+PASS segments('http://foo/abcd?efgh?ijkl') is '["http:","foo","","/abcd","?efgh?ijkl",""]'
+PASS segments('http://foo/abcd#foo?bar') is '["http:","foo","","/abcd","","#foo?bar"]'
+FAIL segments('[61:24:74]:98') should be ["data:","","","text/[61:24:74]:98","",""]. Was [":","","","","",""].
 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:","[61:27]","0","/: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","/","",""]'
-PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","0","/","",""]'
-PASS segments('http://[[::]]') is '[":","","0","","",""]'
+FAIL segments('http:[61:27]/:foo') should be [":","","","","",""]. Was ["http:","[61:27]","","/:foo","",""].
+PASS segments('http://[1::2]:3:4') is '[":","","","","",""]'
+PASS segments('http://2001::1') is '[":","","","","",""]'
+PASS segments('http://[2001::1') is '[":","","","","",""]'
+PASS segments('http://2001::1]') is '[":","","","","",""]'
+PASS segments('http://2001::1]:80') is '[":","","","","",""]'
+PASS segments('http://[2001::1]') is '["http:","[2001::1]","","/","",""]'
+PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","","/","",""]'
+PASS segments('http://[[::]]') is '[":","","","","",""]'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 882ff73..4f384fc 100644 (file)
@@ -3,7 +3,7 @@ Test basic features of URL segmentation
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS segments('http://example.com/') is '["http:","example.com","0","/","",""]'
+PASS segments('http://example.com/') is '["http:","example.com","","/","",""]'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index b69998d..4170120 100644 (file)
@@ -4,3 +4,4 @@ PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 FAIL: internalFrame.contentWindow.location.port == "88" should be true but instead is false.
 PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 FAIL: internalFrame.contentWindow.location.port == "80" should be true but instead is false.
+FAIL: internalFrame.contentWindow.location.host should be :0 but instead is .
index b69998d..4170120 100644 (file)
@@ -4,3 +4,4 @@ PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 FAIL: internalFrame.contentWindow.location.port == "88" should be true but instead is false.
 PASS: internalFrame.contentWindow.location.port == "" should be true and is.
 FAIL: internalFrame.contentWindow.location.port == "80" should be true but instead is false.
+FAIL: internalFrame.contentWindow.location.host should be :0 but instead is .
index 99af7fc..f71c267 100644 (file)
@@ -8,15 +8,15 @@ PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
 Default port as string
 PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
 Set port to 0
-FAIL a.href should be https://www.mydomain.com:0/path/testurl.html?key=value. Was https://www.mydomain.com/path/testurl.html?key=value.
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
 Set port to non-number
 PASS a.href is 'https://www.mydomain.com:4/path/testurl.html?key=value'
 Set port to null
-FAIL a.href should be https://www.mydomain.com:0/path/testurl.html?key=value. Was https://www.mydomain.com/path/testurl.html?key=value.
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
 Set port to empty string
-FAIL a.href should be https://www.mydomain.com:0/path/testurl.html?key=value. Was https://www.mydomain.com/path/testurl.html?key=value.
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
 Set port to undefined
-FAIL a.href should be https://www.mydomain.com:0/path/testurl.html?key=value. Was https://www.mydomain.com/path/testurl.html?key=value.
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
 Set port to URL with foo: protocol
 FAIL a.href should be foo://bar:50/. Was foo://bar/.
 PASS successfullyParsed is true
index aa15c1d..7a09557 100644 (file)
@@ -1,3 +1,31 @@
+2011-08-30  Rachel Blum  <groby@chromium.org>
+
+        The "port" property of an <a> whose href does not specify a port returns the wrong value
+        https://bugs.webkit.org/show_bug.cgi?id=66081
+
+        HTMLAnchorElement now returns "" instead of "0" for unset port
+        Fixed KURLGoogle.cpp to have same behavior as KURL.cpp when setting port 0
+        Fixed Location.cpp to have same behavior as KURL.cpp when setting port 0
+        
+        Reviewed by Adam Barth.
+
+        Tests: fast/dom/HTMLAnchorElement/get-href-attribute-port.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-port.html
+               fast/loader/location-port.html
+               fast/url/segments-from-data-url.html
+               fast/url/segments.html
+               fast/url/trivial-segments.html
+               platform/chromium/fast/dom/HTMLAnchorElement/set-href-attribute-port.html
+               
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::port):
+        * page/Location.cpp:
+        (WebCore::Location::host):
+        (WebCore::Location::port):
+        (WebCore::Location::setPort):
+        * platform/KURLGoogle.cpp:
+        (WebCore::KURL::setPort):
+
 2011-08-30  Scott Byer  <scottbyer@chromium.org>
 
         Fix pan scrolling on Windows to be clamped
index e0c2449..3433637 100644 (file)
@@ -403,7 +403,10 @@ void HTMLAnchorElement::setPathname(const String& value)
 
 String HTMLAnchorElement::port() const
 {
-    return String::number(href().port());
+    if (href().hasPort())
+        return String::number(href().port());
+
+    return emptyString();
 }
 
 void HTMLAnchorElement::setPort(const String& value)
index 0fb802f..4e5b228 100644 (file)
@@ -86,7 +86,7 @@ String Location::host() const
     // Note: this is the IE spec. The NS spec swaps the two, it says
     // "The hostname property is the concatenation of the host and port properties, separated by a colon."
     const KURL& url = this->url();
-    return url.port() ? url.host() + ":" + String::number(url.port()) : url.host();
+    return url.hasPort() ? url.host() + ":" + String::number(url.port()) : url.host();
 }
 
 String Location::hostname() const
@@ -103,7 +103,7 @@ String Location::port() const
         return String();
 
     const KURL& url = this->url();
-    return url.port() ? String::number(url.port()) : "";
+    return url.hasPort() ? String::number(url.port()) : "";
 }
 
 String Location::pathname() const
@@ -203,7 +203,7 @@ void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWin
         return;
     KURL url = m_frame->document()->url();
     int port = portString.toInt();
-    if (port < 0 || port > 0xFFFF)
+    if (port < 0 || port > 0xFFFF || portString.isEmpty())
         url.removePort();
     else
         url.setPort(port);
index 05d5596..203f0de 100644 (file)
@@ -670,16 +670,12 @@ void KURL::setPort(unsigned short i)
 {
     KURLGooglePrivate::Replacements replacements;
     String portStr;
-    if (i) {
-        portStr = String::number(i);
-        replacements.SetPort(
-            reinterpret_cast<const url_parse::UTF16Char*>(portStr.characters()),
-            url_parse::Component(0, portStr.length()));
 
-    } else {
-        // Clear any existing port when it is set to 0.
-        replacements.ClearPort();
-    }
+    portStr = String::number(i);
+    replacements.SetPort(
+        reinterpret_cast<const url_parse::UTF16Char*>(portStr.characters()),
+        url_parse::Component(0, portStr.length()));
+
     m_url.replaceComponents(replacements);
 }