[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:30:11 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit d2fca6f8a3a8fb1dc2fbbefc0a750a6e269c9794
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 11 02:07:18 2009 +0000

    2009-11-10  Yael Aharon  <yael.aharon at nokia.com>
    
            Reviewed by Timothy Hatcher.
    
            Implement URL decomposition IDL attributes for HTMLAnchorElement.
            https://bugs.webkit.org/show_bug.cgi?id=29972
    
            Testcases for setting and getting different parts of the URL.
    
            * fast/dom/HTMLAnchorElement: Added.
            * fast/dom/HTMLAnchorElement/script-tests: Added.
            * fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hostname.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-pathname.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-port.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-protocol.js: Added.
            * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-search.js: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-hash.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-host.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-hostname-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-pathname-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-port.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-protocol-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt: Added.
            * fast/dom/HTMLAnchorElement/set-href-attribute-search.html: Added.
    2009-11-10  Yael Aharon  <yael.aharon at nokia.com>
    
            Reviewed by Timothy Hatcher.
    
            Implement URL decomposition IDL attributes for HTMLAnchorElement.
            https://bugs.webkit.org/show_bug.cgi?id=29972.
    
            Add methods for setting different parts of the URL in href attribute.
    
            Tests: fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-host.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-port.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html
                   fast/dom/HTMLAnchorElement/set-href-attribute-search.html
    
            * bindings/js/JSLocationCustom.cpp:
            (WebCore::JSLocation::setPort):
            * html/HTMLAnchorElement.cpp:
            (WebCore::parsePortFromStringPosition):
            (WebCore::HTMLAnchorElement::setHash):
            (WebCore::HTMLAnchorElement::setHost):
            (WebCore::HTMLAnchorElement::setHostname):
            (WebCore::HTMLAnchorElement::setPathname):
            (WebCore::HTMLAnchorElement::setPort):
            (WebCore::HTMLAnchorElement::setProtocol):
            (WebCore::HTMLAnchorElement::setSearch):
            * html/HTMLAnchorElement.h:
            * html/HTMLAnchorElement.idl:
            * loader/FrameLoader.cpp:
            (WebCore::FrameLoader::iconURL):
            * platform/KURL.cpp:
            (WebCore::KURL::removePort):
            (WebCore::KURL::setPort):
            (WebCore::KURL::prettyURL):
            (WebCore::protocolIsValid):
            * platform/KURL.h:
            (WebCore::KURL::canSetHostOrPort):
            (WebCore::KURL::canSetPathname):
            (WebCore::KURL::hasPort):
            * platform/network/soup/ResourceHandleSoup.cpp:
            (WebCore::):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ff528a3..36c6693 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,37 @@
+2009-11-10  Yael Aharon  <yael.aharon at nokia.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Implement URL decomposition IDL attributes for HTMLAnchorElement.
+        https://bugs.webkit.org/show_bug.cgi?id=29972
+
+        Testcases for setting and getting different parts of the URL.
+
+        * fast/dom/HTMLAnchorElement: Added.
+        * fast/dom/HTMLAnchorElement/script-tests: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hostname.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-pathname.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-port.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-protocol.js: Added.
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-search.js: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-hash.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-host.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-hostname-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-pathname-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-port.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-protocol-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/set-href-attribute-search.html: Added.
+
 2009-11-10  Brian Weinstein  <bweinstein at apple.com>
 
         Update getComputedStyle results for Windows to add -webkit-color-correction.
diff --git a/LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html
similarity index 100%
copy from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html
copy to LayoutTests/fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js
new file mode 100644
index 0000000..5cce834
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js
@@ -0,0 +1,70 @@
+description('Test setting the hash attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Hash value does not start with '#'");
+a.href = "https://www.mydomain.com:8080/path/testurl.html#middle";
+a.hash = "hash-value";
+shouldBe("a.href", "'https://www.mydomain.com:8080/path/testurl.html#hash-value'");
+
+debug("Hash value starts with '#'");
+a.href = "file:///path/testurl.html#middle";
+a.hash = "#hash_value";
+shouldBe("a.href", "'file:///path/testurl.html#hash_value'");
+
+debug("'?' in hash value");
+a.href = "http://www.mydomain.com/path/testurl.html#middle";
+a.hash = "#hash?value";
+shouldBe("a.href", "'http://www.mydomain.com/path/testurl.html#hash?value'");
+
+// The expected behavior should change when character table is updated.
+// IE8 and Firefox3.5.2 don't consider these characters as illegal.
+debug("'#' in hash value, and illegal characters in hostname");
+a.href = "https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle";
+a.hash = "#hash#value";
+shouldBe("a.href", "'https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle'");
+
+// IE8 converts null to "null", which is not the right thing to do.
+// Firefox 3.5.2 removes the '#' at the end, and it should per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set hash to null");
+a.href = "https://www.mydomain.com/path/testurl.html#middle";
+a.hash = null;
+shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'");
+
+// Firefox 3.5.2 removes the '#' at the end, and it should per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set hash to empty string");
+a.href = "https://www.mydomain.com/path/testurl.html#middle";
+a.hash = "";
+shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#'");
+
+// Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should.
+debug("Add hash to mailto: protocol");
+a.href = "mailto:e-mail_address at goes_here";
+a.hash = "hash-value";
+shouldBe("a.href", "'mailto:e-mail_address at goes_here#hash-value'");
+
+// IE8 does not percent-encode spaces in the hash component, but it does that
+// in the path component.
+debug("Add hash to file: protocol");
+a.href = "file:///some path";
+a.hash = "hash value";
+shouldBe("a.href", "'file:///some%20path#hash%20value'");
+
+debug("Set hash to '#'");
+a.href = "http://mydomain.com#middle";
+a.hash = "#";
+shouldBe("a.href", "'http://mydomain.com/#'");
+
+// Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
+debug("Add hash to non-standard protocol");
+try {
+a.href = "foo:bar";
+a.hash = "#hash";
+shouldBe("a.href", "'foo:bar#hash'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js
new file mode 100644
index 0000000..313cf0f
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-host.js
@@ -0,0 +1,115 @@
+description('Test setting the host attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Basic test");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com:0";
+shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+
+// IE8 throws "The URL is invalid" exception.
+debug("Set host with '?' in it");
+try {
+a.href = "https://www.mydomain.com:8080/path/?key=value";
+a.host = "www.other?domain.com:8080";
+shouldBe("a.href", "'https://www.other/?domain.com:8080/path/?key=value'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+debug("Set default port for another protocol");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com:80";
+shouldBe("a.href", "'https://www.otherdomain.com:80/path/'");
+
+debug("Set default port");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com:443";
+shouldBe("a.href", "'https://www.otherdomain.com/path/'");
+
+// Firefox 3.5.2 rejects a port that contains non-digits.
+debug("Set host with letters in port number");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com:44a5";
+shouldBe("a.href", "'https://www.otherdomain.com:44/path/'");
+
+// Firefox 3.5.2 ignores the leading space in the port, but errs on reparsing the port.
+debug("Leading space in port number");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com: 443";
+shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+
+// Firefox 3.5.2 removed the port, clearly against the spec .
+debug("Colon without port number");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.otherdomain.com:";
+shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+
+// IE8 converts null to "null", which is not the right thing to do.
+// Firefox 3.5.2 allows setting the host to null, which it shouldn't per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set host to null");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = null;
+shouldBe("a.href", "'https://www.mydomain.com:8080/path/'");
+
+// Both IE8 and Firefox 3.5.2 allow setting the host to empty string, which they shouldn't, per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+// Since both do that in a buggy way, WebKit does not follow either one of them.
+debug("Set host to empty string");
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "";
+shouldBe("a.href", "'https://www.mydomain.com:8080/path/'");
+
+// Firefox 3.5.2 does not `set the host for file: .
+debug("Set host to URL with file: protocol");
+a.href = "file:///path/";
+a.host = "mydomain.com";
+shouldBe("a.href", "'file://mydomain.com/path/'");
+
+// IE8 throws if the host contains '/'
+debug("Set host containing slashes in it");
+try {
+a.href = "https://www.mydomain.com:8080/path/";
+a.host = "www.other\dom/ain.com";
+shouldBe("a.href", "'https://www.otherdom/ain.com/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// Firefox 3.5.2 add the missing '/' thus gets a different result than IE8 and Webkit.
+debug("Set host to a malformed URL");
+a.href = "https:/\rww.my at domain.com:8080/path/";
+a.host = "www.other!domain.com:15";
+shouldBe("a.href", "'https://www.other!domain.com:15/ww.my@domain.com:8080/path/'");
+
+// IE8 throws an "Object Error" exception.
+// Firefox 3.5.2 accepts this but throws an exception later
+// WebKit should just reject
+debug("Set host that starts with ':'");
+try {
+a.href = "https://domain.com:8080/path/";
+a.host = ":www.otherdomain.com:15";
+shouldBe("a.href", "'https://domain.com:8080/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// IE8 throws a security exception if the host contains '@'
+debug("Set host to URL containing username and ..");
+try {
+a.href = "https://rwwmy@domain.com:8080/pa..th/";
+a.host = "www.other!domain.com:25";
+shouldBe("a.href", "'https://rwwmy@www.other!domain.com:25/pa..th/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// Both IE8 and Firefox append the hosts, instead of rejecting, per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set host to a URL with tel: protocol");
+a.href = "tel:+1-816-555-1212";
+a.host = "+1-800-555-1212";
+shouldBe("a.href", "'tel:+1-816-555-1212'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hostname.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hostname.js
new file mode 100644
index 0000000..0f4438f
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hostname.js
@@ -0,0 +1,72 @@
+description('Test setting the hostname attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Basic test");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = "www.otherdomain.com";
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
+
+// IE8 throws an exception "The URL is invalid".
+try {
+debug("Extra slashes before hostname");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = "//www.otherdomain.com";
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// Firefox 3.5.2 does not allow setting the host to foo: protocol
+debug("Set hostname to URL with foo: protocol");
+a.href = "foo://www.mydomain.com/path/";
+a.hostname = "www.otherdomain.com";
+shouldBe("a.href", "'foo://www.otherdomain.com/path/'");
+
+// IE8 converts null to "null", which is not the right thing to do.
+// Firefox 3.5.2 allows setting the hostname to null, which is wrong per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set hostname to null");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = null;
+shouldBe("a.href", "'https://www.mydomain.com:8080/path/'");
+
+// Both IE8 and Firefox 3.5.2 allow setting the host to empty string, against the spec at
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+// Since both do that in a buggy way, WebKit should not follow either one of them.
+debug("Set hostname to empty string");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = "";
+shouldBe("a.href", "'https://www.mydomain.com:8080/path/'");
+
+// IE8 fails to process really: protocol.
+debug("Set hostname to URL with 2 colons");
+a.href = "really:bad:url";
+a.hostname = "mydomain.com";
+shouldBe("a.href", "'really:bad:url'");
+
+// The expected behavior should change when the character table is updated.
+// IE8 encodes the space in the hostname.
+// Firefox3.5.2 and WebKit consider space as illegal character and would not set 
+// the new hostname.
+debug("Set a hostname that contains space in it");
+a.href = "http://www.my domain.com/path/";
+a.hostname = "www.other domain.com";
+shouldBe("a.href", "'http://www.my domain.com/path/'");
+
+// IE8 throws an exception "The URL is invalid".
+try {
+debug("Set hostname on a local file");
+a.href = "c:/path/testurl.html";
+a.hostname= "a";
+shouldBe("a.href", "'c:/path/testurl.html'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+debug("Set hostname to undefined");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = undefined;
+shouldBe("a.href", "'https://undefined:8080/path/'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-pathname.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-pathname.js
new file mode 100644
index 0000000..cc6a8e7
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-pathname.js
@@ -0,0 +1,71 @@
+description('Test setting the pathname attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Set pathname that starts with slash");
+a.href = "https://www.mydomain.com/path/testurl.html?key=value";
+a.pathname = "/path name";
+shouldBe("a.href", "'https://www.mydomain.com/path%20name?key=value'");
+
+// IE8 throws an "Invalid URL" exception.
+try {
+debug("Set pathname that does not start with slash and contains '?'");
+a.href = "https://www.mydomain.com/path/testurl.html?key=value";
+a.pathname = "pa?th";
+shouldBe("a.href", "'https://www.mydomain.com/pa%3Fth?key=value'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// IE8 throws an "Invalid URL" exception.
+try {
+debug("Set pathname that starts with double slash and contains '#'");
+a.href = "https://www.mydomain.com/path?key=value";
+a.pathname = "//path#name";
+shouldBe("a.href", "'https://www.mydomain.com//path%23name?key=value'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+debug("Set a pathname containing .. in it");
+a.href = "https://www.mydomain.com/path/testurl.html?key=value";
+a.pathname = "/it/../path";
+shouldBe("a.href", "'https://www.mydomain.com/path?key=value'");
+
+// IE8 converts null to "null", which is not the right thing to do.
+debug("Set pathname to null");
+a.href = "https://www.mydomain.com/path/testurl.html?key=value";
+a.pathname = null;
+shouldBe("a.href", "'https://www.mydomain.com/?key=value'");
+
+debug("Set pathname to empty string");
+a.href = "https://www.mydomain.com/?key=value";
+a.pathname = "";
+shouldBe("a.href", "'https://www.mydomain.com/?key=value'");
+
+// The expected behavior should change when the character table is updated.
+// IE8 considers this URL as valid.
+debug("Set pathname that includes illegal characters to URL that contains illegal characters.");
+a.href = "https://www.my|d[]()omain.com/path/testurl.html?key=value";
+a.pathname = "p$a|th";
+shouldBe("a.href", "'https://www.my|d[]()omain.com/path/testurl.html?key=value'");
+
+// IE8 throws a security exception.
+try {
+debug("Set pathname to URL that contains '@' in host");
+a.href = "http://w@#ww";
+a.pathname = "path";
+shouldBe("a.href", "'http://w@/path#ww'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// IE8 allows setting the pathname, for non-hierarchial URL.
+// It is not supposed to allow that per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set pathname to a URL with non-hierarchical protocol");
+a.href = "tel:+1800-555-1212";
+a.pathname = "the-path";
+shouldBe("a.href", "'tel:+1800-555-1212'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-port.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-port.js
new file mode 100644
index 0000000..9bc1112
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-port.js
@@ -0,0 +1,49 @@
+description('Test setting the port attribute of the URL in HTMLAnchorElement.');
+
+var a = document.createElement('a');
+
+debug("Default port as number");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = 443;
+shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
+
+debug("Default port as string");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = "443";
+shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
+
+debug("Set port to 0");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = "0";
+shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
+
+// Firefox 3.5.2 does not accept the port if any character is not a digit.
+debug("Set port to non-number");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = "4a";
+shouldBe("a.href", "'https://www.mydomain.com:4/path/testurl.html?key=value'");
+
+// Firefox 3.5.2 does not accept the port if it is null.
+debug("Set port to null");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = null;
+shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
+
+// Firefox 3.5.2 does not accept the port if it is null.
+debug("Set port to empty string");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = "";
+shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
+
+debug("Set port to undefined");
+a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
+a.port = undefined;
+shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
+
+// Firefox 3.5.2 does not allow setting the port on a URL with protocol foo: .
+debug("Set port to URL with foo: protocol");
+a.href = "foo://bar/";
+a.port = 50;
+shouldBe("a.href", "'foo://bar:50/'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-protocol.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-protocol.js
new file mode 100644
index 0000000..b296dea
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-protocol.js
@@ -0,0 +1,80 @@
+description('Test setting the protocol attribute of the URL in HTMLAnchorElement .');
+
+var a = document.createElement('a');
+
+debug("Basic test");
+a.href = "https://www.mydomain.com/path/";
+a.protocol = "http-foo";
+shouldBe("a.href", "'http-foo://www.mydomain.com/path/'");
+
+// IE8 throws "Invalid argument" exception.
+debug("Set a protocol that contains ':'");
+try {
+a.href = "https://www.mydomain.com/path/";
+a.protocol = "http:foo";
+shouldBe("a.href", "'http://www.mydomain.com/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// IE8 throws "Invalid argument" exception.
+debug("Set a protocol that contains invalid characters");
+try {
+a.href = "https://www.mydomain.com/path/";
+a.protocol = "http^foo";
+shouldBe("a.href", "'https://www.mydomain.com/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// The expected behavior should change when the character table is updated.
+// IE8 encodes '^' in the host.
+debug("Set a protocol to a URL with invalid host name");
+a.href = "h:^^";
+a.protocol = "foo";
+shouldBe("a.href", "'foo:^^'");
+
+// IE8 throws "Invalid argument" exception.
+try {
+debug("Set a protocol that starts with ':'");
+a.href = "https://www.mydomain.com/path/";
+a.protocol = ":http";
+shouldBe("a.href", "'https://www.mydomain.com/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// IE8 converts null to "null", which is not the right thing to do.
+debug("Set protocol to null");
+a.href = "https://www.mydomain.com/path/";
+a.protocol = null;
+shouldBe("a.href", "'https://www.mydomain.com/path/'");
+
+// IE8 throws "Invalid argument" exception.
+try {
+debug("Set protocol to empty string");
+a.href = "https://www.mydomain.com/path/";
+a.protocol = "";
+shouldBe("a.href", "'https://www.mydomain.com/path/'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+// Firefox 3.5.2 tries to build a hierarchical URL.
+debug("Set protocol to http on malformed URL");
+a.href = "foo:??bar";
+a.protocol = "http";
+shouldBe("a.href", "'http:??bar'");
+
+// IE8 keeps the protocol if it is 'c:'.
+debug("Set protocol to a URL which points to a local file");
+a.href = "c:\path";
+a.protocol = "f-oo";
+shouldBe("a.href", "'f-oo:path'");
+
+debug("Set protocol to undefined");
+a.href = "https://www.mydomain.com/path/";
+a.protocol = undefined;
+shouldBe("a.href", "'undefined://www.mydomain.com/path/'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-search.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-search.js
new file mode 100644
index 0000000..5b90a04
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-search.js
@@ -0,0 +1,49 @@
+description('Test setting the search attribute of the URL in HTMLAnchorElement .');
+
+var a = document.createElement('a');
+
+debug("Set search without '?'");
+a.href = "https://www.mydomain.com/path/?key=value";
+a.search = "value=key";
+shouldBe("a.href", "'https://www.mydomain.com/path/?value=key'");
+
+// IE8 does not encode spaces in search string
+debug("Set search that starts with '?' and contains spaces");
+a.href = "https://www.mydomain.com/path/?key=value";
+a.search = "?val ue= key?";
+shouldBe("a.href", "'https://www.mydomain.com/path/?val%20ue=%20key?'");
+
+debug("Set search to a malformed URL");
+a.href = "s:www.mydomain.com/path/";
+a.search = "%";
+shouldBe("a.href", "'s:www.mydomain.com/path/?%'");
+
+// IE8 throws "The URL is invalid" exception.
+debug("Set search containing '#'");
+try {
+a.href = "https://www.mydomain.com/path/?key=value#hash";
+a.search = "?value#key";
+shouldBe("a.href", "'https://www.mydomain.com/path/?value%23key#hash'");
+} catch(e) {
+debug("Exception: " + e.description);
+}
+
+debug("Set search to a malformed URL");
+a.href = "bad:/|/url";
+a.search = "?value=key";
+shouldBe("a.href", "'bad:/|/url?value=key'");
+
+// IE8 converts null to "null", which is not the right thing to do.
+debug("Set search to null");
+a.href = "https://www.mydomain.com/path/?key=value";
+a.search = null;
+shouldBe("a.href", "'https://www.mydomain.com/path/'");
+
+// Firefox 3.5.2 Removes the '?', and it shouldn't, per
+// http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes .
+debug("Set search to empty string");
+a.href = "https://www.mydomain.com/path/?key=value";
+a.search = "";
+shouldBe("a.href", "'https://www.mydomain.com/path/?'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt
new file mode 100644
index 0000000..6515820
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt
@@ -0,0 +1,29 @@
+Test setting the hash attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Hash value does not start with '#'
+PASS a.href is 'https://www.mydomain.com:8080/path/testurl.html#hash-value'
+Hash value starts with '#'
+PASS a.href is 'file:///path/testurl.html#hash_value'
+'?' in hash value
+PASS a.href is 'http://www.mydomain.com/path/testurl.html#hash?value'
+'#' in hash value, and illegal characters in hostname
+PASS a.href is 'https://www.my"d(){}|~om?ain#com/path/testurl.html#middle'
+Set hash to null
+PASS a.href is 'https://www.mydomain.com/path/testurl.html#'
+Set hash to empty string
+PASS a.href is 'https://www.mydomain.com/path/testurl.html#'
+Add hash to mailto: protocol
+PASS a.href is 'mailto:e-mail_address at goes_here#hash-value'
+Add hash to file: protocol
+PASS a.href is 'file:///some%20path#hash%20value'
+Set hash to '#'
+PASS a.href is 'http://mydomain.com/#'
+Add hash to non-standard protocol
+PASS a.href is 'foo:bar#hash'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
new file mode 100644
index 0000000..44ed1fc
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
@@ -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/set-href-attribute-hash.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt
new file mode 100644
index 0000000..6c457a4
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt
@@ -0,0 +1,39 @@
+Test setting the host attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Basic test
+PASS a.href is 'https://www.otherdomain.com:0/path/'
+Set host with '?' in it
+PASS a.href is 'https://www.other/?domain.com:8080/path/?key=value'
+Set default port for another protocol
+PASS a.href is 'https://www.otherdomain.com:80/path/'
+Set default port
+PASS a.href is 'https://www.otherdomain.com/path/'
+Set host with letters in port number
+PASS a.href is 'https://www.otherdomain.com:44/path/'
+Leading space in port number
+PASS a.href is 'https://www.otherdomain.com:0/path/'
+Colon without port number
+PASS a.href is 'https://www.otherdomain.com:0/path/'
+Set host to null
+PASS a.href is 'https://www.mydomain.com:8080/path/'
+Set host to empty string
+PASS a.href is 'https://www.mydomain.com:8080/path/'
+Set host to URL with file: protocol
+PASS a.href is 'file://mydomain.com/path/'
+Set host containing slashes in it
+PASS a.href is 'https://www.otherdom/ain.com/path/'
+Set host to a malformed URL
+PASS a.href is 'https://www.other!domain.com:15/ww.my@domain.com:8080/path/'
+Set host that starts with ':'
+PASS a.href is 'https://domain.com:8080/path/'
+Set host to URL containing username and ..
+PASS a.href is 'https://rwwmy@www.other!domain.com:25/pa..th/'
+Set host to a URL with tel: protocol
+PASS a.href is 'tel:+1-816-555-1212'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html
new file mode 100644
index 0000000..602f3d2
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html
@@ -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/set-href-attribute-host.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname-expected.txt
new file mode 100644
index 0000000..d0b284d
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname-expected.txt
@@ -0,0 +1,27 @@
+Test setting the hostname attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Basic test
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
+Extra slashes before hostname
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
+Set hostname to URL with foo: protocol
+PASS a.href is 'foo://www.otherdomain.com/path/'
+Set hostname to null
+PASS a.href is 'https://www.mydomain.com:8080/path/'
+Set hostname to empty string
+PASS a.href is 'https://www.mydomain.com:8080/path/'
+Set hostname to URL with 2 colons
+PASS a.href is 'really:bad:url'
+Set a hostname that contains space in it
+PASS a.href is 'http://www.my domain.com/path/'
+Set hostname on a local file
+FAIL a.href should be c:/path/testurl.html. Was c://a/path/testurl.html.
+Set hostname to undefined
+PASS a.href is 'https://undefined:8080/path/'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
new file mode 100644
index 0000000..f08b433
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
@@ -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/set-href-attribute-hostname.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname-expected.txt
new file mode 100644
index 0000000..5b2d8ae
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname-expected.txt
@@ -0,0 +1,27 @@
+Test setting the pathname attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Set pathname that starts with slash
+PASS a.href is 'https://www.mydomain.com/path%20name?key=value'
+Set pathname that does not start with slash and contains '?'
+PASS a.href is 'https://www.mydomain.com/pa%3Fth?key=value'
+Set pathname that starts with double slash and contains '#'
+PASS a.href is 'https://www.mydomain.com//path%23name?key=value'
+Set a pathname containing .. in it
+PASS a.href is 'https://www.mydomain.com/path?key=value'
+Set pathname to null
+PASS a.href is 'https://www.mydomain.com/?key=value'
+Set pathname to empty string
+PASS a.href is 'https://www.mydomain.com/?key=value'
+Set pathname that includes illegal characters to URL that contains illegal characters.
+PASS a.href is 'https://www.my|d[]()omain.com/path/testurl.html?key=value'
+Set pathname to URL that contains '@' in host
+PASS a.href is 'http://w@/path#ww'
+Set pathname to a URL with non-hierarchical protocol
+PASS a.href is 'tel:+1800-555-1212'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html
new file mode 100644
index 0000000..93d70b0
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html
@@ -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/set-href-attribute-pathname.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt
new file mode 100644
index 0000000..93678c4
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt
@@ -0,0 +1,25 @@
+Test setting the port attribute of the URL in HTMLAnchorElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Default port as number
+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
+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
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
+Set port to empty string
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
+Set port to undefined
+PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
+Set port to URL with foo: protocol
+PASS a.href is 'foo://bar:50/'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port.html
new file mode 100644
index 0000000..f5cc94e
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port.html
@@ -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/set-href-attribute-port.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol-expected.txt
new file mode 100644
index 0000000..bd801ab
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol-expected.txt
@@ -0,0 +1,29 @@
+Test setting the protocol attribute of the URL in HTMLAnchorElement .
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Basic test
+PASS a.href is 'http-foo://www.mydomain.com/path/'
+Set a protocol that contains ':'
+PASS a.href is 'http://www.mydomain.com/path/'
+Set a protocol that contains invalid characters
+PASS a.href is 'https://www.mydomain.com/path/'
+Set a protocol to a URL with invalid host name
+PASS a.href is 'foo:^^'
+Set a protocol that starts with ':'
+PASS a.href is 'https://www.mydomain.com/path/'
+Set protocol to null
+PASS a.href is 'https://www.mydomain.com/path/'
+Set protocol to empty string
+PASS a.href is 'https://www.mydomain.com/path/'
+Set protocol to http on malformed URL
+PASS a.href is 'http:??bar'
+Set protocol to a URL which points to a local file
+PASS a.href is 'f-oo:path'
+Set protocol to undefined
+PASS a.href is 'undefined://www.mydomain.com/path/'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html
new file mode 100644
index 0000000..8f6ec8f
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html
@@ -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/set-href-attribute-protocol.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt
new file mode 100644
index 0000000..d034e2b
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt
@@ -0,0 +1,23 @@
+Test setting the search attribute of the URL in HTMLAnchorElement .
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Set search without '?'
+PASS a.href is 'https://www.mydomain.com/path/?value=key'
+Set search that starts with '?' and contains spaces
+PASS a.href is 'https://www.mydomain.com/path/?val%20ue=%20key?'
+Set search to a malformed URL
+PASS a.href is 's:www.mydomain.com/path/?%'
+Set search containing '#'
+PASS a.href is 'https://www.mydomain.com/path/?value%23key#hash'
+Set search to a malformed URL
+PASS a.href is 'bad:/|/url?value=key'
+Set search to null
+PASS a.href is 'https://www.mydomain.com/path/'
+Set search to empty string
+PASS a.href is 'https://www.mydomain.com/path/?'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search.html
new file mode 100644
index 0000000..58695cb
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-search.html
@@ -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/set-href-attribute-search.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ab0f9e1..9da85cd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2009-11-10  Yael Aharon  <yael.aharon at nokia.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Implement URL decomposition IDL attributes for HTMLAnchorElement.
+        https://bugs.webkit.org/show_bug.cgi?id=29972.
+
+        Add methods for setting different parts of the URL in href attribute.
+
+        Tests: fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-host.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-pathname.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-port.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-protocol.html
+               fast/dom/HTMLAnchorElement/set-href-attribute-search.html
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::setPort):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::parsePortFromStringPosition):
+        (WebCore::HTMLAnchorElement::setHash):
+        (WebCore::HTMLAnchorElement::setHost):
+        (WebCore::HTMLAnchorElement::setHostname):
+        (WebCore::HTMLAnchorElement::setPathname):
+        (WebCore::HTMLAnchorElement::setPort):
+        (WebCore::HTMLAnchorElement::setProtocol):
+        (WebCore::HTMLAnchorElement::setSearch):
+        * html/HTMLAnchorElement.h:
+        * html/HTMLAnchorElement.idl:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::iconURL):
+        * platform/KURL.cpp:
+        (WebCore::KURL::removePort):
+        (WebCore::KURL::setPort):
+        (WebCore::KURL::prettyURL):
+        (WebCore::protocolIsValid):
+        * platform/KURL.h:
+        (WebCore::KURL::canSetHostOrPort):
+        (WebCore::KURL::canSetPathname):
+        (WebCore::KURL::hasPort):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::):
+
 2009-11-10  Nate Chapin  <japhet at chromium.org>
 
         Unreviewed, fix Chromium build after http://trac.webkit.org/changeset/50760.
diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp
index c76a2b1..d765261 100644
--- a/WebCore/bindings/js/JSLocationCustom.cpp
+++ b/WebCore/bindings/js/JSLocationCustom.cpp
@@ -257,8 +257,9 @@ void JSLocation::setPort(ExecState* exec, JSValue value)
     const UString& portString = value.toString(exec);
     int port = charactersToInt(portString.data(), portString.size());
     if (port < 0 || port > 0xFFFF)
-        port = 0;
-    url.setPort(port);
+        url.removePort();
+    else
+        url.setPort(port);
 
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp
index d9cc1f7..de473a2 100644
--- a/WebCore/html/HTMLAnchorElement.cpp
+++ b/WebCore/html/HTMLAnchorElement.cpp
@@ -58,6 +58,15 @@ PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(const QualifiedName& tag
     return adoptRef(new HTMLAnchorElement(tagName, document));
 }
 
+// This function does not allow leading spaces before the port number.
+static unsigned parsePortFromStringPosition(const String& value, unsigned portStart, unsigned& portEnd)
+{
+    portEnd = portStart;
+    while (isASCIIDigit(value[portEnd]))
+        ++portEnd;
+    return value.substring(portStart, portEnd - portStart).toUInt();
+}
+
 bool HTMLAnchorElement::supportsFocus() const
 {
     if (isContentEditable())
@@ -362,6 +371,16 @@ String HTMLAnchorElement::hash() const
     return fragmentIdentifier.isEmpty() ? "" : "#" + fragmentIdentifier;
 }
 
+void HTMLAnchorElement::setHash(const String& value)
+{
+    KURL url = href();
+    if (value[0] == '#')
+        url.setFragmentIdentifier(value.substring(1));
+    else
+        url.setFragmentIdentifier(value);
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::host() const
 {
     const KURL& url = href();
@@ -372,32 +391,145 @@ String HTMLAnchorElement::host() const
     return url.host() + ":" + String::number(url.port());
 }
 
+void HTMLAnchorElement::setHost(const String& value)
+{
+    if (value.isEmpty())
+        return;
+    KURL url = href();
+    if (!url.canSetHostOrPort())
+        return;
+
+    int separator = value.find(':');
+    if (!separator)
+        return;
+
+    if (separator == -1)
+        url.setHostAndPort(value);
+    else {
+        unsigned portEnd;
+        unsigned port = parsePortFromStringPosition(value, separator + 1, portEnd);
+        if (!port) {
+            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
+            // specifically goes against RFC 3986 (p3.2) and
+            // requires setting the port to "0" if it is set to empty string.
+            url.setHostAndPort(value.substring(0, separator + 1) + "0");
+        } else {
+            if (SecurityOrigin::isDefaultPortForProtocol(port, url.protocol()))
+                url.setHostAndPort(value.substring(0, separator));
+            else
+                url.setHostAndPort(value.substring(0, portEnd));
+        }
+    }
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::hostname() const
 {
     return href().host();
 }
 
+void HTMLAnchorElement::setHostname(const String& value)
+{
+    // Before setting new value:
+    // Remove all leading U+002F SOLIDUS ("/") characters.
+    unsigned i = 0;
+    unsigned hostLength = value.length();
+    while (value[i] == '/')
+        i++;
+
+    if (i == hostLength)
+        return;
+
+    KURL url = href();
+    if (!url.canSetHostOrPort())
+        return;
+
+    url.setHost(value.substring(i));
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::pathname() const
 {
     return href().path();
 }
 
+void HTMLAnchorElement::setPathname(const String& value)
+{
+    KURL url = href();
+    if (!url.canSetPathname())
+        return;
+
+    if (value[0] == '/')
+        url.setPath(value);
+    else
+        url.setPath("/" + value);
+
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::port() const
 {
     return String::number(href().port());
 }
 
+void HTMLAnchorElement::setPort(const String& value)
+{
+    KURL url = href();
+    if (!url.canSetHostOrPort())
+        return;
+
+    // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
+    // specifically goes against RFC 3986 (p3.2) and
+    // requires setting the port to "0" if it is set to empty string.
+    unsigned port = value.toUInt();
+    if (SecurityOrigin::isDefaultPortForProtocol(port, url.protocol()))
+        url.removePort();
+    else
+        url.setPort(port);
+
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::protocol() const
 {
     return href().protocol() + ":";
 }
 
+void HTMLAnchorElement::setProtocol(const String& value)
+{
+    int separator = value.find(':');
+
+    if (!separator)
+        return;
+    if (value.isEmpty())
+        return;
+
+    KURL url = href();
+    // Following Firefox 3.5.2 which removes anything after the first ":"
+    String newProtocol = value.substring(0, separator);
+    if (!protocolIsValid(newProtocol))
+        return;
+    url.setProtocol(newProtocol);
+
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::search() const
 {
     String query = href().query();
     return query.isEmpty() ? "" : "?" + query;
 }
 
+void HTMLAnchorElement::setSearch(const String& value)
+{
+    KURL url = href();
+    String newSearch = (value[0] == '?') ? value.substring(1) : value;
+    // Make sure that '#' in the query does not leak to the hash.
+    url.setQuery(newSearch.replace('#', "%23"));
+
+    setHref(url.string());
+}
+
 String HTMLAnchorElement::text() const
 {
     return innerText();
diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h
index e47ea99..03d3529 100644
--- a/WebCore/html/HTMLAnchorElement.h
+++ b/WebCore/html/HTMLAnchorElement.h
@@ -62,12 +62,26 @@ public:
     const AtomicString& name() const;
 
     String hash() const;
+    void setHash(const String&);
+
     String host() const;
+    void setHost(const String&);
+
     String hostname() const;
+    void setHostname(const String&);
+
     String pathname() const;
+    void setPathname(const String&);
+
     String port() const;
+    void setPort(const String&);
+
     String protocol() const;
+    void setProtocol(const String&);
+
     String search() const;
+    void setSearch(const String&);
+
     String text() const;
 
     String toString() const;
diff --git a/WebCore/html/HTMLAnchorElement.idl b/WebCore/html/HTMLAnchorElement.idl
index 057358e..e55bd86 100644
--- a/WebCore/html/HTMLAnchorElement.idl
+++ b/WebCore/html/HTMLAnchorElement.idl
@@ -37,7 +37,7 @@ module html {
         attribute [ConvertNullToNullString, Reflect] DOMString target;
         attribute [ConvertNullToNullString, Reflect] DOMString type;
 
-        // IE Extensions
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
         readonly attribute DOMString hash;
         readonly attribute DOMString host;
         readonly attribute DOMString hostname;
@@ -45,6 +45,16 @@ module html {
         readonly attribute DOMString port;
         readonly attribute DOMString protocol;
         readonly attribute DOMString search;
+#else
+        attribute [ConvertNullToNullString] DOMString hash;
+        attribute [ConvertNullToNullString] DOMString host;
+        attribute [ConvertNullToNullString] DOMString hostname;
+        attribute [ConvertNullToNullString] DOMString pathname;
+        attribute [ConvertNullToNullString] DOMString port;
+        attribute [ConvertNullToNullString] DOMString protocol;
+        attribute [ConvertNullToNullString] DOMString search;
+#endif
+
         readonly attribute DOMString text;
 
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 7713371..45d4c76 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -605,8 +605,8 @@ KURL FrameLoader::iconURL()
     KURL url;
     url.setProtocol(m_URL.protocol());
     url.setHost(m_URL.host());
-    if (int port = m_URL.port())
-        url.setPort(port);
+    if (m_URL.hasPort())
+        url.setPort(m_URL.port());
     url.setPath("/favicon.ico");
     return url;
 }
diff --git a/WebCore/platform/KURL.cpp b/WebCore/platform/KURL.cpp
index c5829d2..90c5b0f 100644
--- a/WebCore/platform/KURL.cpp
+++ b/WebCore/platform/KURL.cpp
@@ -685,18 +685,22 @@ void KURL::setHost(const String& s)
     parse(m_string.left(hostStart()) + (slashSlashNeeded ? "//" : "") + s + m_string.substring(m_hostEnd));
 }
 
+void KURL::removePort()
+{
+    if (m_hostEnd == m_portEnd)
+        return;
+    parse(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
+}
+
 void KURL::setPort(unsigned short i)
 {
     if (!m_isValid)
         return;
 
-    if (i) {
-        bool colonNeeded = m_portEnd == m_hostEnd;
-        int portStart = (colonNeeded ? m_hostEnd : m_hostEnd + 1);
+    bool colonNeeded = m_portEnd == m_hostEnd;
+    int portStart = (colonNeeded ? m_hostEnd : m_hostEnd + 1);
 
-        parse(m_string.left(portStart) + (colonNeeded ? ":" : "") + String::number(i) + m_string.substring(m_portEnd));
-    } else
-        parse(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
+    parse(m_string.left(portStart) + (colonNeeded ? ":" : "") + String::number(i) + m_string.substring(m_portEnd));
 }
 
 void KURL::setHostAndPort(const String& hostAndPort)
@@ -819,7 +823,7 @@ String KURL::prettyURL() const
             authority.append('@');
         }
         append(authority, host());
-        if (port() != 0) {
+        if (hasPort()) {
             authority.append(':');
             append(authority, String::number(port()));
         }
@@ -1624,6 +1628,18 @@ bool protocolIsJavaScript(const String& url)
     return protocolIs(url, "javascript");
 }
 
+bool protocolIsValid(const String& protocol)
+{
+    if (!isSchemeFirstChar(protocol[0]))
+        return false;
+    unsigned protocolLength = protocol.length();
+    for (unsigned i = 1; i < protocolLength; i++) {
+        if (!isSchemeChar(protocol[i]))
+            return false;
+    }
+    return true;
+}
+
 String mimeTypeFromDataURL(const String& url)
 {
     ASSERT(protocolIs(url, "data"));
diff --git a/WebCore/platform/KURL.h b/WebCore/platform/KURL.h
index 73fadd1..4833e08 100644
--- a/WebCore/platform/KURL.h
+++ b/WebCore/platform/KURL.h
@@ -78,6 +78,7 @@ public:
     KURL(const KURL& base, const String& relative);
     KURL(const KURL& base, const String& relative, const TextEncoding&);
 
+
 #if USE(GOOGLEURL)
     // For conversions for other structures that have already parsed and
     // canonicalized the URL. The input must be exactly what KURL would have
@@ -104,6 +105,12 @@ public:
     // non-hierarchical (like "javascript:") URLs will have no path.
     bool hasPath() const;
 
+    // Returns true if you can set the host and port for the URL.
+    // Non-hierarchical URLs don't have a host and port.
+    bool canSetHostOrPort() const { return isHierarchical(); }
+
+    bool canSetPathname() const { return isHierarchical(); }
+    
 #if USE(GOOGLEURL)
     const String& string() const { return m_url.string(); }
 #else
@@ -113,6 +120,7 @@ public:
     String protocol() const;
     String host() const;
     unsigned short port() const;
+    bool hasPort() const;
     String user() const;
     String pass() const;
     String path() const;
@@ -135,7 +143,7 @@ public:
     void setProtocol(const String&);
     void setHost(const String&);
 
-    // Setting the port to 0 will clear any port from the URL.
+    void removePort();
     void setPort(unsigned short);
 
     // Input is like "foo.com" or "foo.com:8000".
@@ -254,6 +262,7 @@ const KURL& blankURL();
 
 bool protocolIs(const String& url, const char* protocol);
 bool protocolIsJavaScript(const String& url);
+bool protocolIsValid(const String& protocol);
 
 String mimeTypeFromDataURL(const String& url);
 
@@ -317,6 +326,11 @@ inline bool KURL::isValid() const
     return m_isValid;
 }
 
+inline bool KURL::hasPort() const
+{
+    return m_hostEnd < m_portEnd;
+}
+
 inline bool KURL::protocolInHTTPFamily() const
 {
     return m_protocolInHTTPFamily;
diff --git a/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/WebCore/platform/network/soup/ResourceHandleSoup.cpp
index a738af5..2e497ab 100644
--- a/WebCore/platform/network/soup/ResourceHandleSoup.cpp
+++ b/WebCore/platform/network/soup/ResourceHandleSoup.cpp
@@ -873,7 +873,7 @@ static bool startGio(ResourceHandle* handle, KURL url)
     // using GIO internally, and providing URIs instead of file paths
     url.removeFragmentIdentifier();
     url.setQuery(String());
-    url.setPort(0);
+    url.removePort();
 
 #if !PLATFORM(WIN_OS)
     // we avoid the escaping for local files, because

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list