summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js
blob: 62d6693d4ec8b1db7157451a251d14a215f2e0b8 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Test shouldAvoidSideEffects flag.

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

gdbg.executeInGlobal(`
var obj, result, reachedNextLine;
`);

dbg.shouldAvoidSideEffects = false;
assertEq(dbg.shouldAvoidSideEffects, false);

let result = gdbg.executeInGlobal(`
result = undefined;
reachedNextLine = false;

obj = createSideEffectfulResolveObject();
result = obj.test;
reachedNextLine = true;
"finished";
`);
assertEq(g.result, 42);
assertEq(g.reachedNextLine, true);
assertEq(result.return, "finished");

dbg.shouldAvoidSideEffects = true;
assertEq(dbg.shouldAvoidSideEffects, true);

result = gdbg.executeInGlobal(`
result = undefined;
reachedNextLine = false;

obj = createSideEffectfulResolveObject();
result = obj.test;
reachedNextLine = true;
"finished";
`);
assertEq(g.result, undefined);
assertEq(g.reachedNextLine, false);
assertEq(result, null);

// Resolve after abort.
dbg.shouldAvoidSideEffects = false;
assertEq(dbg.shouldAvoidSideEffects, false);

result = gdbg.executeInGlobal(`
result = undefined;
reachedNextLine = false;

result = obj.test;
reachedNextLine = true;
"finished";
`);
assertEq(g.result, 42);
assertEq(g.reachedNextLine, true);
assertEq(result.return, "finished");