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)
Tracking
()
NEW
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.
Comment 1•13 years ago
|
||
We have similar JS_IsArrayObject checks in many places: IDB, WebGL...
It is not clear to me what WebIDL says about this case.
Updated•13 years ago
|
![]() |
||
Comment 2•13 years ago
|
||
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).
Comment 3•13 years ago
|
||
(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.
![]() |
||
Comment 4•13 years ago
|
||
> 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[].
Comment 5•13 years ago
|
||
Ah, right. Filed https://www.w3.org/Bugs/Public/show_bug.cgi?id=17711
Comment 6•7 years ago
|
||
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
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•