test_bug866823.xul 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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=866823
  6. -->
  7. <window title="Mozilla Bug 866823"
  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=866823"
  13. target="_blank">Mozilla Bug 866823</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for Bug 866823 **/
  19. SimpleTest.waitForExplicitFinish();
  20. const Cu = Components.utils;
  21. function go() {
  22. var iwin = $('ifr').contentWindow;
  23. // Make sure that Xray waivers can't be transitively extended onto objects
  24. // for whom the extender may not waive.
  25. var sb = new Cu.Sandbox(iwin, { wantXrays: true });
  26. sb.iwin = iwin;
  27. ok(Cu.evalInSandbox('iwin.wrappedJSObject.top == iwin.top', sb), "Waiver does not propagate");
  28. Cu.evalInSandbox('iwin.wrappedJSObject.waiver = iwin.wrappedJSObject', sb);
  29. ok(iwin.wrappedJSObject.eval('waiver == window'), "Waivers disappear same-compartment");
  30. // Make sure that standard prototypes don't get COWs.
  31. sb.objProto = Object.prototype;
  32. try {
  33. sb.eval('objProto.toString;', sb);
  34. ok(false, "Should have thrown");
  35. } catch (e) {
  36. ok(/denied|insecure/, "No silent failure when accessing properties on forbidden prototype");
  37. }
  38. SimpleTest.finish();
  39. }
  40. ]]>
  41. </script>
  42. <iframe id="ifr" onload="go();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  43. </window>