diff options
Diffstat (limited to 'LayoutTests/fast/dom/HTMLAnchorElement')
25 files changed, 902 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.html new file mode 100644 index 0000000..1951c43 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/TEMPLATE.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="YOUR_JS_FILE_HERE"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</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@goes_here"; +a.hash = "hash-value"; +shouldBe("a.href", "'mailto:e-mail_address@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@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/script-tests/set-href-attribute-whitespace.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-whitespace.js new file mode 100644 index 0000000..8be6232 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-whitespace.js @@ -0,0 +1,49 @@ +description('Test setting the href attribute of an HTMLAnchorElement to a URL with leading and trailing whitespace.'); + +var a = document.createElement('a'); + +debug("Set href that starts with a space"); +a.href = " https://www.mydomain.com/path/testurl.html?key=value"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that starts with a newline"); +a.href = "\nhttps://www.mydomain.com/path/testurl.html?key=value"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that starts with a tab"); +a.href = "\thttps://www.mydomain.com/path/testurl.html?key=value"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that starts with a carriage return"); +a.href = "\rhttps://www.mydomain.com/path/testurl.html?key=value"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that starts with a combination of newlines, spaces and tabs"); +a.href = "\n \t\r \nhttps://www.mydomain.com/path/testurl.html?key=value"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that ends with a space"); +a.href = "https://www.mydomain.com/path/testurl.html?key=value "; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that ends with a newline"); +a.href = "https://www.mydomain.com/path/testurl.html?key=value\n"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that ends with a tab"); +a.href = "https://www.mydomain.com/path/testurl.html?key=value\t"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that ends with a carriage return"); +a.href = "https://www.mydomain.com/path/testurl.html?key=value\r"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that ends with a combination of newlines, spaces and tabs"); +a.href = "https://www.mydomain.com/path/testurl.html?key=value\n \t\r \n"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +debug("Set href that starts and ends with a combination of newlines, spaces and tabs"); +a.href = "\n \t\r \nhttps://www.mydomain.com/path/testurl.html?key=value\n \t\r \n"; +shouldBe("a.hostname", "'www.mydomain.com'"); + +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@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/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace-expected.txt new file mode 100644 index 0000000..f7dfc61 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace-expected.txt @@ -0,0 +1,31 @@ +Test setting the href attribute of an HTMLAnchorElement to a URL with leading and trailing whitespace. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Set href that starts with a space +PASS a.hostname is 'www.mydomain.com' +Set href that starts with a newline +PASS a.hostname is 'www.mydomain.com' +Set href that starts with a tab +PASS a.hostname is 'www.mydomain.com' +Set href that starts with a carriage return +PASS a.hostname is 'www.mydomain.com' +Set href that starts with a combination of newlines, spaces and tabs +PASS a.hostname is 'www.mydomain.com' +Set href that ends with a space +PASS a.hostname is 'www.mydomain.com' +Set href that ends with a newline +PASS a.hostname is 'www.mydomain.com' +Set href that ends with a tab +PASS a.hostname is 'www.mydomain.com' +Set href that ends with a carriage return +PASS a.hostname is 'www.mydomain.com' +Set href that ends with a combination of newlines, spaces and tabs +PASS a.hostname is 'www.mydomain.com' +Set href that starts and ends with a combination of newlines, spaces and tabs +PASS a.hostname is 'www.mydomain.com' +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace.html b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace.html new file mode 100644 index 0000000..7f86293 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-whitespace.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-whitespace.js"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> |