tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Script-getLineOffsets-08.js (697B)


      1 // A "while" or a "for" loop should have a single entry point.
      2 
      3 var g = newGlobal({newCompartment: true});
      4 var dbg = new Debugger(g);
      5 
      6 dbg.onDebuggerStatement = function(frame) {
      7  var s = frame.eval('f').return.script;
      8 
      9  // There should be just a single entry point for the first line of
     10  // the function.  See below to understand the "+2".
     11  assertEq(s.getLineOffsets(g.line0 + 2).length, 1);
     12 };
     13 
     14 
     15 function test(code) {
     16  g.eval('var line0 = Error().lineNumber;\n' +
     17         'function f() {\n' +   // line0 + 1
     18         code + '\n' +          // line0 + 2 -- see above
     19         '}\n' +
     20         'debugger;');
     21 }
     22 
     23 test('while (false)\n;');
     24 test('for (;false;)\n;');
     25 test('for (;;) break;\n;');