js/src/jit-test/tests/debug/Frame-arguments-06.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 // Test extracting frame.arguments element getters and calling them in
     2 // various awkward ways.
     4 load(libdir + "asserts.js");
     6 var g = newGlobal();
     7 var dbg = Debugger(g);
     8 var hits = 0;
     9 var fframe, farguments, fgetter;
    10 dbg.onDebuggerStatement = function (frame) {
    11     if (hits === 0) {
    12         fframe = frame;
    13         farguments = frame.arguments;
    14         fgetter = Object.getOwnPropertyDescriptor(farguments, "0").get;
    15         assertEq(fgetter instanceof Function, true);
    17         // Calling the getter without an appropriate this-object
    18         // fails, but shouldn't assert or crash.
    19         assertThrowsInstanceOf(function () { fgetter.call(Math); }, TypeError);
    20     } else {
    21         // Since fframe is still on the stack, fgetter can be applied to it.
    22         assertEq(fframe.live, true);
    23         assertEq(fgetter.call(farguments), 100);
    25         // Since h was called without arguments, there is no argument 0.
    26         assertEq(fgetter.call(frame.arguments), undefined);
    27     }
    28     hits++;
    29 };
    31 g.eval("function h() { debugger; }");
    32 g.eval("function f(x) { debugger; h(); }");
    33 g.f(100);
    34 assertEq(hits, 2);
    36 // Now that fframe is no longer live, trying to get its arguments should throw.
    37 assertEq(fframe.live, false);
    38 assertThrowsInstanceOf(function () { fgetter.call(farguments); }, Error);

mercurial