JS errors in event handlers lack file and line number info
Categories
(Core :: DOM: Core & HTML, enhancement, P5)
Tracking
()
People
(Reporter: fur, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [firebug-p3])
Attachments
(2 files)
Comment 1•28 years ago
|
||
Updated•27 years ago
|
Comment 2•27 years ago
|
||
Comment 3•27 years ago
|
||
Updated•27 years ago
|
Updated•27 years ago
|
Comment 6•27 years ago
|
||
Updated•26 years ago
|
Updated•26 years ago
|
Comment 8•26 years ago
|
||
Comment 9•26 years ago
|
||
Comment 11•26 years ago
|
||
Comment 12•26 years ago
|
||
Comment 13•26 years ago
|
||
Updated•26 years ago
|
Updated•26 years ago
|
Comment 15•26 years ago
|
||
Comment 16•26 years ago
|
||
Comment 17•25 years ago
|
||
Comment 18•25 years ago
|
||
Comment 19•24 years ago
|
||
Comment 21•22 years ago
|
||
Comment 22•22 years ago
|
||
Comment 23•22 years ago
|
||
Comment 24•22 years ago
|
||
Comment 25•22 years ago
|
||
Comment 26•21 years ago
|
||
Comment 28•18 years ago
|
||
Updated•18 years ago
|
Comment 29•18 years ago
|
||
Updated•18 years ago
|
Updated•18 years ago
|
Comment 30•17 years ago
|
||
Comment 31•13 years ago
|
||
Comment 32•8 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
Updated•4 years ago
|
Comment 33•20 days ago
|
||
I checked this against a current trunk build (opt, headless) with a page whose inline handler throws:
<button onclick="
var x = 1;
throw new Error('inline boom');">go</button>
The throw is on line 10 of the file. The console reports:
JavaScript error: file:///.../t11240.html, line 3: Error: inline boom
So the original complaint is fixed. Errors from inline event handlers now carry a filename, the document URL. EventListenerManager::SetEventHandler passes it to the compile options with setFileAndLine(url, 0), and it attaches the element and attribute name through UpdateFunctionDebugMetadata.
One part is still open. The line number is relative to the attribute value, where line 1 is the first line of the attribute text. It is not the line in the document. The throw above is on line 3 of the attribute but line 10 of the file, so the report doesn't help find it in a large page.
A fix looks plausible. nsHtml5Tokenizer already tracks attributeLine and passes it to nsHtml5HtmlAttributes::addAttribute, but that function ignores its aLine argument, so the line never reaches the DOM. To use it, the parser would need to:
- Keep the line in nsHtml5AttributeEntry.
- Carry it to the element for on* attributes through a tree operation.
- Store it per element.
- Offset the compile line in SetEventHandler by it.
Two caveats. attributeLine is where the attribute name starts, not where the value starts, so multi-line values would need the tokenizer to record the value start. It would also only cover parser-created elements. Handlers set through setAttribute, innerHTML or fragment parsing have no document position.
Closing this as FIXED; I filed a separate bug for the document-relative line number. The other items from comment 28 (the event, the element, an XPath-style identifier) are not covered by this test. They would be better handled in a separate enhancement bug.
Description
•