Warn when __noSuchMethod__ is used

RESOLVED FIXED in Firefox 39

Status

()

Core
JavaScript Engine
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: jandem, Assigned: jandem)

Tracking

({dev-doc-complete, site-compat})

unspecified
mozilla39
dev-doc-complete, site-compat
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox39 fixed)

Details

(Whiteboard: [DocArea=JS])

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
Created attachment 8573973 [details] [diff] [review]
Patch

With this patch we show a console warning whenever __noSuchMethod__ is used. We warn at most once per compartment, to avoid flooding the console.
Attachment #8573973 - Flags: review?(jorendorff)

Updated

3 years ago
Keywords: dev-doc-needed
Have you considered using GlobalObject::warnOnceAbout?
(Assignee)

Comment 2

3 years ago
(In reply to Tom Schuster [:evilpie] from comment #1)
> Have you considered using GlobalObject::warnOnceAbout?

Ah I didn't know about it. It looks more complicated to me: (1) it requires a js.msg entry and (2) I don't understand why it uses a full HeapValue to store a flag. A bool on the compartment seems both simpler and more efficient. If people prefer warnOnceAbout I can use that though.
Attachment #8573973 - Flags: review?(jorendorff) → review+

Updated

3 years ago
Blocks: 1142337
(Assignee)

Comment 3

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/19fafff99435
https://hg.mozilla.org/mozilla-central/rev/19fafff99435
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox39: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
No longer blocks: 1142337
Whiteboard: [DocArea=JS]

Updated

3 years ago
Depends on: 1143065
https://developer.mozilla.org/en-US/Firefox/Releases/39#JavaScript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod
Keywords: dev-doc-needed → dev-doc-complete
I'll add this to the 39 site compat doc hopefully this weekend.
Keywords: dev-doc-complete → dev-doc-needed
OK done. https://developer.mozilla.org/en-US/Firefox/Releases/39/Site_Compatibility
Keywords: dev-doc-needed → dev-doc-complete, site-compat

Updated

2 years ago
See Also: → bug 1148638

Comment 8

2 years ago
Is the officially recommended alternative handler's "get" for Proxy?
https://bugzilla.mozilla.org/show_bug.cgi?id=683218#c14
(In reply to YUKI "Piro" Hiroshi from comment #8)
Yes, pretty much.  There are perhaps different ways to skin the dead cat here using proxies, but adding a catchall "get" trap via an interspersed proxy is the easiest way to do it.

Proxies do not do nice things to performance, tho, and will not for some time.  You *really* are better off doing property-existence checks than continuing whatever approach it is you're taking right now.
And I should be *extra* clear to note: DO NOT intersperse an object into the prototype chain of Object.prototype, to catch *all* lookups that aren't found on earlier objects in the prototype chain.  This is an EXTRAORDINARILY BAD idea that will destroy performance for vast swaths of code, and I'm actively working on making it impossible to do this, for this and other reasons.
(Assignee)

Comment 11

2 years ago
Also, many use cases for __noSuchMethod__ don't need a proxy. When you just want to forward some method calls to another object, you can often just add a function for each property that forwards the call to the other object (or use a for-in loop to do this automatically for each method on the target object).
You need to log in before you can comment on or make changes to this bug.