test_bug996069.xul 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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=996069
  6. -->
  7. <window title="Mozilla Bug 996069"
  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=996069"
  13. target="_blank">Mozilla Bug 996069</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. const Cu = Components.utils;
  19. /** Test for Bug 996069 **/
  20. SimpleTest.waitForExplicitFinish();
  21. function loaded() {
  22. var ifr = document.getElementById("ifr").contentWindow;
  23. var sb = new Cu.Sandbox([ifr],
  24. { sandboxPrototype: ifr });
  25. ifr.wrappedJSObject.finishTest = function() {
  26. // If we got here we did not hit the NS_ReleaseAssert...
  27. ok(true, "nsExpandedPrincipal should not be inherited by content windows");
  28. // But let's be sure that the new window does not have nsEP
  29. newWin.wrappedJSObject.obj = Cu.evalInSandbox("var obj = { foo: 'bar' }; obj", sb);
  30. try {
  31. newWin.eval("obj.foo");
  32. ok(false, "newWin should not have access to object from a scope with nsExpandedPrincipal");
  33. } catch (e) {
  34. ok(/Permission denied/.exec(e.message), "newWin should not have access to object from a scope with nsExpandedPrincipal");
  35. }
  36. newWin.close();
  37. SimpleTest.finish();
  38. };
  39. var newWin = Cu.evalInSandbox(
  40. "window.open('http://example.org/chrome/js/xpconnect/tests/chrome/file_bug996069.html');",
  41. sb);
  42. }
  43. ]]>
  44. </script>
  45. <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/chrome/js/xpconnect/tests/chrome/file_bug996069.html" />
  46. </window>