test_uri_scheme.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. -->
  5. <head>
  6. <title>Test for URI Manipulation</title>
  7. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  8. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  9. <script type="text/javascript">
  10. function dotest1()
  11. {
  12. SimpleTest.waitForExplicitFinish();
  13. var o = new URL("http://localhost/");
  14. try { o.href = "foopy:bar:baz"; } catch(e) { }
  15. o.protocol = "http:";
  16. o.hostname;
  17. try { o.href = "http://localhost/"; } catch(e) { }
  18. ok(o.protocol, "http:");
  19. dotest2();
  20. }
  21. function dotest2()
  22. {
  23. var o = new URL("http://www.mozilla.org/");
  24. try {
  25. o.href ="aaaaaaaaaaa:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  26. } catch(e) { }
  27. o.hash = "#";
  28. o.pathname = "/";
  29. o.protocol = "http:";
  30. try { o.href = "http://localhost/"; } catch(e) { }
  31. ok(o.protocol, "http:");
  32. dotest3();
  33. }
  34. function dotest3()
  35. {
  36. is(new URL("resource://123/").href, "resource://123/");
  37. SimpleTest.finish();
  38. }
  39. </script>
  40. </head>
  41. <body onload="dotest1();">
  42. <p id="display"></p>
  43. <div id="content" style="display: none"></div>
  44. <pre id="test">
  45. </pre>
  46. </body>
  47. </html>