diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/debug/Source-introductionScript-01.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/Source-introductionScript-01.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Source-introductionScript-01.js | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Source-introductionScript-01.js b/js/src/jit-test/tests/debug/Source-introductionScript-01.js new file mode 100644 index 0000000000..29dfeb0c83 --- /dev/null +++ b/js/src/jit-test/tests/debug/Source-introductionScript-01.js @@ -0,0 +1,118 @@ +// Dynamically generated sources should have their introduction script and +// offset set correctly. + +var g = newGlobal({newCompartment: true}); +var dbg = new Debugger; +var gDO = dbg.addDebuggee(g); +var log; + +// Direct eval, while the frame is live. +dbg.onDebuggerStatement = function (frame) { + log += 'd'; + var source = frame.script.source; + var introducer = frame.older; + assertEq(source.introductionScript, introducer.script); + assertEq(source.introductionOffset, introducer.offset); +}; +log = ''; +g.eval('\n\neval("\\n\\ndebugger;");'); +assertEq(log, 'd'); + +// Direct eval, after the frame has been popped. +var introducer, introduced; +dbg.onDebuggerStatement = function (frame) { + log += 'de1'; + introducer = frame.script; + dbg.onDebuggerStatement = function (frame) { + log += 'de2'; + introduced = frame.script.source; + }; +}; +log = ''; +g.evaluate('debugger; eval("\\n\\ndebugger;");', { lineNumber: 1812 }); +assertEq(log, 'de1de2'); +assertEq(introduced.introductionScript, introducer); +assertEq(introducer.getOffsetLocation(introduced.introductionOffset).lineNumber, 1812); + +// Indirect eval, while the frame is live. +dbg.onDebuggerStatement = function (frame) { + log += 'd'; + var source = frame.script.source; + var introducer = frame.older; + assertEq(source.introductionScript, introducer.script); + assertEq(source.introductionOffset, introducer.offset); +}; +log = ''; +g.eval('\n\n(0,eval)("\\n\\ndebugger;");'); +assertEq(log, 'd'); + +// Indirect eval, after the frame has been popped. +var introducer, introduced; +dbg.onDebuggerStatement = function (frame) { + log += 'de1'; + introducer = frame.script; + dbg.onDebuggerStatement = function (frame) { + log += 'de2'; + introduced = frame.script.source; + }; +}; +log = ''; +g.evaluate('debugger; (0,eval)("\\n\\ndebugger;");', { lineNumber: 1066 }); +assertEq(log, 'de1de2'); +assertEq(introduced.introductionScript, introducer); +assertEq(introducer.getOffsetLocation(introduced.introductionOffset).lineNumber, 1066); + +// Function constructor. +dbg.onDebuggerStatement = function (frame) { + log += 'o'; + var outerScript = frame.script; + var outerOffset = frame.offset; + dbg.onDebuggerStatement = function (frame) { + log += 'i'; + var source = frame.script.source; + assertEq(source.introductionScript, outerScript); + assertEq(outerScript.getOffsetLocation(source.introductionOffset).lineNumber, + outerScript.getOffsetLocation(outerOffset).lineNumber); + }; +}; +log = ''; +g.eval('\n\n\ndebugger; Function("debugger;")()'); +assertEq(log, 'oi'); + +// Function constructor, after the the introduction call's frame has been +// popped. +var introducer; +dbg.onDebuggerStatement = function (frame) { + log += 'F2'; + introducer = frame.script; +}; +log = ''; +var fDO = gDO.executeInGlobal('debugger; Function("origami;")', { lineNumber: 1685 }).return; +var source = fDO.script.source; +assertEq(log, 'F2'); +assertEq(source.introductionScript, introducer); +assertEq(introducer.getOffsetLocation(source.introductionOffset).lineNumber, 1685); + +// If the introduction script is in a different global from the script it +// introduced, we don't record it. +dbg.onDebuggerStatement = function (frame) { + log += 'x'; + var source = frame.script.source; + assertEq(source.introductionScript, undefined); + assertEq(source.introductionOffset, undefined); +}; +log = ''; +g.eval('debugger;'); // introduction script is this top-level script +assertEq(log, 'x'); + +// If the code is introduced by a function that doesn't provide +// introduction information, that shouldn't be a problem. +dbg.onDebuggerStatement = function (frame) { + log += 'x'; + var source = frame.script.source; + assertEq(source.introductionScript, undefined); + assertEq(source.introductionOffset, undefined); +}; +log = ''; +g.eval('evaluate("debugger;", { lineNumber: 1729 });'); +assertEq(log, 'x'); |