summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-whitespace.js
blob: 8be62327d13a6f9ce88552468afde3dcec15d5d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;