test_bug1126911.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=1126911
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 1126911</title>
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
  11. <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
  12. <script type="application/javascript">
  13. /** Test for Bug 1126911 **/
  14. const Cu = Components.utils;
  15. var sb = new Cu.Sandbox(null);
  16. sb.win = window;
  17. sb.loc = location;
  18. function checkThrows(expr) {
  19. try {
  20. Cu.evalInSandbox(expr, sb);
  21. ok(false, "Should have thrown: " + expr);
  22. } catch (e) {
  23. ok(/denied|insecure/.test(e), "should get security exception: " + e);
  24. }
  25. }
  26. checkThrows('win.top');
  27. checkThrows('loc.replace');
  28. </script>
  29. </head>
  30. <body>
  31. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1126911">Mozilla Bug 1126911</a>
  32. <p id="display"></p>
  33. <div id="content" style="display: none">
  34. </div>
  35. <pre id="test">
  36. </pre>
  37. </body>
  38. </html>