test_url_malformedHost.html (1438B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1020041 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1020041</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1020041">Mozilla Bug 1020041</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 <iframe name="x" id="x"></iframe> 17 <iframe name="y" id="y"></iframe> 18 </div> 19 <pre id="test"> 20 </pre> 21 <a id="link" href="http://www.example.com:8080">foobar</a> 22 <area id="area" href="http://www.example.com:8080" /> 23 <script type="application/javascript"> 24 25 var tests = [ 26 { host: "?", expected: "www.example.com" }, 27 { host: "what?", expected: "what" }, 28 { host: "so what", expected: "www.example.com" }, 29 { host: "aa#bb", expected: "aa" }, 30 { host: "a/b", expected: "a" }, 31 { host: "a\\b", expected: "a" }, 32 { host: "[2001::1]#bla:10", expected: "[2001::1]"}, 33 ]; 34 35 for (var i = 0; i < tests.length; ++i) { 36 var url = new URL("http://www.example.com"); 37 url.host = tests[i].host; 38 is(url.host, tests[i].expected, "URL.host is: " + url.host); 39 40 url = new URL("http://www.example.com"); 41 url.hostname = tests[i].host; 42 is(url.hostname, tests[i].expected, "URL.hostname is: " + url.host); 43 } 44 45 </script> 46 </body> 47 </html>