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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.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-hash.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
index ca9e4ddb8ac31beed0a613db82523e402f9890d5..9c799679b65142aa049154b99e968e69371dd9e6 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html
@@ -4,6 +4,72 @@
<script src="../../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/set-href-attribute-hash.js"></script>
+<script>
+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'");
+
+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#null'");
+
+// Firefox 3.5.2 removes the '#' at the end, and it should per
+// http://url.spec.whatwg.org/#dom-url-hash
+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 value'");
+
+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);
+}
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698