test_bug801241.xul 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
  3. <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
  4. <!--
  5. https://bugzilla.mozilla.org/show_bug.cgi?id=801241
  6. -->
  7. <window title="Mozilla Bug 801241"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  10. <!-- test results are displayed in the html:body -->
  11. <body xmlns="http://www.w3.org/1999/xhtml">
  12. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=801241"
  13. target="_blank">Mozilla Bug 801241</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for Bug 801241 **/
  19. SimpleTest.waitForExplicitFinish();
  20. const Cu = Components.utils;
  21. // This is decompiled and run inside the sandbox;
  22. function sbCode() {
  23. try {
  24. win.location = win.location;
  25. ok(true, "Didn't throw setting from location");
  26. } catch (e) {
  27. ok(false, "Threw setting location from sandbox");
  28. }
  29. }
  30. function go() {
  31. document.getElementById('ifr').onload = null;
  32. var sb = new Cu.Sandbox(this);
  33. sb.win = document.getElementById('ifr').contentWindow;
  34. sb.ok = ok;
  35. Cu.evalInSandbox('(' + sbCode.toSource() + ')()', sb);
  36. SimpleTest.finish();
  37. }
  38. ]]>
  39. </script>
  40. <iframe id="ifr" onload="go();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  41. </window>