summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/xdr/delazify-findScript-lineCount.js
blob: 7846f1128b4558834f7571b88746bf78bc22c41c (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
function testDelazify(i) {
  var g = newGlobal({ newCompartment: true });
  var dbg = new Debugger(g);

  dbg.onDebuggerStatement = (frame) => {
    var allScripts = dbg.findScripts();
    var j = 0;
    for (let script of allScripts) {
      if (i == -1 || i == j) {
        // Delazify.
        try {
          script.lineCount;
        } catch (e) {
        }
      }
      j++;
    }
  };

  var cache = cacheEntry(`
function f(
  a = (
    b = (
      c = function g() {
      },
    ) => {
    },
    d = (
      e = (
        f = (
        ) => {
        },
      ) => {
      },
    ) => {
    },
  ) => {
  },
) {
}
debugger;
`);

  evaluate(cache, { global: g, saveIncrementalBytecode: true });
  evaluate(cache, { global: g, loadBytecode: true });
}

// Delazify all.
testDelazify(-1);

// Delazify specific function and its ancestor.
for (var i = 0; i < 30; i++) {
  testDelazify(i);
}