test_bug965082.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=965082
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 965082</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. <script type="application/javascript">
  12. /** Test for Bug 965082 **/
  13. SimpleTest.waitForExplicitFinish();
  14. function checkThrows(f, msg) {
  15. try { f(); ok(false, "Should have thrown: " + msg); }
  16. catch (e) { ok(/denied|insecure/.test(e), "Should throw security exception: " + e + " (" + msg + ")"); }
  17. }
  18. function go() {
  19. var protoSetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  20. checkThrows(function() { protoSetter.call(window[0], new Object()); }, "Setting cross-origin Window prototype");
  21. checkThrows(function() { protoSetter.call(window[0].location, new Object()); }, "Setting cross-origin Location prototype");
  22. SimpleTest.finish();
  23. }
  24. </script>
  25. </head>
  26. <body>
  27. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=965082">Mozilla Bug 965082</a>
  28. <p id="display"></p>
  29. <div id="content" style="display: none">
  30. </div>
  31. <iframe id="ifr" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
  32. <pre id="test">
  33. </pre>
  34. </body>
  35. </html>