summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-this-14.js
blob: a47b203ea16a72e1b5b91700818fca1a292d0ca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Test that Debugger.Frame.prototype.this works on a suspended generator
// function.

load(libdir + "asserts.js");

const g = newGlobal({ newCompartment: true });
const dbg = new Debugger();
const gDO = dbg.addDebuggee(g);

g.eval(`
var context = {};
var f = function*() {
  return this;
}.bind(context);
`);

let frame;
dbg.onEnterFrame = f => {
  frame = f;
  assertEq(frame.this, gDO.makeDebuggeeValue(g.context));
  dbg.onEnterFrame = undefined;
};

const it = g.f();

assertEq(!!frame, true);
assertEq(frame.this, gDO.makeDebuggeeValue(g.context));

it.next();

assertThrowsInstanceOf(() => frame.this, Error);