Closed Bug 943613 Opened 11 years ago Closed 11 years ago

Notify JS implemented Event Target when an event listener is added / removed

Categories

(Firefox OS Graveyard :: NFC, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: psiddh, Assigned: smaug)

References

Details

Attachments

(6 files, 2 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/30.0.1599.114 Chrome/30.0.1599.114 Safari/537.36

Steps to reproduce:

Whenever a Gaia application adds / removes event listeners , JS implementation of EventTargets should be notified
Blocks: 933136
Assignee: nobody → bugs
Attached patch patch (obsolete) — Splinter Review
Avoid adding more callback magic to codegen, but just hack this into
DETH and require webidl interface to implement 
[ChromeOnly] void eventListenerAdded(nsIAtom? aEventNameWithOnPrefix);
[ChromeOnly] void eventListenerRemoved(nsIAtom? aEventNameWithOnPrefix);

Passing nsIAtom isn't super nice for js impl, but since we normally
don't have this stuff called, I'd prefer to not convert the param to
string (nor remove on-prefix)
Attachment #8338881 - Flags: review?(bzbarsky)
Attached patch example (obsolete) — Splinter Review
dump "on" + eventname to terminal when listener is added to PeerConnection
> Passing nsIAtom isn't super nice for js impl

How about we just special-case it in BindingUtils.h like we do nsIVariant and convert it to a string JS value at that point?
Comment on attachment 8338881 [details] [diff] [review]
patch

OK, I think I've convinced myself that you shouldn't end up with an exception that needs cleanup on rv in these cases (because your compartment is null and because the callback codegen won't throw strings that need deallocating).

So r=me if we either make nsIAtom convert to string or if you just make this take a DOMString and use nsDependentAtomString, which should be pretty cheap.
Attachment #8338881 - Flags: review?(bzbarsky) → review+
Ok, I'll make webidl methods take DOMString and then the param should be
without on prefix.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #8338881 - Attachment is obsolete: true
Attached patch example v2Splinter Review
Attachment #8338882 - Attachment is obsolete: true
Attached patch v3Splinter Review
Different method name
Bah, looks like possible exceptions need to be cleared.
ErrorResult is so unfriendly for C++ callers :/
> ErrorResult is so unfriendly for C++ callers :/

Bug 933378.

But in this case, see comment 4?
Attached patch v3bSplinter Review
Not pretty, but since we currently have the rather strong assertions in
ErrorResult, so have to call WouldReportJSException()
Attachment #8339238 - Flags: review?(bzbarsky)
Comment on attachment 8339238 [details] [diff] [review]
v3b

Hmm.  Maybe the right thing is to change http://hg.mozilla.org/mozilla-central/file/34f431863037/dom/bindings/CallbackObject.cpp#l169 to be:

   if ((mCompartment && mExceptionHandling == eRethrowContentExceptions) ||
       mExceptionHandling == eRethrowExceptions) {

because ShouldRethrowException always returns false if !mCompartment.

r=me either way, but seems like that would be nicer API-wise.
Attachment #8339238 - Flags: review?(bzbarsky) → review+
Aha, that is nicer. Wasn't too obvious.
No, that's wrong.  eRethrowExceptions rethrows unconditionally, no matter what mCompartment is.  So the mCompartment check should be attached only to the eRethrowContentExceptions case, as in comment 15.
Blocks: 943939
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: