Bug 18855 - Mechanism for storing line numbers and source URLs in JavaScript exceptions needs improvement
Summary: Mechanism for storing line numbers and source URLs in JavaScript exceptions n...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar
: 62897 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-05-02 14:42 PDT by David Kilzer (:ddkilzer)
Modified: 2014-12-17 16:52 PST (History)
9 users (show)

See Also:


Attachments
Test cases (1007 bytes, text/html)
2008-05-02 14:59 PDT, David Kilzer (:ddkilzer)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2008-05-02 14:42:28 PDT
* SUMMARY
The mechanism for storing line numbers and source URLs for JavaScript exceptions fails to work in the following cases:

- Throwing any non-object (like a string or a number)
- Throwing any object with a property named "line" or a property named "sourceURL"

What JavaScriptCore does now (in KJS::Node::handleException()) is to *modify* the exception object to add the "line" and "sourceURL" properties (but only if neither currently exist).  It seems wrong to modify a JavaScript object simply to store metadata and obviously doesn't work if the exception is not an object.

* STEPS TO REPRODUCE
1. Launch Safari/WebKit.
2. Open the Web Inspector.
3. Open one of the attached test cases.

* RESULTS
No line number or source URL is provided for the exceptions thrown in the test cases.

* REGRESSION
I don't think this is a regression.  The code to set the "line" and "sourceURL" properties on the exception object existed as far back as r9352 in nodes.cpp.
Comment 1 David Kilzer (:ddkilzer) 2008-05-02 14:59:37 PDT
Created attachment 20932 [details]
Test cases

Additional fun facts:

- Throwing an exception inside a function body from an onclick handler results in "undefined" for the description--always.

- Throwing an object with just a "sourceURL" line will cause that URL to be printed in the Web Inspector.
Comment 2 David Kilzer (:ddkilzer) 2008-05-02 15:27:55 PDT
<rdar://problem/5908160>
Comment 3 Patrick Mueller 2009-12-04 08:15:11 PST
It would be good to provide a set of tests to run across browsers to capture what everyone is doing here.  Basically, something like Dave's tests that just run and produce results.  But also include some of the existing 'built-in' exceptions, both thrown by existing internal code, as well as cons'd up by the user (eg, someone write's code that does a "throw new Error()")
Comment 4 Gavin Barraclough 2012-09-07 00:39:57 PDT
*** Bug 62897 has been marked as a duplicate of this bug. ***
Comment 5 Oliver Hunt 2013-04-18 23:20:02 PDT
The regular object and the primitive cases should work now.  I think we are still deliberately deferring to properties on objects if there's a lineNo property