Open Bug 797325 Opened 12 years ago Updated 2 years ago

Components.utils.atline should be true

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: Yoric, Unassigned)

Details

(Whiteboard: [js:p3])

Attachments

(2 files, 2 obsolete files)

Experience shows that, at least in some cases, throwing an error from a file that contains //@line directives displays line numbers as if these directives were absent.

Not quite sure how to best write a test. I attach a trivial patch to test_jsctypes.js.in that throws an error. The error is thrown from line 644 but the xpcshell output indicates that it is thrown from line 629.

This is pretty annoying for debugging, in particular for intermittent oranges. I have had the same issues with other files on m-c, btw.
Adding
  Components.utils.atline = true;
in head.js seems to do the trick for test_jsctypes.js.in.

Note that this contradicts the MDN documentation that states that |atline| is readonly. However, doing this from within test_jsctypes.js.in does not help.

Unfortunately, this is not really an acceptable solution, as it does not port to, e.g. code modules.
Summary: //@line Does not seem to be interpreted correctly → Components.utils.atline should be true
There is potential for problems with Components.utils.atline universally true. While it is always useful for tinderbox tests, it may or may not be what $user wants with Firefox builds.
If you're a Firefox developer and you just built and have the corresponding source, you probably want atline = true, but if you're an occasional developer, or an addon developer, or some other kind of developer, chances are you'd like actual lines and file names of where the error is in what you have, which is the preprocessed file, and would likely prefer atline = false.
That makes sense. Perhaps we should have atline = true in debug builds, for instance.
We could add '-e "options('atline');"' to xpcshell invocations, and add an about:config pref for Firefox itself ; we could set it for mochitests.
Sounds like a plan.
Let's start with xpcshell.
Attachment #667465 - Flags: feedback?(mh+mozilla)
Comment on attachment 667465 [details] [diff] [review]
Setting Components.utils.atline = true for xpcshell tests.

I think it would be better to set with -e 'options("atline")' on the xpcshell command line.
Attachment #667465 - Flags: feedback?(mh+mozilla) → feedback-
Assignee: general → dteller
Attachment #667465 - Attachment is obsolete: true
Attachment #667470 - Flags: review?(mh+mozilla)
Comment on attachment 667470 [details] [diff] [review]
Setting options("atline") for xpcshell tests.

Review of attachment 667470 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/xpcshell/runxpcshelltests.py
@@ +200,5 @@
>          '-n',
>          '-s',
>          '-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
> +        '-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath,
> +        '-e', "options('atline');"

I'd invert the quotes for consistency.

Note I'm not a peer for the test harness. Ted is.
Attachment #667470 - Flags: review?(ted.mielczarek)
Attachment #667470 - Flags: review?(mh+mozilla)
Attachment #667470 - Flags: review+
Swapped quotes.
Attachment #667470 - Attachment is obsolete: true
Attachment #667470 - Flags: review?(ted.mielczarek)
Attachment #667480 - Flags: review?(ted.mielczarek)
As mentioned bu glandium, bug 246286 contains what looks like a (unfortunately bitrotten) patch for the mochitest side. If anyone wants to pick it up, this would be great.
Assignee: dteller → general
Comment on attachment 667480 [details] [diff] [review]
Setting options("atline") for xpcshell tests.

Review of attachment 667480 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/xpcshell/runxpcshelltests.py
@@ +200,5 @@
>          '-n',
>          '-s',
>          '-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
> +        '-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath,
> +        '-e', 'options("atline");'

Seems reasonable, but maybe we should just compress these three -e arguments into one -e?
'-e', 'const _HTTPD_JS_PATH = "%s"; const _HEAD_JS_PATH = "%s"; options("atline");' % (self.httpdJSPath, self.headJSPath)
Attachment #667480 - Flags: review?(ted.mielczarek) → review+
Assignee: general → dteller
Does this bug only cover js code in tests? i.e. if I want the line numbers to match up for mobile/android/chrome/content/browser.js, should I just set Components.utils.atline=true in that file, or will this bug eventually fix that problem?
(In reply to Kartikaya Gupta (:kats) from comment #13)
> Does this bug only cover js code in tests? i.e. if I want the line numbers
> to match up for mobile/android/chrome/content/browser.js, should I just set
> Components.utils.atline=true in that file, or will this bug eventually fix
> that problem?

See comment 2.
Thanks, I misunderstood that comment the first time I read through it.
Whiteboard: [js:p3]
I don't think I'll have time to work on this in any near future.
Assignee: dteller → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: