summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/noExecute-04.js
blob: 628a425bad7665f48efd9315cc4e19540327a263 (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
// Tests that NX works through the enabled toggle and adding/removing the
// global.

load(libdir + "asserts.js");
load(libdir + "debuggerNXHelper.js");

var g = newGlobal({newCompartment: true});
var dbg = new Debugger(g);

g.eval(`
       function f() { }
       var o = {
         get p() { },
         set p(x) { }
       };
       `);

var handlers = [() => { g.f(); },
                () => { g.o.p } ,
                () => { g.o.p = 42; }];

function testHookEnabled(hookName, trigger) {
  for (var h of handlers) {
    assertThrowsInstanceOf(h, Debugger.DebuggeeWouldRun);
  }
}

function testHookRemoval(hookName, trigger) {
  for (var h of handlers) {
    assertThrowsInstanceOf(h, Debugger.DebuggeeWouldRun);
    dbg.removeDebuggee(g);
    h();
    dbg.addDebuggee(g);
    assertThrowsInstanceOf(h, Debugger.DebuggeeWouldRun);
  }
}

testDebuggerHooksNX(dbg, g, testHookEnabled);
testDebuggerHooksNX(dbg, g, testHookRemoval);