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

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

Issue 26248003: Do not special case null for URLUtils attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 description('Test setting the protocol attribute of the URL in HTMLAnchorElement .'); 1 description('Test setting the protocol attribute of the URL in HTMLAnchorElement .');
2 2
3 var a = document.createElement('a'); 3 var a = document.createElement('a');
4 4
5 debug("Basic test"); 5 debug("Basic test");
6 a.href = "https://www.mydomain.com/path/"; 6 a.href = "https://www.mydomain.com/path/";
7 a.protocol = "http-foo"; 7 a.protocol = "http-foo";
8 shouldBe("a.href", "'http-foo://www.mydomain.com/path/'"); 8 shouldBe("a.href", "'http-foo://www.mydomain.com/path/'");
9 9
10 // IE8 throws "Invalid argument" exception. 10 // IE8 throws "Invalid argument" exception.
(...skipping 26 matching lines...) Expand all
37 // IE8 throws "Invalid argument" exception. 37 // IE8 throws "Invalid argument" exception.
38 try { 38 try {
39 debug("Set a protocol that starts with ':'"); 39 debug("Set a protocol that starts with ':'");
40 a.href = "https://www.mydomain.com/path/"; 40 a.href = "https://www.mydomain.com/path/";
41 a.protocol = ":http"; 41 a.protocol = ":http";
42 shouldBe("a.href", "'https://www.mydomain.com/path/'"); 42 shouldBe("a.href", "'https://www.mydomain.com/path/'");
43 } catch(e) { 43 } catch(e) {
44 debug("Exception: " + e.description); 44 debug("Exception: " + e.description);
45 } 45 }
46 46
47 // IE8 converts null to "null", which is not the right thing to do.
48 debug("Set protocol to null"); 47 debug("Set protocol to null");
49 a.href = "https://www.mydomain.com/path/"; 48 a.href = "https://www.mydomain.com/path/";
50 a.protocol = null; 49 a.protocol = null;
51 shouldBe("a.href", "'https://www.mydomain.com/path/'"); 50 shouldBe("a.href", "'null://www.mydomain.com/path/'");
52 51
53 // IE8 throws "Invalid argument" exception. 52 // IE8 throws "Invalid argument" exception.
54 try { 53 try {
55 debug("Set protocol to empty string"); 54 debug("Set protocol to empty string");
56 a.href = "https://www.mydomain.com/path/"; 55 a.href = "https://www.mydomain.com/path/";
57 a.protocol = ""; 56 a.protocol = "";
58 shouldBe("a.href", "'https://www.mydomain.com/path/'"); 57 shouldBe("a.href", "'https://www.mydomain.com/path/'");
59 } catch(e) { 58 } catch(e) {
60 debug("Exception: " + e.description); 59 debug("Exception: " + e.description);
61 } 60 }
62 61
63 // Firefox 4 adds three slashes, unlike Safari and Chrome 62 // Firefox 4 adds three slashes, unlike Safari and Chrome
64 debug("Set protocol to http on malformed URL"); 63 debug("Set protocol to http on malformed URL");
65 a.href = "foo:??bar"; 64 a.href = "foo:??bar";
66 a.protocol = "http"; 65 a.protocol = "http";
67 shouldBe("a.href", "'http:/??bar'"); 66 shouldBe("a.href", "'http:/??bar'");
68 67
69 // IE8 keeps the protocol if it is 'c:'. 68 // IE8 keeps the protocol if it is 'c:'.
70 debug("Set protocol to a URL which points to a local file"); 69 debug("Set protocol to a URL which points to a local file");
71 a.href = "c:\path"; 70 a.href = "c:\path";
72 a.protocol = "f-oo"; 71 a.protocol = "f-oo";
73 shouldBe("a.href", "'f-oo:path'"); 72 shouldBe("a.href", "'f-oo:path'");
74 73
75 debug("Set protocol to undefined"); 74 debug("Set protocol to undefined");
76 a.href = "https://www.mydomain.com/path/"; 75 a.href = "https://www.mydomain.com/path/";
77 a.protocol = undefined; 76 a.protocol = undefined;
78 shouldBe("a.href", "'undefined://www.mydomain.com/path/'"); 77 shouldBe("a.href", "'undefined://www.mydomain.com/path/'");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698