summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Environment-methods-toPrimitive.js
blob: 106728901d24598aeb8f4586c8d3dcbd508b0f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// removeDebuggee can be called through ToPrimitive while converting the argument
// passed to Debugger.Environment.{find,getVariable,setVariable} to string.

var g = newGlobal({newCompartment: true});
g.eval("function f() { debugger; }");
var dbg = new Debugger();
var oddball = {[Symbol.toPrimitive]: () => dbg.removeDebuggee(g)};

for (var method of ["find", "getVariable", "setVariable"]) {
  dbg.addDebuggee(g);
  dbg.onDebuggerStatement = frame => {
    var ex;
    try {
      frame.environment[method](oddball, oddball);
    } catch (e) {
      ex = e;
    }
    assertEq(ex.message, "Debugger.Environment is not a debuggee environment");
  };
  g.f();
}