Closed
Bug 584355
Opened 14 years ago
Closed 14 years ago
Function.caller property strange behaviour
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: antonglv, Assigned: paul.biggar)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(3 files, 3 obsolete files)
786 bytes,
application/vnd.mozilla.xul+xml
|
Details | |
1.32 KB,
patch
|
Details | Diff | Splinter Review | |
7.13 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Build Identifier: It seems Function.caller does not implement 'toString' method in some cases. Reproducible: Always Steps to Reproduce: 1. Open attached test.xul file in browser 2. Click both buttons 3. Actual Results: The first button throws exception: Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMWindowInternal.alert]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: test.xul :: ff :: line 8" data: no] and the second button shows message: function f() { ff(); } Expected Results: Both buttons should show message: function f() { ff(); }
Updated•14 years ago
|
QA Contact: general → general
Comment 2•14 years ago
|
||
This is a regression from the patch for bug 494235. The fix is coming in Paul's patch for bug 578158 (once I sr it ;-). Noting dependencies, attaching a spot-fix patch in a sec. /be
Assignee: nobody → brendan
Status: UNCONFIRMED → NEW
Depends on: 578158
Ever confirmed: true
OS: Linux → All
Hardware: x86 → All
Comment 3•14 years ago
|
||
Comment 4•14 years ago
|
||
Attachment #462802 -
Attachment is obsolete: true
Assignee | ||
Comment 5•14 years ago
|
||
This integrates Brendan's fix with bug 578158. It's built on top of attachment 462838 [details] [diff] [review].
Assignee | ||
Updated•14 years ago
|
Attachment #462843 -
Flags: review?(brendan)
Comment 7•14 years ago
|
||
Comment on attachment 462843 [details] [diff] [review] Patch built on attachement 462838 >-WrapEscapingClosure(JSContext *cx, JSStackFrame *fp, JSObject *funobj, JSFunction *fun) >+WrapEscapingClosure(JSContext *cx, JSStackFrame *fp, JSFunction *fun) Good catch -- no need for funobj (nor was there ever). > NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent) > { > if (clasp == &js_FunctionClass) >- return NewFunction(cx, NULL, parent); >- >- return NewNonFunction<withGivenProto>(cx, clasp, proto, parent); >+ return detail::NewObject<withGivenProto, true>(cx, clasp, proto, parent); >+ else >+ return detail::NewObject<withGivenProto, false>(cx, clasp, proto, parent); else after return is a non-sequitur, avoid. But in cases like this one, return isFunction() ? ... : ... seems better yet. Must the C++ template parameter be true or false literally, or could you pass isFunction() and common even more code? I'm dreaming, I know. /be
Assignee | ||
Comment 8•14 years ago
|
||
With the fixes from Brendan's review. We can't put a run-time value into a template instantiation, as it expects a compile-time constant.
Attachment #462843 -
Attachment is obsolete: true
Attachment #463117 -
Flags: review?(brendan)
Attachment #462843 -
Flags: review?(brendan)
Comment 9•14 years ago
|
||
Comment on attachment 463117 [details] [diff] [review] With review changes. Need the test I included in my second attached patch -- r=me with that included. /be
Attachment #463117 -
Flags: review?(brendan) → review+
Assignee | ||
Comment 10•14 years ago
|
||
Now with testcase.
Attachment #463117 -
Attachment is obsolete: true
Assignee | ||
Comment 11•14 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/6387329315b2
Whiteboard: fixed-in-tracemonkey
Comment 12•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/6387329315b2
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•