Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
index 786a8256ed375c147d54f8e51f26667c0abac928..505cc1a08d54eddc3dc74317145578b96f495605 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hostname.html
@@ -4,6 +4,74 @@
<script src="../../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/set-href-attribute-hostname.js"></script>
+<script>
+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/'");
+
+debug("Set hostname to null");
+a.href = "https://www.mydomain.com:8080/path/";
+a.hostname = null;
+shouldBe("a.href", "'https://null: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/'");
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698