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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 description('Test setting the hash attribute of the URL in HTMLAnchorElement.');
2
3 var a = document.createElement('a');
4
5 debug("Hash value does not start with '#'");
6 a.href = "https://www.mydomain.com:8080/path/testurl.html#middle";
7 a.hash = "hash-value";
8 shouldBe("a.href", "'https://www.mydomain.com:8080/path/testurl.html#hash-value' ");
9
10 debug("Hash value starts with '#'");
11 a.href = "file:///path/testurl.html#middle";
12 a.hash = "#hash_value";
13 shouldBe("a.href", "'file:///path/testurl.html#hash_value'");
14
15 debug("'?' in hash value");
16 a.href = "http://www.mydomain.com/path/testurl.html#middle";
17 a.hash = "#hash?value";
18 shouldBe("a.href", "'http://www.mydomain.com/path/testurl.html#hash?value'");
19
20 // The expected behavior should change when character table is updated.
21 // IE8 and Firefox3.5.2 don't consider these characters as illegal.
22 debug("'#' in hash value, and illegal characters in hostname");
23 a.href = "https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle";
24 a.hash = "#hash#value";
25 shouldBe("a.href", "'https://www.my\"d(){}|~om?ain#com/path/testurl.html#middle' ");
26
27 debug("Set hash to null");
28 a.href = "https://www.mydomain.com/path/testurl.html#middle";
29 a.hash = null;
30 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html#null'");
31
32 // Firefox 3.5.2 removes the '#' at the end, and it should per
33 // http://url.spec.whatwg.org/#dom-url-hash
34 debug("Set hash to empty string");
35 a.href = "https://www.mydomain.com/path/testurl.html#middle";
36 a.hash = "";
37 shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html'");
38
39 // Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should.
40 debug("Add hash to mailto: protocol");
41 a.href = "mailto:e-mail_address@goes_here";
42 a.hash = "hash-value";
43 shouldBe("a.href", "'mailto:e-mail_address@goes_here#hash-value'");
44
45 // IE8 does not percent-encode spaces in the hash component, but it does that
46 // in the path component.
47 debug("Add hash to file: protocol");
48 a.href = "file:///some path";
49 a.hash = "hash value";
50 shouldBe("a.href", "'file:///some%20path#hash value'");
51
52 debug("Set hash to '#'");
53 a.href = "http://mydomain.com#middle";
54 a.hash = "#";
55 shouldBe("a.href", "'http://mydomain.com/'");
56
57 // Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
58 debug("Add hash to non-standard protocol");
59 try {
60 a.href = "foo:bar";
61 a.hash = "#hash";
62 shouldBe("a.href", "'foo:bar#hash'");
63 } catch(e) {
64 debug("Exception: " + e.description);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698