Audit nsIScriptError.columnNumber consumers in DevTools
Categories
(DevTools :: General, task)
Tracking
(Not tracked)
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(2 files)
nsIScriptError
has been using a mix of 0-based and 1-based column number.
bug 1864168 and bug 1864783 are going to switch some consumer of 0-based column number to 1-based.
If there's any code in DevTools that listens to nsIScriptError
s and expects the columnNumber
being 0-based, it should be rewritten to expect 1-based column number,
or maybe expect that "the column number base is unknown".
Assignee | ||
Comment 1•10 months ago
|
||
As a first step, here's the data flow into the nsIScriptError.columnNumber
field.
Some consumers had been using 1-based column number,
other consumers had been using 0-based column number, and some of them are switched to 1-based column number by the patch stack for bug 1862693, bug 1862814, bug 1864155, and bug 1864168.
Assignee | ||
Comment 2•10 months ago
|
||
- Regular JavaScript is logged with 1-based column number in the console
- nsIScriptError error/warnings generated from Gecko C++ code is logged with 0-based column number, which is inconsistent with other regular JavaScript error reported to the same file
- CSS error/warning is logged with 1-based column number in the console
- during the conversion from
nsIScriptError
to resource or message or action, there's no place that converts the base - The consumer of the nsIScriptError.columnNumber expects the 1-based and converts between 0-based (below 2 code)
- I don't see anywhere else that expects the base
export function getExceptionPreview(target, tokenPos, codeMirror) {
...
const tokenColumnStart = match.location.start.column + 1;
addEditorExceptionLine() {
...
column: columnNumber - 1,
Assignee | ||
Comment 3•10 months ago
|
||
Assignee | ||
Comment 4•10 months ago
|
||
Given the above, I think the code that's using 0-based column number for nsIScriptError.columnNumber just need to be fixed to 1-based (like bug 1862814 patches), and there's no change necessary to devtools' side.
Assignee | ||
Comment 5•10 months ago
|
||
same for Console API mentioned in https://phabricator.services.mozilla.com/D193370
most consumers have been using 1-based, and only service worker-related warning have been using 0-based,
and switching to 1-based should be fine.
Description
•