summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/noExecute-05.js
blob: 3bbed222635c5702ff6a5753ad04268e475a1197 (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
// Tests that NX disallows debuggee execution for all debuggees.

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

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

dbg.addDebuggee(g1);
dbg.addDebuggee(g2);

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

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

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

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

testDebuggerHooksNX(dbg, g1, testHook);
testDebuggerHooksNX(dbg, g2, testHook);