test_bug423375.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=423375
  5. -->
  6. <head>
  7. <title>Test for Bug 423375</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=423375">Mozilla Bug 423375</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. <iframe id="load-frame"></iframe>
  16. </div>
  17. <pre id="test">
  18. <script class="testbody" type="text/javascript">
  19. /**
  20. ** Test for Bug 423375
  21. ** (content shouldn't be able to load chrome: or resource:)
  22. **/
  23. function tryLoad(url)
  24. {
  25. try {
  26. window.frames[0].location = url;
  27. return "loaded";
  28. } catch (e if /Access.*denied/.test(String(e))) {
  29. return "denied";
  30. } catch (e) {
  31. return "unexpected: " + e;
  32. }
  33. }
  34. is(tryLoad("chrome://global/content/mozilla.xhtml"), "denied",
  35. "content should have been prevented from loading chrome: URL");
  36. is(tryLoad("resource://gre-resources/html.css"), "denied",
  37. "content should have been prevented from loading resource: URL");
  38. </script>
  39. </pre>
  40. </body>
  41. </html>