See the attached testcase. It should alert "[object HTMLBodyElement]", not undefined, and does in fx7. This would be really easy to fix in the nodelist proxy code, except that the JS engined doesn't expose the APIs that do the right thing (that is, looking up the prop on the proto but using the proxy itself as |this|) to consumers. I suspect we need to fix this for fx10....
Created attachment 570806 [details] An even worse manifestation of this problem We forward the fast paths to proto if it's been tampered with, so this testcase throws when it shouldn't.
I'm happy to take this given some indication of what public APIs would be acceptable here for jseng....
JSBool JS_ProxyGetPropertyTo(JSContext* cx, JSObject* obj, T propname, JSObject* onBehalfOf, jsval* vp); perhaps, conditioned on a comment by it in jsapi.h explaining the exact meanings of obj and onBehalfOf, could do it.
Where T is a jsid for now? Or would you prefer separate uint32 and property name variants? If so, what should T be for the name variant?
T would be jsid and uint32 for now. I need to add JSPropertyName to JSAPI so there could be a third variant for property names known not to be uint32 (and not special, but nothing anyone cares about is special) before you could add a JSPropertyName variant.
Created attachment 570841 [details] [diff] [review] When forwarding gets to the prototype in nodelists, make sure to use the right |this|. Now that I look at the code, maybe the api should use 'Forward' instead of 'Proxy'?
Created attachment 570842 [details] [diff] [review] Including the test file too
Comment on attachment 570842 [details] [diff] [review] Including the test file too Review of attachment 570842 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsapi.h @@ +3431,5 @@ > extern JS_PUBLIC_API(JSBool) > JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp); > > extern JS_PUBLIC_API(JSBool) > +JS_ProxyGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, jsval *vp); I suggested this name. In isolation it's a reasonable name. But now that I think about it, this kind of clashes a bit with Proxy objects and all that nonsense. What do you think of JS_ForwardGetPropertyTo instead, mutatis mutandis for element?
Ahahaha, we had the same idea! :-D That's what I get for not reading bug commentas.
> Ahahaha, we had the same idea! Yep. I'll make that change. ;)