test_bug605167.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=505915
  5. -->
  6. <head>
  7. <title>Test for Bug 505915</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=505915">Mozilla Bug 505915</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript;version=1.7">
  18. /** Test for Bug 505915 **/
  19. var dataUrl = "data:text/html,<script>parent.f = function() { return this; };<" + "/script>";
  20. var targetUrl = "http://example.com";
  21. var f;
  22. var p = 0;
  23. function go() {
  24. switch (++p) {
  25. case 1:
  26. frames[0].location = dataUrl;
  27. break;
  28. case 2:
  29. frames[0].location = targetUrl;
  30. break;
  31. case 3:
  32. try {
  33. f().cross_origin_property;
  34. ok(false, "should have thrown an exception");
  35. } catch (e) {
  36. ok(/Permission denied/.test(e) || /attempt to run compile-and-go script/.test(e),
  37. "threw the correct exception");
  38. }
  39. SimpleTest.finish();
  40. break;
  41. }
  42. }
  43. SimpleTest.waitForExplicitFinish();
  44. </script>
  45. </pre>
  46. <iframe id="ifr" onload="go();"></iframe>
  47. </body>
  48. </html>