1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/chrome/test_exnstack.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=735544 1.9 +--> 1.10 +<window title="Mozilla Bug 735544" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + 1.14 + <!-- test results are displayed in the html:body --> 1.15 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=735544" 1.17 + target="_blank">Mozilla Bug 735544</a> 1.18 + <iframe id='ifr0' onload="frameDone(0);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" /> 1.19 + <iframe id='ifr1' onload="frameDone(1);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" /> 1.20 + </body> 1.21 + 1.22 + <!-- test code goes here --> 1.23 + <script type="application/javascript"> 1.24 + <![CDATA[ 1.25 + /** Test for Bug 735544 - Allow exception stacks to cross compartment boundaries **/ 1.26 + 1.27 + SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 + var gFramesDone = [false, false]; 1.30 + function frameDone(idx) { 1.31 + gFramesDone[idx] = true; 1.32 + if (gFramesDone[0] && gFramesDone[1]) 1.33 + startTest(); 1.34 + } 1.35 + 1.36 + function throwAsChrome() { 1.37 + 1.38 + // Grab the iframe content windows. 1.39 + var cwin0 = document.getElementById('ifr0').contentWindow; 1.40 + var cwin1 = document.getElementById('ifr1').contentWindow; 1.41 + 1.42 + // Have cwin0 call a function on cwin1 that throws. 1.43 + cwin0.wrappedJSObject.doThrow(cwin1); 1.44 + } 1.45 + 1.46 + function startTest() { 1.47 + 1.48 + try { 1.49 + throwAsChrome(); 1.50 + ok(false, "should throw"); 1.51 + } catch (e) { 1.52 + 1.53 + stackFrames = e.stack.split("\n"); 1.54 + 1.55 + ok(/throwAsInner/.exec(stackFrames[0]), 1.56 + "The bottom frame should be thrown by the inner"); 1.57 + 1.58 + ok(/throwAsOuter/.exec(stackFrames[2]), 1.59 + "The 3rd-from-bottom frame should be thrown by the other"); 1.60 + 1.61 + ok(!/throwAsChrome/.exec(e.stack), 1.62 + "The entire stack should not cross into chrome."); 1.63 + } 1.64 + 1.65 + SimpleTest.finish(); 1.66 + } 1.67 + 1.68 + ]]> 1.69 + </script> 1.70 + 1.71 +</window>