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.
Have you considered using GlobalObject::warnOnceAbout?
(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.
I'll add this to the 39 site compat doc hopefully this weekend.
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.
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).