test_bug800864.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=800864
  5. -->
  6. <head>
  7. <title>Test for Bug 800864</title>
  8. <script type="application/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=800864">Mozilla Bug 800864</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript">
  18. SimpleTest.waitForExplicitFinish();
  19. function checkThrows(f) {
  20. try {
  21. f();
  22. ok(false, "Didn't throw a security exception like we should");
  23. } catch(e) {
  24. ok(/denied|insecure/.exec(e), "Should throw security exception. Got: " + e);
  25. }
  26. }
  27. function go() {
  28. ifr = document.getElementById('ifr');
  29. win = ifr.contentWindow;
  30. loc = win.location;
  31. ifr.onload = check;
  32. win.location = 'http://test1.example.com';
  33. }
  34. function check() {
  35. checkThrows(function() { loc.toString(); });
  36. checkThrows(function() { loc.valueOf().toString(); });
  37. checkThrows(function() { loc.href; });
  38. checkThrows(function() { loc + ''; });
  39. SimpleTest.finish();
  40. }
  41. </script>
  42. </pre>
  43. </body>
  44. <iframe id="ifr" onload="go()" src="file_empty.html"></iframe>
  45. </html>