michael@0: // Dynamically generated sources should have their introduction script and michael@0: // offset set correctly. michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger; michael@0: var gDO = dbg.addDebuggee(g); michael@0: var log; michael@0: michael@0: // Direct eval, while the frame is live. michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'd'; michael@0: var source = frame.script.source; michael@0: var introducer = frame.older; michael@0: assertEq(source.introductionScript, introducer.script); michael@0: assertEq(source.introductionOffset, introducer.offset); michael@0: }; michael@0: log = ''; michael@0: g.eval('\n\neval("\\n\\ndebugger;");'); michael@0: assertEq(log, 'd'); michael@0: michael@0: // Direct eval, after the frame has been popped. michael@0: var introducer, introduced; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'de1'; michael@0: introducer = frame.script; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'de2'; michael@0: introduced = frame.script.source; michael@0: }; michael@0: }; michael@0: log = ''; michael@0: g.evaluate('debugger; eval("\\n\\ndebugger;");', { lineNumber: 1812 }); michael@0: assertEq(log, 'de1de2'); michael@0: assertEq(introduced.introductionScript, introducer); michael@0: assertEq(introducer.getOffsetLine(introduced.introductionOffset), 1812); michael@0: michael@0: // Indirect eval, while the frame is live. michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'd'; michael@0: var source = frame.script.source; michael@0: var introducer = frame.older; michael@0: assertEq(source.introductionScript, introducer.script); michael@0: assertEq(source.introductionOffset, introducer.offset); michael@0: }; michael@0: log = ''; michael@0: g.eval('\n\n(0,eval)("\\n\\ndebugger;");'); michael@0: assertEq(log, 'd'); michael@0: michael@0: // Indirect eval, after the frame has been popped. michael@0: var introducer, introduced; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'de1'; michael@0: introducer = frame.script; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'de2'; michael@0: introduced = frame.script.source; michael@0: }; michael@0: }; michael@0: log = ''; michael@0: g.evaluate('debugger; (0,eval)("\\n\\ndebugger;");', { lineNumber: 1066 }); michael@0: assertEq(log, 'de1de2'); michael@0: assertEq(introduced.introductionScript, introducer); michael@0: assertEq(introducer.getOffsetLine(introduced.introductionOffset), 1066); michael@0: michael@0: // Function constructor. michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'o'; michael@0: var outerScript = frame.script; michael@0: var outerOffset = frame.offset; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'i'; michael@0: var source = frame.script.source; michael@0: assertEq(source.introductionScript, outerScript); michael@0: assertEq(outerScript.getOffsetLine(source.introductionOffset), michael@0: outerScript.getOffsetLine(outerOffset)); michael@0: }; michael@0: }; michael@0: log = ''; michael@0: g.eval('\n\n\ndebugger; Function("debugger;")()'); michael@0: assertEq(log, 'oi'); michael@0: michael@0: // Function constructor, after the the introduction call's frame has been michael@0: // popped. michael@0: var introducer; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'F2'; michael@0: introducer = frame.script; michael@0: }; michael@0: log = ''; michael@0: var fDO = gDO.evalInGlobal('debugger; Function("origami;")', { lineNumber: 1685 }).return; michael@0: var source = fDO.script.source; michael@0: assertEq(log, 'F2'); michael@0: assertEq(source.introductionScript, introducer); michael@0: assertEq(introducer.getOffsetLine(source.introductionOffset), 1685); michael@0: michael@0: // If the introduction script is in a different global from the script it michael@0: // introduced, we don't record it. michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'x'; michael@0: var source = frame.script.source; michael@0: assertEq(source.introductionScript, undefined); michael@0: assertEq(source.introductionOffset, undefined); michael@0: }; michael@0: log = ''; michael@0: g.eval('debugger;'); // introduction script is this top-level script michael@0: assertEq(log, 'x'); michael@0: michael@0: // If the code is introduced by a function that doesn't provide michael@0: // introduction information, that shouldn't be a problem. michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: log += 'x'; michael@0: var source = frame.script.source; michael@0: assertEq(source.introductionScript, undefined); michael@0: assertEq(source.introductionOffset, undefined); michael@0: }; michael@0: log = ''; michael@0: g.eval('evaluate("debugger;", { lineNumber: 1729 });'); michael@0: assertEq(log, 'x');