mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 05:10:49 +00:00
Bug 1038238 - Part 0: Make js/src/vm/SavedStacks.h use 1-based column numbers,
like js::ComputeStackString and other browsers do; r=jorendorff https://bugzilla.mozilla.org/show_bug.cgi?id=1038238
This commit is contained in:
parent
d8c68a04b7
commit
2edf06beb3
@ -51,7 +51,7 @@ function testFocus(sw, hud) {
|
||||
|
||||
var loc = node.querySelector(".message-location");
|
||||
ok(loc, "location element exists");
|
||||
is(loc.textContent.trim(), sw.Scratchpad.uniqueName + ":1:0",
|
||||
is(loc.textContent.trim(), sw.Scratchpad.uniqueName + ":1:1",
|
||||
"location value is correct");
|
||||
|
||||
sw.addEventListener("focus", function onFocus() {
|
||||
|
@ -35,10 +35,10 @@ function test() {
|
||||
|
||||
// The expected stack trace object.
|
||||
let stacktrace = [
|
||||
{ columnNumber: 2, filename: TEST_URI, functionName: "window.foobar585956c", language: 2, lineNumber: 9 },
|
||||
{ columnNumber: 9, filename: TEST_URI, functionName: "foobar585956b", language: 2, lineNumber: 14 },
|
||||
{ columnNumber: 9, filename: TEST_URI, functionName: "foobar585956a", language: 2, lineNumber: 18 },
|
||||
{ columnNumber: 0, filename: TEST_URI, functionName: "", language: 2, lineNumber: 21 }
|
||||
{ columnNumber: 3, filename: TEST_URI, functionName: "window.foobar585956c", language: 2, lineNumber: 9 },
|
||||
{ columnNumber: 10, filename: TEST_URI, functionName: "foobar585956b", language: 2, lineNumber: 14 },
|
||||
{ columnNumber: 10, filename: TEST_URI, functionName: "foobar585956a", language: 2, lineNumber: 18 },
|
||||
{ columnNumber: 1, filename: TEST_URI, functionName: "", language: 2, lineNumber: 21 }
|
||||
];
|
||||
|
||||
ok(obj._stacktrace, "found stacktrace object");
|
||||
|
@ -30,7 +30,7 @@ function consoleOpened(aHud) {
|
||||
|
||||
function testLocationColumn() {
|
||||
let messages = hud.outputNode.children;
|
||||
let expected = ['10:6', '10:38', '11:8', '12:10', '13:8', '14:6'];
|
||||
let expected = ['10:7', '10:39', '11:9', '12:11', '13:9', '14:7'];
|
||||
|
||||
for(let i = 0, len = messages.length; i < len; i++) {
|
||||
let msg = messages[i].textContent;
|
||||
|
@ -45,13 +45,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
||||
ise(e.code, DOMException.NOT_SUPPORTED_ERR,
|
||||
"Should have the right 'code'");
|
||||
ise(e.stack,
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:38:6\n",
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:38:7\n",
|
||||
"Exception stack should still only show our code");
|
||||
ise(e.filename,
|
||||
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
|
||||
"Should still have the right file name");
|
||||
ise(e.lineNumber, 38, "Should still have the right line number");
|
||||
todo_is(e.columnNumber, 6,
|
||||
todo_is(e.columnNumber, 7,
|
||||
"No column number support for DOMException yet");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
|
@ -45,7 +45,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
||||
ensurePromiseFail.bind(null, 1),
|
||||
checkExn.bind(null, 44, "NS_ERROR_UNEXPECTED", "", undefined,
|
||||
ourFile, 1,
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:44:6\n")),
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:44:7\n")),
|
||||
t.testPromiseWithThrowingContentPromiseInit(function() {
|
||||
thereIsNoSuchContentFunction1();
|
||||
}).then(
|
||||
@ -64,7 +64,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
||||
checkExn.bind(null, 61, "ReferenceError",
|
||||
"thereIsNoSuchContentFunction2 is not defined",
|
||||
undefined, ourFile, 4,
|
||||
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:61:11\n")),
|
||||
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:61:11\nAsync*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:60:7\n")),
|
||||
t.testPromiseWithThrowingChromeThenable().then(
|
||||
ensurePromiseFail.bind(null, 5),
|
||||
checkExn.bind(null, 0, "NS_ERROR_UNEXPECTED", "", undefined, "", 5, "")),
|
||||
@ -81,13 +81,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
||||
checkExn.bind(null, 79, "NotFoundError",
|
||||
"We are a second DOMException",
|
||||
DOMException.NOT_FOUND_ERR, ourFile, 7,
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:79:6\n")),
|
||||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:79:7\n")),
|
||||
t.testPromiseWithDOMExceptionThrowingThenFunction().then(
|
||||
ensurePromiseFail.bind(null, 8),
|
||||
checkExn.bind(null, 85, "NetworkError",
|
||||
"We are a third DOMException",
|
||||
DOMException.NETWORK_ERR, ourFile, 8,
|
||||
"Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:85:6\n")),
|
||||
"Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:85:7\n")),
|
||||
t.testPromiseWithDOMExceptionThrowingThenable().then(
|
||||
ensurePromiseFail.bind(null, 9),
|
||||
checkExn.bind(null, 0, "TypeMismatchError",
|
||||
|
@ -171,10 +171,10 @@ function testConsoleGroup(aMessageObject) {
|
||||
function startTraceTest() {
|
||||
gLevel = "trace";
|
||||
gArgs = [
|
||||
{columnNumber: 8, filename: TEST_URI, functionName: "window.foobar585956c", language: 2, lineNumber: 6},
|
||||
{columnNumber: 15, filename: TEST_URI, functionName: "foobar585956b", language: 2, lineNumber: 11},
|
||||
{columnNumber: 15, filename: TEST_URI, functionName: "foobar585956a", language: 2, lineNumber: 15},
|
||||
{columnNumber: 0, filename: TEST_URI, functionName: "onclick", language: 2, lineNumber: 1}
|
||||
{columnNumber: 9, filename: TEST_URI, functionName: "window.foobar585956c", language: 2, lineNumber: 6},
|
||||
{columnNumber: 16, filename: TEST_URI, functionName: "foobar585956b", language: 2, lineNumber: 11},
|
||||
{columnNumber: 16, filename: TEST_URI, functionName: "foobar585956a", language: 2, lineNumber: 15},
|
||||
{columnNumber: 1, filename: TEST_URI, functionName: "onclick", language: 2, lineNumber: 1}
|
||||
];
|
||||
|
||||
let button = gWindow.document.getElementById("test-trace");
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
load(libdir + 'asserts.js');
|
||||
|
||||
assertEq(evaluate("saveStack().column"), 0);
|
||||
assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1729);
|
||||
assertEq(evaluate("\nsaveStack().column", { columnNumber: 1729 }), 0);
|
||||
assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 42);
|
||||
assertEq(evaluate("saveStack().column"), 1);
|
||||
assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1730);
|
||||
assertEq(evaluate("\nsaveStack().column", { columnNumber: 1729 }), 1);
|
||||
assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 43);
|
||||
assertThrowsInstanceOf(() => evaluate("saveStack().column", { columnNumber: -10 }),
|
||||
RangeError);
|
||||
assertThrowsInstanceOf(() => evaluate("saveStack().column", { columnNumber: Math.pow(2,30) }),
|
||||
@ -22,7 +22,7 @@ if (helperThreadCount() > 0) {
|
||||
|
||||
print("offThreadCompileScript 3");
|
||||
offThreadCompileScript("saveStack().column", { columnNumber: 10000 });
|
||||
assertEq(runOffThreadScript(), 10000);
|
||||
assertEq(runOffThreadScript(), 10001);
|
||||
}
|
||||
|
||||
// Check handling of columns near the limit of our ability to represent them.
|
||||
@ -30,12 +30,12 @@ if (helperThreadCount() > 0) {
|
||||
// it's probably not worth it to be thorough.)
|
||||
const maxColumn = Math.pow(2, 30) - 1;
|
||||
assertEq(evaluate("saveStack().column", { columnNumber: maxColumn }),
|
||||
maxColumn);
|
||||
maxColumn + 1);
|
||||
|
||||
// Check the 'silently zero' behavior when we reach the limit of the srcnotes
|
||||
// column encoding.
|
||||
assertEq(evaluate(" saveStack().column", { columnNumber: maxColumn }),
|
||||
0);
|
||||
1);
|
||||
|
||||
// Gathering source text for inclusion in error messages should not try to reach
|
||||
// outside the buffer to find the start of the source line. The below should
|
||||
|
@ -28,13 +28,13 @@ assertEq(stack.functionDisplayName, "tester");
|
||||
|
||||
assertEq(stack.parent.functionDisplayName, "doTest");
|
||||
assertEq(stack.parent.line, 6);
|
||||
assertEq(stack.parent.column, 4);
|
||||
assertEq(stack.parent.column, 5);
|
||||
|
||||
assertEq(stack.parent.parent.functionDisplayName, "test");
|
||||
assertEq(stack.parent.parent.line, 10);
|
||||
assertEq(stack.parent.parent.column, 4);
|
||||
assertEq(stack.parent.parent.column, 5);
|
||||
|
||||
assertEq(stack.parent.parent.parent.line, 24);
|
||||
assertEq(stack.parent.parent.parent.column, 0);
|
||||
assertEq(stack.parent.parent.parent.column, 1);
|
||||
|
||||
assertEq(stack.parent.parent.parent.parent, null);
|
||||
|
@ -1103,6 +1103,10 @@ SavedStacks::getLocation(JSContext *cx, const FrameIter &iter, MutableHandleLoca
|
||||
return false;
|
||||
|
||||
locationp->line = iter.computeLine(&locationp->column);
|
||||
// XXX: Make the column 1-based as in other browsers, instead of 0-based
|
||||
// which is how SpiderMonkey stores it internally. This will be
|
||||
// unnecessary once bug 1144340 is fixed.
|
||||
locationp->column++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1126,7 +1130,8 @@ SavedStacks::getLocation(JSContext *cx, const FrameIter &iter, MutableHandleLoca
|
||||
uint32_t column;
|
||||
uint32_t line = PCToLineNumber(script, pc, &column);
|
||||
|
||||
LocationValue value(source, line, column);
|
||||
// Make the column 1-based. See comment above.
|
||||
LocationValue value(source, line, column + 1);
|
||||
if (!pcLocationMap.add(p, key, value))
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user