Closed
Bug 1440468
Opened 7 years ago
Closed 7 years ago
Proxied functions can't be passed to Function.prototype.toString.call()
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: john.david.dalton, Assigned: evilpies)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete)
Attachments
(3 files)
27.78 KB,
image/png
|
Details | |
4.59 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
949 bytes,
patch
|
yulia
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
Steps to reproduce:
var a = function() {}
var p = new Proxy(a, {})
Function.prototype.toString.call(p)
// TypeError: Function.prototype.toString called on incompatible object
typeof p // "function"
Object.prototype.toString.call(p) // [object Function]
With at least Safari passing it to Function.prototype.toString.call will work.
Related to https://bugs.chromium.org/p/v8/issues/detail?id=7484
Actual results:
It throws an error.
Expected results:
It should not throw.
Updated•7 years ago
|
Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Ever confirmed: true
Product: Firefox → Core
Reporter | ||
Comment 1•7 years ago
|
||
Assignee | ||
Comment 2•7 years ago
|
||
I hadn't heard about this and I am sure I agree that this change is a good idea. I am going to look at the proposal.
Assignee | ||
Comment 3•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → evilpies
Assignee | ||
Comment 6•7 years ago
|
||
Assignee | ||
Comment 7•7 years ago
|
||
Comment on attachment 9006002 [details] [diff] [review]
Proxied functions can't be passed to Function.prototype.toString.call(). r?
I changed the error message, because "x is not a function" doesn't really make sense while allowing all callables.
Attachment #9006002 -
Flags: review?(andrebargull)
Comment 8•7 years ago
|
||
evilpie++
Comment 9•7 years ago
|
||
Comment on attachment 9006002 [details] [diff] [review]
Proxied functions can't be passed to Function.prototype.toString.call(). r?
Review of attachment 9006002 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM!
And good idea to adjust the error message.
Attachment #9006002 -
Flags: review?(andrebargull) → review+
Reporter | ||
Comment 10•7 years ago
|
||
By way of the `Function#toString` revisions `Function.prototype.toString.call` does allow proxied functions. This is now part of test262 and has been fixed in Chakra, V8, and JS Core, leaving FF as the only one not supporting this.
Assignee | ||
Comment 11•7 years ago
|
||
Attachment #9006103 -
Flags: review?(ystartsev)
Comment 12•7 years ago
|
||
Comment on attachment 9006103 [details] [diff] [review]
Fix devtools test
Looks good to me
Attachment #9006103 -
Flags: review?(ystartsev) → review+
Comment 13•7 years ago
|
||
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3528822f9b00
Proxied functions can't be passed to Function.prototype.toString.call(). r=anba
https://hg.mozilla.org/integration/mozilla-inbound/rev/02675ca26d6c
Fix devtools test for new Function.prototype.toString behavior. r=yulia
Assignee | ||
Updated•7 years ago
|
Keywords: dev-doc-needed
Comment 14•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3528822f9b00
https://hg.mozilla.org/mozilla-central/rev/02675ca26d6c
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Updated•7 years ago
|
Target Milestone: mozilla64 → mozilla63
Updated•7 years ago
|
Target Milestone: mozilla63 → mozilla64
Comment 15•6 years ago
|
||
Note to docs team:
I have added a note covering this to the Fx 64 rel notes:
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/64#JavaScript
This probably needs describing in a sensible place in the docs, and maybe adding to BCD somehow too?
Comment 17•6 years ago
|
||
It looks like this is part of https://github.com/tc39/Function-prototype-toString-revision and I've documented that when it got implemented initially: https://bugzilla.mozilla.org/show_bug.cgi?id=1317400#c52
The compat table (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString#Browser_compatibility) says Firefox 54, because that's when bug 1317400 landed. Should we update the table to say Firefox 64 and mark 54-63 as partial support for "String revision" then?
Should this be mentioned somewhere in the Proxy docs? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
Not sure if this is really a significant change that actually requires more detailed docs. Please let me know.
Flags: needinfo?(evilpies)
Assignee | ||
Comment 18•6 years ago
|
||
(In reply to Florian Scholz [:fscholz] (MDN) from comment #17)
> It looks like this is part of
> https://github.com/tc39/Function-prototype-toString-revision and I've
> documented that when it got implemented initially:
> https://bugzilla.mozilla.org/show_bug.cgi?id=1317400#c52
>
Great
> The compat table
> (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
> Global_Objects/Function/toString#Browser_compatibility) says Firefox 54,
> because that's when bug 1317400 landed. Should we update the table to say
> Firefox 64 and mark 54-63 as partial support for "String revision" then?
>
Sounds fine to me, or maybe just split this feature out?
> Should this be mentioned somewhere in the Proxy docs?
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
> Global_Objects/Proxy
>
I don't think we need to mention this on the Proxy page, but https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString#Description needs to be updated about not throwing for Proxy.
> Not sure if this is really a significant change that actually requires more
> detailed docs. Please let me know.
Flags: needinfo?(evilpies)
Comment 19•6 years ago
|
||
Thanks!
Updated
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString#Description
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString#Firefox-specific_notes
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•