js/xpconnect/tests/chrome/test_exnstack.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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"/>
    11   <!-- test results are displayed in the html:body -->
    12   <body xmlns="http://www.w3.org/1999/xhtml">
    13   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=735544"
    14      target="_blank">Mozilla Bug 735544</a>
    15  <iframe id='ifr0' onload="frameDone(0);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" />
    16  <iframe id='ifr1' onload="frameDone(1);" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_exnstack.html" />
    17   </body>
    19   <!-- test code goes here -->
    20   <script type="application/javascript">
    21   <![CDATA[
    22   /** Test for Bug 735544 - Allow exception stacks to cross compartment boundaries **/
    24   SimpleTest.waitForExplicitFinish();
    26   var gFramesDone = [false, false];
    27   function frameDone(idx) {
    28     gFramesDone[idx] = true;
    29     if (gFramesDone[0] && gFramesDone[1])
    30       startTest();
    31   }
    33   function throwAsChrome() {
    35     // Grab the iframe content windows.
    36     var cwin0 = document.getElementById('ifr0').contentWindow;
    37     var cwin1 = document.getElementById('ifr1').contentWindow;
    39     // Have cwin0 call a function on cwin1 that throws.
    40     cwin0.wrappedJSObject.doThrow(cwin1);
    41   }
    43   function startTest() {
    45     try {
    46       throwAsChrome();
    47       ok(false, "should throw");
    48     } catch (e) {
    50       stackFrames = e.stack.split("\n");
    52       ok(/throwAsInner/.exec(stackFrames[0]),
    53          "The bottom frame should be thrown by the inner");
    55       ok(/throwAsOuter/.exec(stackFrames[2]),
    56          "The 3rd-from-bottom frame should be thrown by the other");
    58       ok(!/throwAsChrome/.exec(e.stack),
    59          "The entire stack should not cross into chrome.");
    60     }
    62     SimpleTest.finish();
    63   }
    65   ]]>
    66   </script>
    68 </window>

mercurial