js/src/jit-test/tests/debug/Object-evalInGlobal-05.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Object-evalInGlobal-05.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,22 @@
     1.4 +// Debugger.Object.prototype.evalInGlobal throws when asked to evaluate in a CCW of a global.
     1.5 +
     1.6 +load(libdir + 'asserts.js');
     1.7 +
     1.8 +var dbg = new Debugger();
     1.9 +
    1.10 +var g1 = newGlobal();
    1.11 +var dg1 = dbg.addDebuggee(g1);
    1.12 +
    1.13 +var g2 = newGlobal();
    1.14 +var dg2 = dbg.addDebuggee(g2);
    1.15 +
    1.16 +// Generate a Debugger.Object viewing g2 from g1's compartment.
    1.17 +var dg1wg2 = dg1.makeDebuggeeValue(g2);
    1.18 +assertEq(dg1wg2.global, dg1);
    1.19 +assertEq(dg1wg2.unwrap(), dg2);
    1.20 +assertThrowsInstanceOf(function () { dg1wg2.evalInGlobal('1'); }, TypeError);
    1.21 +assertThrowsInstanceOf(function () { dg1wg2.evalInGlobalWithBindings('x', { x: 1 }); }, TypeError);
    1.22 +
    1.23 +// These, however, should not throw.
    1.24 +assertEq(dg1wg2.unwrap().evalInGlobal('1729').return, 1729);
    1.25 +assertEq(dg1wg2.unwrap().evalInGlobalWithBindings('x', { x: 1729 }).return, 1729);

mercurial