Closed
Bug 1440949
Opened 6 years ago
Closed 6 years ago
Allow plain JS objects to require addon interposition
Categories
(Firefox :: Extension Compatibility, enhancement)
Firefox
Extension Compatibility
Tracking
()
RESOLVED
FIXED
Firefox 60
Tracking | Status | |
---|---|---|
firefox60 | --- | fixed |
People
(Reporter: bgrins, Assigned: bgrins)
References
Details
Attachments
(1 file)
For Bug 1392352, I'm planning to turn gBrowser into a plain JS object instead of a DOM node. So in order to apply TabBrowserElementInterposition we need to provide a way for the object to run interpositions as suggested in https://bugzilla.mozilla.org/show_bug.cgi?id=1392352#c77.
Comment hidden (mozreview-request) |
Comment 2•6 years ago
|
||
mozreview-review |
Comment on attachment 8953781 [details] Bug 1440949 - Allow plain JS objects to request addon interposition; https://reviewboard.mozilla.org/r/222980/#review228898 Close. Just a couple of minor issues. ::: js/xpconnect/wrappers/AddonWrapper.cpp:45 (Diff revision 1) > > bool > +RequiresInterpositions(JSContext* cx, HandleObject target) > +{ > + bool requiresAddonInterpositions; > + RootedObject unwrapped(cx, UncheckedUnwrap(target)); This is not especially cheap. Please just pass in the unwrapped object we already have rather than unwrapping again. ::: js/xpconnect/wrappers/AddonWrapper.cpp:48 (Diff revision 1) > +{ > + bool requiresAddonInterpositions; > + RootedObject unwrapped(cx, UncheckedUnwrap(target)); > + JSAutoCompartment ac(cx, unwrapped); > + > + if (!JS_HasOwnProperty(cx, unwrapped, "requiresAddonInterpositions", &requiresAddonInterpositions)) { It probably doesn't matter much, but we should also check whether the property value is `true` rather than just that it exists. It would be strange/confusing to have `requiresAddonInterpositions: false` turn interpositions on. Also, if this fails, we need to do `JS_ClearPendingException(cx)`, or we'll run into problems.
Attachment #8953781 -
Flags: review?(kmaglione+bmo)
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•6 years ago
|
||
Thanks for the review, uploaded a new version. I'm not sure if the truthy testing is correct - I pulled this from some other code accessing JS_GetOwnPropertyDescriptor.
Comment 5•6 years ago
|
||
mozreview-review |
Comment on attachment 8953781 [details] Bug 1440949 - Allow plain JS objects to request addon interposition; https://reviewboard.mozilla.org/r/222980/#review229378 ::: js/xpconnect/wrappers/AddonWrapper.cpp:42 (Diff revision 2) > return; > JS_ReportErrorUTF8(cx, msg, bytes.ptr()); > } > > bool > +RequiresInterpositions(JSContext* cx, RootedObject* unwrapped) s/RootedObject\*/HandleObject/ ::: js/xpconnect/wrappers/AddonWrapper.cpp:44 (Diff revision 2) > } > > bool > +RequiresInterpositions(JSContext* cx, RootedObject* unwrapped) > +{ > + JS::Rooted<JS::PropertyDescriptor> desc(cx); `Rooted<PropertyDescriptor>` ::: js/xpconnect/wrappers/AddonWrapper.cpp:52 (Diff revision 2) > + if (!JS_GetOwnPropertyDescriptor(cx, *unwrapped, "requiresAddonInterpositions", &desc)) { > + JS_ClearPendingException(cx); > + return false; > + } > + > + return desc.object() && desc.value().isTrue(); s/object/hasValue/
Attachment #8953781 -
Flags: review?(kmaglione+bmo) → review+
Comment hidden (mozreview-request) |
Pushed by bgrinstead@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/eacdc0b781e2 Allow plain JS objects to request addon interposition;r=kmag
Comment 8•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/eacdc0b781e2
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
You need to log in
before you can comment on or make changes to this bug.
Description
•