test_url_data.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Test URL API - data:plain</title>
  6. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  7. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  8. </head>
  9. <body>
  10. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1018682">Mozilla Bug 1018682</a>
  11. <script type="application/javascript">
  12. var base = new URL("data:text/plain,");
  13. base.protocol = "chrome:";
  14. is(base.protocol, 'data:', "The protocol should not change from data to chrome.");
  15. try {
  16. var relative = new URL("a", base);
  17. ok(false, "Relative URL from a data:text/plain should not work.");
  18. } catch(e) {
  19. ok(true, "Relative URL from a data:text/plain should not work.");
  20. }
  21. base.protocol = "http:";
  22. ok(true, "Protocol: http changed");
  23. is(base.href, "http://text/plain,", "Base URL is correct");
  24. var relative = new URL("a", base);
  25. ok(relative, "This works.");
  26. is(relative.href, "http://text/a", "Relative URL is correct");
  27. </script>
  28. </body>
  29. </html>