js/src/jit-test/tests/debug/Environment-nondebuggee.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.

michael@0 1 // Using an environment that is not a debuggee should throw.
michael@0 2
michael@0 3 load(libdir + 'asserts.js');
michael@0 4
michael@0 5 var g = newGlobal();
michael@0 6 var dbg = new Debugger;
michael@0 7 let gw = dbg.addDebuggee(g);
michael@0 8 var log;
michael@0 9
michael@0 10 function check(env) {
michael@0 11 assertEq(env.inspectable, false);
michael@0 12 assertThrowsInstanceOf(() => env.type, Error);
michael@0 13 assertThrowsInstanceOf(() => env.object, Error);
michael@0 14 assertThrowsInstanceOf(() => env.parent, Error);
michael@0 15 assertThrowsInstanceOf(() => env.callee, Error);
michael@0 16
michael@0 17 assertThrowsInstanceOf(() => env.names(), Error);
michael@0 18 assertThrowsInstanceOf(() => env.find('x'), Error);
michael@0 19 assertThrowsInstanceOf(() => env.getVariable('x'), Error);
michael@0 20 assertThrowsInstanceOf(() => env.setVariable('x'), Error);
michael@0 21 }
michael@0 22
michael@0 23 dbg.onDebuggerStatement = function (frame) {
michael@0 24 log += 'd';
michael@0 25
michael@0 26 let env = frame.environment;
michael@0 27 dbg.removeDebuggee(g);
michael@0 28 check(env);
michael@0 29 }
michael@0 30
michael@0 31 log = '';
michael@0 32 g.eval('let x = 42; debugger;');
michael@0 33 assertEq(log, 'd');
michael@0 34
michael@0 35 dbg.addDebuggee(g);
michael@0 36 g.eval('function f() { }');
michael@0 37 let env = gw.getOwnPropertyDescriptor('f').value.environment;
michael@0 38 assertEq(env.type, 'object');
michael@0 39 dbg.removeDebuggee(g);
michael@0 40 check(env);

mercurial