1description('Test setting the href attribute of an HTMLAnchorElement to a URL with leading and trailing whitespace.'); 2 3var a = document.createElement('a'); 4 5debug("Set href that starts with a space"); 6a.href = " https://www.mydomain.com/path/testurl.html?key=value"; 7shouldBe("a.hostname", "'www.mydomain.com'"); 8 9debug("Set href that starts with a newline"); 10a.href = "\nhttps://www.mydomain.com/path/testurl.html?key=value"; 11shouldBe("a.hostname", "'www.mydomain.com'"); 12 13debug("Set href that starts with a tab"); 14a.href = "\thttps://www.mydomain.com/path/testurl.html?key=value"; 15shouldBe("a.hostname", "'www.mydomain.com'"); 16 17debug("Set href that starts with a carriage return"); 18a.href = "\rhttps://www.mydomain.com/path/testurl.html?key=value"; 19shouldBe("a.hostname", "'www.mydomain.com'"); 20 21debug("Set href that starts with a combination of newlines, spaces and tabs"); 22a.href = "\n \t\r \nhttps://www.mydomain.com/path/testurl.html?key=value"; 23shouldBe("a.hostname", "'www.mydomain.com'"); 24 25debug("Set href that ends with a space"); 26a.href = "https://www.mydomain.com/path/testurl.html?key=value "; 27shouldBe("a.hostname", "'www.mydomain.com'"); 28 29debug("Set href that ends with a newline"); 30a.href = "https://www.mydomain.com/path/testurl.html?key=value\n"; 31shouldBe("a.hostname", "'www.mydomain.com'"); 32 33debug("Set href that ends with a tab"); 34a.href = "https://www.mydomain.com/path/testurl.html?key=value\t"; 35shouldBe("a.hostname", "'www.mydomain.com'"); 36 37debug("Set href that ends with a carriage return"); 38a.href = "https://www.mydomain.com/path/testurl.html?key=value\r"; 39shouldBe("a.hostname", "'www.mydomain.com'"); 40 41debug("Set href that ends with a combination of newlines, spaces and tabs"); 42a.href = "https://www.mydomain.com/path/testurl.html?key=value\n \t\r \n"; 43shouldBe("a.hostname", "'www.mydomain.com'"); 44 45debug("Set href that starts and ends with a combination of newlines, spaces and tabs"); 46a.href = "\n \t\r \nhttps://www.mydomain.com/path/testurl.html?key=value\n \t\r \n"; 47shouldBe("a.hostname", "'www.mydomain.com'"); 48 49var successfullyParsed = true; 50