summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-setProperty-02.js
blob: 42b61f8190ce77190c9313b08ff01c35867627a0 (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
32
33
34
35
36
// tests calling script functions via Debugger.Object.prototype.setProperty
// to see if they trigger debugger traps
"use strict";

var global = newGlobal({newCompartment: true});
var dbg = new Debugger(global);
dbg.onDebuggerStatement = onDebuggerStatement;

let obj;
global.eval(`
const obj = {
    set prop(val) {
        debugger;
        this._prop = val;
    }
};

debugger;
`);


function onDebuggerStatement(frame) {
    dbg.onDebuggerStatement = onDebuggerStatementGetter;

    obj = frame.environment.getVariable("obj");
}

let debuggerRan = false;

assertEq(obj.setProperty("prop", 42).return, true);
assertEq(obj.getProperty("_prop").return, 42);
assertEq(debuggerRan, true);

function onDebuggerStatementGetter(frame) {
    debuggerRan = true;
}