Open Bug 770350 Opened 13 years ago Updated 3 years ago

nsIDOMMutationObserver.observe doesn't accept JS Proxy for attributeFilter option

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86_64
Windows 7
defect

Tracking

()

People

(Reporter: ochameau, Unassigned)

References

Details

In Jetpack, we are using JS proxies for content scripts. These proxies are on top of xraywrappers and can be used for any DOM feature, including new MutationObserver API. Unfortunately, the observer method doesn't work with a JS proxy for attributeFilter option's attribute. No matter what we do in Proxy handler, it will immediatly throw a NS_ERROR_ILLEGAL_VALUE exception: var obs = new MutationObserver(function () {}); obs.observe(document, { attributes: true, attributeFilter : Proxy.create({}, Array.prototype) }); // Exception: Component returned failure code: 0x80070057 // (NS_ERROR_ILLEGAL_VALUE) [nsIDOMMutationObserver.observe] I haven't ran gdb, but I suspect this code to be failing: http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDOMMutationObserver.cpp#549 rv = nsContentUtils::JSArrayToAtomArray(aCx, d.attributeFilter, filters); http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentUtils.cpp#6756 if (!JS_IsArrayObject(aCx, obj) || !JS_GetArrayLength(aCx, obj, &length)) { return NS_ERROR_ILLEGAL_VALUE; } http://mxr.mozilla.org/mozilla-central/source/js/src/jsapi.cpp#4509 return ObjectClassIs(*obj, ESClass_Array, cx); It isn't a blocker for us as we have a workaround. And it may only be matter of using new DirectProxies API? But it would be cool to make it work with some JS proxies somehow.
Blocks: 769006
We have similar JS_IsArrayObject checks in many places: IDB, WebGL... It is not clear to me what WebIDL says about this case.
Currently the spec for mutation observers says: DOMString[] attributeFilter; (Is that really right? Should mutations to the filter after the init call automatically propagate to the mutation observer??) Then WebIDL says this should throw if the filter is not a "native Array object" (and a few other things, like platform objects supporting indexed properties). It does not seem to define what "native Array object" means (possibly a bug in WebIDL there).
(In reply to Boris Zbarsky (:bz) from comment #2) > Currently the spec for mutation observers says: > > DOMString[] attributeFilter; > > (Is that really right? Should mutations to the filter after the init call > automatically propagate to the mutation observer??) What init call? You call observe(the_node_you_want_to_observe, observing_options). So, no, changes to the filter doesn't make sense.
> What init call? Sorry, the observe() call. > So, no, changes to the filter doesn't make sense. Then attributeFilter should be sequence<DOMString>. Right now it's being passed by value, not by reference, at least in some cases, because it's a DOMString[].
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.