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/Object-errorLineNumber-errorColumnNumber.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/Object-errorLineNumber-errorColumnNumber.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Object-errorLineNumber-errorColumnNumber.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-errorLineNumber-errorColumnNumber.js b/js/src/jit-test/tests/debug/Object-errorLineNumber-errorColumnNumber.js new file mode 100644 index 0000000000..a581f93b6e --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-errorLineNumber-errorColumnNumber.js @@ -0,0 +1,55 @@ +// Debugger.Object.prototype.{errorLineNumber,errorColumnNumber} return the +// line number and column number associated with some error object. + +var g = newGlobal({newCompartment: true}); +var dbg = new Debugger(); +var gw = dbg.addDebuggee(g); + +var syntaxError = gw.executeInGlobal("\nlet a, a;").throw; +assertEq(syntaxError.errorLineNumber, 2); +assertEq(syntaxError.errorColumnNumber, 7); + +var typeError = gw.executeInGlobal("\n1 + f();").throw; +assertEq(typeError.errorLineNumber, 2); +assertEq(typeError.errorColumnNumber, 1); + +// Custom errors have no line/column numbers . +var customError = gw.executeInGlobal("\nthrow 1;").throw; +assertEq(customError.errorLineNumber, undefined); +assertEq(customError.errorColumnNumber, undefined); + +customError = gw.executeInGlobal("\nthrow { errorLineNumber: 10, errorColumnNumber: 20 };").throw; +assertEq(customError.errorLineNumber, undefined); +assertEq(customError.errorColumnNumber, undefined); + +customError = gw.executeInGlobal("\nthrow { lineNumber: 10, columnNumber: 20 };").throw; +assertEq(customError.errorLineNumber, undefined); +assertEq(customError.errorColumnNumber, undefined); + +// Ensure that the method works across globals. +g.eval(`var g = newGlobal({newCompartment: true}); + g.eval('var err; \\n' + + 'try {\\n' + + ' f();\\n' + + '} catch (e) {\\n' + + ' err = e;\\n' + + '}'); + var err2 = g.err;`); +var otherGlobalError = gw.executeInGlobal("throw err2").throw; +assertEq(otherGlobalError.errorLineNumber, 3); +assertEq(otherGlobalError.errorColumnNumber, 3); + +// Ensure that non-error objects return undefined. +const Args = [ + "1", + "'blah'", + "({})", + "[]", + "() => 1" +] + +for (let arg of Args) { + let nonError = gw.executeInGlobal(`${arg}`).return; + assertEq(nonError.errorLineNumber, undefined); + assertEq(nonError.errorColumnNumber, undefined); +} |