test_exnstack.xul 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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=735544
  6. -->
  7. <window title="Mozilla Bug 735544"
  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=735544"
  13. target="_blank">Mozilla Bug 735544</a>
  14. <iframe id='ifr0' onload="frameDone(0);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" />
  15. <iframe id='ifr1' onload="frameDone(1);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" />
  16. </body>
  17. <!-- test code goes here -->
  18. <script type="application/javascript">
  19. <![CDATA[
  20. /** Test for Bug 735544 - Allow exception stacks to cross compartment boundaries **/
  21. SimpleTest.waitForExplicitFinish();
  22. var gFramesDone = [false, false];
  23. function frameDone(idx) {
  24. gFramesDone[idx] = true;
  25. if (gFramesDone[0] && gFramesDone[1])
  26. startTest();
  27. }
  28. function throwAsChrome() {
  29. // Grab the iframe content windows.
  30. var cwin0 = document.getElementById('ifr0').contentWindow;
  31. var cwin1 = document.getElementById('ifr1').contentWindow;
  32. // Have cwin0 call a function on cwin1 that throws.
  33. cwin0.wrappedJSObject.doThrow(cwin1);
  34. }
  35. function startTest() {
  36. try {
  37. throwAsChrome();
  38. ok(false, "should throw");
  39. } catch (e) {
  40. stackFrames = e.stack.split("\n");
  41. ok(/throwAsInner/.exec(stackFrames[0]),
  42. "The bottom frame should be thrown by the inner");
  43. ok(/throwAsOuter/.exec(stackFrames[2]),
  44. "The 3rd-from-bottom frame should be thrown by the other");
  45. ok(!/throwAsChrome/.exec(e.stack),
  46. "The entire stack should not cross into chrome.");
  47. }
  48. SimpleTest.finish();
  49. }
  50. ]]>
  51. </script>
  52. </window>