Debugger-findScripts-uncompleted-02.js (1242B)
1 // Uncompleted scripts shouldn't be found in findScripts. 2 3 let g = newGlobal({newCompartment: true}); 4 let dbg = new Debugger(g); 5 6 let message = ""; 7 try { 8 g.eval(` 9 (function nonLazyOuter() { 10 (function nonLazyInner() { 11 function lazy1() { 12 function lazy2() { 13 } 14 } 15 })(); 16 })(); 17 18 (function uncompletedNonLazy() { 19 (function completedNonLazy() { 20 function lazyInCompleted1() { 21 function lazyInCompleted2() { 22 } 23 } 24 })(); 25 // completedNonLazy and its inner scripts can be exposed to debugger since 26 // the compilation for completedNonLazy finishes, even if the enclosing 27 // uncompletedNonLazy fails to compile. 28 switch (1) { 29 ${"case 1:".repeat(2**16+1)} 30 } 31 })(); 32 `); 33 } catch (e) { 34 message = e.message; 35 } 36 37 assertEq(message.includes("too many switch cases"), true, 38 "Error for switch-case should be thrown," + 39 "in order to test the case that uncompleted script is created"); 40 41 let actualNames = []; 42 for (var script of dbg.findScripts()) { 43 // Since all of above scripts can be GCed, we cannot check the set of 44 // found scripts. 45 if (script.displayName) { 46 assertEq(script.displayName != "uncompletedNonLazy", true, 47 "Uncompiled script shouldn't be found"); 48 } 49 }