js/src/jit-test/tests/debug/onExceptionUnwind-03.js

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 // |jit-test| debug
     2 // The onExceptionUnwind hook is called multiple times as the stack unwinds.
     4 var g = newGlobal();
     5 g.debuggeeGlobal = this;
     6 g.dbg = null;
     7 g.eval("(" + function () {
     8         dbg = new Debugger(debuggeeGlobal);
     9         dbg.onExceptionUnwind = function (frame, exc) {
    10             assertEq(frame instanceof Debugger.Frame, true);
    11             assertEq(exc instanceof Debugger.Object, true);
    12             var s = '!';
    13             for (var f = frame; f; f = f.older)
    14                 if (f.type === "call")
    15                     s += f.callee.name;
    16             s += ', ';
    17             debuggeeGlobal.log += s;
    18         };
    19     } + ")();");
    21 var log;
    23 function k() {
    24     try {
    25         throw new Error("oops");  // hook call 1
    26     } finally {
    27         log += 'k-finally, ';
    28     } // hook call 2
    29 }
    31 function j() {
    32     k();  // hook call 3
    33     log += 'j-unreached, ';
    34 }
    36 function h() {
    37     try {
    38         j();  // hook call 4
    39         log += 'h-unreached, ';
    40     } catch (exc) {
    41         log += 'h-catch, ';
    42         throw exc; // hook call 5
    43     }
    44 }
    46 function f() {
    47     try {
    48         h(); // hook call 6
    49     } catch (exc) {
    50         log += 'f-catch, ';
    51     }
    52     log += 'f-after, ';
    53 }
    55 log = '';
    56 f();
    57 g.dbg.enabled = false;
    58 assertEq(log, '!kjhf, k-finally, !kjhf, !jhf, !hf, h-catch, !hf, !f, f-catch, f-after, ');

mercurial