test_bug720619.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=720619
  5. -->
  6. <head>
  7. <title>Test for Bug 629227</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=720619">Mozilla Bug 720619</a>
  13. <p id="display">
  14. <iframe id="testTarget"></iframe>
  15. </p>
  16. <div id="content" style="display: none">
  17. </div>
  18. <pre id="test">
  19. <script type="application/javascript">
  20. /** Test for Bug 720619 **/
  21. SimpleTest.waitForExplicitFinish();
  22. function checkThrows(f, exception) {
  23. try {
  24. f();
  25. ok(false, "should have thrown: " + f);
  26. } catch (e) {
  27. ok(exception.test(e.toString()), "correctly threw");
  28. }
  29. }
  30. function go() {
  31. var loc = $('ifr').contentWindow.location;
  32. checkThrows(function() {loc + '';}, /Permission denied/);
  33. checkThrows(function() {'' + loc;}, /Permission denied/);
  34. checkThrows(function() {String(loc);}, /Permission denied/);
  35. var win = $('ifr').contentWindow;
  36. checkThrows(function() {win + '';}, /Permission denied/);
  37. checkThrows(function() {'' + win;}, /Permission denied/);
  38. checkThrows(function() {String(win);}, /Permission denied/);
  39. SimpleTest.finish();
  40. }
  41. </script>
  42. <iframe id="ifr" onload="go()"
  43. src="http://example.org/tests/js/xpconnect/tests/mochitest/file_bug720619.html">
  44. </iframe>
  45. </pre>
  46. </body>
  47. </html>