Debian Codegraph @

js/src/jit-test/tests/debug/Source-introductionType.js

raw
1 // |jit-test| skip-if: helperThreadCount() === 0
2
3 // Check that scripts' introduction types are properly marked.
4
5 var g = newGlobal({newCompartment: true});
6 var dbg = new Debugger();
7 var gDO = dbg.addDebuggee(g);
8 var log;
9
10 // (Indirect) eval.
11 dbg.onDebuggerStatement = function (frame) {
12 log += 'd';
13 assertEq(frame.script.source.introductionType, 'eval');
14 };
15 log = '';
16 g.eval('debugger;');
17 assertEq(log, 'd');
18
19 // Function constructor.
20 dbg.onDebuggerStatement = function (frame) {
21 log += 'd';
22 assertEq(frame.script.source.introductionType, 'Function');
23 };
24 log = '';
25 g.Function('debugger;')();
26 assertEq(log, 'd');
27
28 // GeneratorFunction constructor.
29 dbg.onDebuggerStatement = function (frame) {
30 log += 'd';
31 assertEq(frame.script.source.introductionType, 'GeneratorFunction');
32 };
33 log = '';
34 g.eval('(function*() {})').constructor('debugger;')().next();
35 assertEq(log, 'd');
36
37 // Shell 'evaluate' function
38 dbg.onDebuggerStatement = function (frame) {
39 log += 'd';
40 assertEq(frame.script.source.introductionType, "js shell evaluate");
41 };
42 log = '';
43 g.evaluate('debugger;');
44 assertEq(log, 'd');
45
46 // Shell 'load' function
47 dbg.onDebuggerStatement = function (frame) {
48 log += 'd';
49 assertEq(frame.script.source.introductionType, "js shell load");
50 };
51 log = '';
52 g.load(scriptdir + 'Source-introductionType-data');
53 assertEq(log, 'd');
54
55 // Shell 'run' function
56 dbg.onDebuggerStatement = function (frame) {
57 log += 'd';
58 assertEq(frame.script.source.introductionType, "js shell run");
59 };
60 log = '';
61 g.run(scriptdir + 'Source-introductionType-data');
62 assertEq(log, 'd');
63
64 // Shell 'offThreadCompileToStencil' function.
65 dbg.onDebuggerStatement = function (frame) {
66 log += 'd';
67 assertEq(frame.script.source.introductionType,
68 "js shell offThreadCompileToStencil");
69 };
70 log = '';
71 g.offThreadCompileToStencil('debugger;');
72 var stencil = g.finishOffThreadStencil();
73 g.evalStencil(stencil);
74 assertEq(log, 'd');
75
76 // Debugger.Frame.prototype.eval
77 dbg.onDebuggerStatement = function (frame) {
78 log += 'o';
79 dbg.onDebuggerStatement = innerHandler;
80 frame.eval('debugger');
81 function innerHandler(frame) {
82 log += 'i';
83 assertEq(frame.script.source.introductionType, "debugger eval");
84 }
85 };
86 log = '';
87 g.eval('debugger;');
88 assertEq(log, 'oi');
89
90 // Debugger.Frame.prototype.evalWithBindings
91 dbg.onDebuggerStatement = function (frame) {
92 log += 'o';
93 dbg.onDebuggerStatement = innerHandler;
94 frame.evalWithBindings('debugger', { x: 42 });
95 function innerHandler(frame) {
96 log += 'i';
97 assertEq(frame.script.source.introductionType, "debugger eval");
98 }
99 };
100 log = '';
101 g.eval('debugger;');
102 assertEq(log, 'oi');
103
104 // Debugger.Object.executeInGlobal
105 dbg.onDebuggerStatement = function (frame) {
106 log += 'd';
107 assertEq(frame.script.source.introductionType, "debugger eval");
108 };
109 log = '';
110 gDO.executeInGlobal('debugger;');
111 assertEq(log, 'd');
112
113 // Debugger.Object.executeInGlobalWithBindings
114 dbg.onDebuggerStatement = function (frame) {
115 log += 'd';
116 assertEq(frame.script.source.introductionType, "debugger eval");
117 };
118 log = '';
119 gDO.executeInGlobalWithBindings('debugger;', { x: 42 });
120 assertEq(log, 'd');
121