mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 762556 - Error stack should contain column number. r=jorendorff
This commit is contained in:
parent
9910640a95
commit
a13a658926
@ -137,13 +137,16 @@ var parseStack = iced(function parseStack(stack) {
|
||||
if (line) {
|
||||
let atIndex = line.indexOf("@");
|
||||
let columnIndex = line.lastIndexOf(":");
|
||||
let fileName = sourceURI(line.slice(atIndex + 1, columnIndex));
|
||||
let lineNumber = parseInt(line.slice(columnIndex + 1));
|
||||
let lineIndex = line.lastIndexOf(":", columnIndex - 1);
|
||||
let fileName = sourceURI(line.slice(atIndex + 1, lineIndex));
|
||||
let lineNumber = parseInt(line.slice(lineIndex + 1, columnIndex));
|
||||
let columnNumber = parseInt(line.slice(columnIndex + 1));
|
||||
let name = line.slice(0, atIndex).split("(").shift();
|
||||
frames.unshift({
|
||||
fileName: fileName,
|
||||
name: name,
|
||||
lineNumber: lineNumber
|
||||
lineNumber: lineNumber,
|
||||
columnNumber: columnNumber
|
||||
});
|
||||
}
|
||||
return frames;
|
||||
@ -155,7 +158,8 @@ var serializeStack = iced(function serializeStack(frames) {
|
||||
return frames.reduce(function(stack, frame) {
|
||||
return frame.name + "@" +
|
||||
frame.fileName + ":" +
|
||||
frame.lineNumber + "\n" +
|
||||
frame.lineNumber + ":" +
|
||||
frame.columnNumber + "\n" +
|
||||
stack;
|
||||
}, "");
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ let observer = {
|
||||
reflow: function (start, end) {
|
||||
// Gather information about the current code path.
|
||||
let path = (new Error().stack).split("\n").slice(1).map(line => {
|
||||
return line.replace(/:\d+$/, "");
|
||||
return line.replace(/:\d+:\d+$/, "");
|
||||
}).join("|");
|
||||
let pathWithLineNumbers = (new Error().stack).split("\n").slice(1).join("|");
|
||||
|
||||
|
@ -75,7 +75,7 @@ let observer = {
|
||||
// Gather information about the current code path.
|
||||
let stack = new Error().stack;
|
||||
let path = stack.split("\n").slice(1).map(line => {
|
||||
return line.replace(/:\d+$/, "");
|
||||
return line.replace(/:\d+:\d+$/, "");
|
||||
}).join("|");
|
||||
let pathWithLineNumbers = (new Error().stack).split("\n").slice(1).join("|");
|
||||
|
||||
|
@ -41,7 +41,7 @@ function runTests()
|
||||
method: "display",
|
||||
code: error1,
|
||||
result: error1 + openComment +
|
||||
"Exception: Ouch!\n@" + scratchpad.uniqueName + ":1" + closeComment,
|
||||
"Exception: Ouch!\n@" + scratchpad.uniqueName + ":1:1" + closeComment,
|
||||
label: "error display output"
|
||||
},
|
||||
{
|
||||
@ -78,7 +78,7 @@ function runTests()
|
||||
method: "run",
|
||||
code: error1,
|
||||
result: error1 + openComment +
|
||||
"Exception: Ouch!\n@" + scratchpad.uniqueName + ":1" + closeComment,
|
||||
"Exception: Ouch!\n@" + scratchpad.uniqueName + ":1:1" + closeComment,
|
||||
label: "error run output"
|
||||
},
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ function runTests()
|
||||
method: "display",
|
||||
code: error,
|
||||
result: error + openComment + "Exception: Ouch!\n@" +
|
||||
scratchpad.uniqueName + ":1" + closeComment,
|
||||
scratchpad.uniqueName + ":1:1" + closeComment,
|
||||
label: "error display output",
|
||||
},
|
||||
{
|
||||
@ -57,7 +57,7 @@ function runTests()
|
||||
method: "run",
|
||||
code: error,
|
||||
result: error + openComment + "Exception: Ouch!\n@" +
|
||||
scratchpad.uniqueName + ":1" + closeComment,
|
||||
scratchpad.uniqueName + ":1:1" + closeComment,
|
||||
label: "error run output",
|
||||
},
|
||||
{
|
||||
|
@ -7,11 +7,11 @@ function f() {
|
||||
}
|
||||
f();
|
||||
assertEq(stack,
|
||||
"h@@evaluate:2\n" +
|
||||
"@@evaluate:4\n");
|
||||
"h@@evaluate:2:1\n" +
|
||||
"@@evaluate:4:2\n");
|
||||
|
||||
function k() {
|
||||
evaluate("stack = Error().stack", {newContext: true});
|
||||
}
|
||||
k();
|
||||
assertEq(stack, "@@evaluate:1\n");
|
||||
assertEq(stack, "@@evaluate:1:1\n");
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Test offThreadCompileScript option handling.
|
||||
|
||||
offThreadCompileScript('Error()');
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@<string>:1\n/), true);
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@<string>:1:1\n/), true);
|
||||
|
||||
offThreadCompileScript('Error()',
|
||||
{ fileName: "candelabra", lineNumber: 6502 });
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@candelabra:6502\n/), true);
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@candelabra:6502:1\n/), true);
|
||||
|
||||
var element = {};
|
||||
offThreadCompileScript('Error()', { element: element }); // shouldn't crash
|
||||
|
@ -237,9 +237,15 @@ ComputeStackString(JSContext *cx)
|
||||
if (!sb.appendInflated(cfilename, strlen(cfilename)))
|
||||
return nullptr;
|
||||
|
||||
/* Finally, : followed by the line number and a newline. */
|
||||
uint32_t line = PCToLineNumber(script, i.pc());
|
||||
if (!sb.append(':') || !NumberValueToStringBuffer(cx, NumberValue(line), sb) ||
|
||||
uint32_t column = 0;
|
||||
uint32_t line = PCToLineNumber(script, i.pc(), &column);
|
||||
// Now the line number
|
||||
if (!sb.append(':') || !NumberValueToStringBuffer(cx, NumberValue(line), sb))
|
||||
return nullptr;
|
||||
|
||||
// Finally, : followed by the column number (1-based, as in other browsers)
|
||||
// and a newline.
|
||||
if (!sb.append(':') || !NumberValueToStringBuffer(cx, NumberValue(column + 1), sb) ||
|
||||
!sb.append('\n'))
|
||||
{
|
||||
return nullptr;
|
||||
|
10
js/src/tests/js1_8_5/extensions/column-numbers.js
Normal file
10
js/src/tests/js1_8_5/extensions/column-numbers.js
Normal file
@ -0,0 +1,10 @@
|
||||
actual = 'No Error';
|
||||
expected = /column-numbers\.js:4:5/;
|
||||
try {
|
||||
throw new Error("test");
|
||||
}
|
||||
catch(ex) {
|
||||
actual = ex.stack;
|
||||
print('Caught exception ' + ex.stack);
|
||||
}
|
||||
reportMatch(expected, actual, 'column number present');
|
@ -37,7 +37,8 @@ this.createStackMessage = function createStackMessage(error, fnName, pythonFile,
|
||||
let trace, msg;
|
||||
if (typeof(error) == "object" && 'name' in error && 'stack' in error) {
|
||||
let stack = error.stack.split("\n");
|
||||
let line = stack[0].substr(stack[0].lastIndexOf(':') + 1);
|
||||
let match = stack[0].match(/:(\d+):\d+$/);
|
||||
let line = match ? parseInt(match[1]) : 0;
|
||||
msg = error.name + ('message' in error ? ": " + error.message : "");
|
||||
trace = python_stack +
|
||||
"\ninline javascript, line " + line +
|
||||
|
Loading…
Reference in New Issue
Block a user